以程序方式编写一个相当大的,以数据库为中心的PHP应用程序而没有MVC是否合理?
Sorry for the rather subjective question, but I was hoping to get an opinion from someone more experienced than myself on this.
I'm pretty far into an ajax-driven PHP application and, while I have pretty good separation between markup and behavior on the client side, my PHP is slowly becoming a bit of a mess. I'm doing alright so far breaking it up into parts and structuring in a way that I don't have too much repetition, but I'm definitely beginning to see how this can become a burden with enough code. So I've been reading about OOP and MVC and now I'm trying to decide whether it's worth refactoring for CodeIgniter or Kohana. Intuitively, it feels like this would be more work than it's worth, but I know I may be singing a different tune in a little while.
In your experience, is it considered absolutely hackish to write a serious application procedurally today, or are there certain kinds of applications that lend themselves better to procedural/structural programming.
对于这个相当主观的问题感到抱歉,但我希望得到一个比我更有经验的人的意见。 p>
我已经非常接近ajax驱动的PHP应用程序了,虽然我在客户端的标记和行为之间有很好的分离,但我的PHP慢慢变得有点混乱 。 到目前为止,我做得很好,分成几部分,并以一种我没有太多重复的方式构建,但我肯定会开始看到它如何成为一个足够代码的负担。 所以我一直在阅读有关OOP和MVC的内容,现在我正在尝试决定是否值得重构CodeIgniter或Kohana。 直观地说,感觉这将是更多的工作而不是它的价值,但我知道我可能会在一段时间内唱出不同的曲调。 p>
根据您的经验,它是否被视为绝对的hackish 今天在程序上写一个严肃的应用程序,或者是否有某些类型的应用程序更适合程序/结构编程。 p> div>
MVC and OOP are just "ways", amongst others. Yes, they are great, facilitate good struturation of code, and are used a lot, but they are not the only way you can develop an application.
For instance, Drupal is not using any kind of Object-Oriented code : it's all procedural... And it's a big application, that has lots of success, is used by many people, even on big sites, and for which many people have developped lots of modules... even if it almost doesn't use any class/object !
I, personnaly, would go with MVC and/or OOP for almost any kind of new application ; just because I know those and they are helpful -- but those are not required when it comes to developping a great application : they help, but you can still have some crappy code if you don't behave when programming ^^
I can't remember the last time I've seen any large, serious application that was entirely in one paradigm of programming, even OOP. (That is, if "object-oriented" was a single uniform thing.)
I wouldn't worry in the least if a program didn't use OOP, but I would be a bit concerned if it only used one paradigm. (I'd probably be more suspicious if it didn't use functional programming at all.) No large task is entirely homogeneous, so if you're trying to use one paradigm for an entire program, it's probably a great fit in some areas and a poor fit in others.