PHP应用程序的面向对象设计 [英] Object Oriented design for PHP application

查看:39
本文介绍了PHP应用程序的面向对象设计的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于我们的学校项目,我们的任务是定义一个描述PHP应用程序体系结构的设计文档.

For our school project, we are tasked to define a design document describing the architecture of a PHP application.

我们可以自由决定要在文档中包括什么.

We are free te decide what to include in the document.

我们的教授建议使用许多(UML)图.

Our professor suggested, lots of (UML) diagrams.

他还要求我们考虑类图,但是要小心,因为PHP并不是完全面向对象的.

He also asked us to consider class diagrams, but with care, as PHP is not fully object oriented.

我的问题:域驱动的面向对象设计对于PHP应用程序是否可行?在PHP中进行OO时要考虑什么?优缺点都有什么?在PHP和PHP最佳实践中有关OO的任何有用资源吗?

My question: Is a Domain Driven Object Oriented Design feasible for a PHP application? What to consider when doing OO in PHP? What are the pro's and con's? Any helpful resources on OO in PHP and PHP best-practices?

推荐答案

恕我直言,在不知道应用程序应该做什么的情况下描述任何应用程序的体系结构是非常困难的.任何复杂程度的所有应用程序(PHP或其他)看起来都不同.

IMHO it's pretty difficult to describe the architecture of any application without knowing what the application is supposed to do. All applications (PHP or otherwise) of any complexity look different.

其次,PHP5为您提供类/对象以及通常过多的OO争吵-因此将其描述为不完全面向对象"是令人误解的.如果您的意思是可以采取一种不限制于对象的程序方法,那么可以,但是,如果您希望一切都成为一个对象,那么这就是您的选择.

Secondly, PHP5 gives you classes/objects and the usual plethora of OO gubbings - so to describe it as 'not fully object orientated' is misleading I think. If you mean you can take a procedural approach with out being restricted to objects then yes, but if you wanted everything to be an object then that's your choice.

DDD是否适用于PHP?是的当然.一种特定的体系结构方法通常不依赖于技术.最佳实践,OO设计的优缺点适用于大多数语言-PHP使您可以自由决定如何构造代码.

Is DDD feasible for PHP? Yes, of course. A particular approach to architecture is not usually dependent on technology. Best practices, pros/cons of OO design apply to most languages - PHP leaves you pretty free to decide how to structure your code.

您可能会发现来自PHP网站的最佳做法很有用;)

You may find this Best Practices talk from the PHP site useful ;)

这篇关于PHP应用程序的面向对象设计的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆