tags:

views:

291

answers:

6

I have a large website that I have time to convert to a nice custom-framework that I can build to my needs. I want to build my own, and not use something like Smarty because I'd like to...

  1. know how all the guts of it work
  2. cut any and all bloat
  3. learn it, just for kicks

But, after building it in different ways, several times...I keep feeling that for the amount of "convenience" it offers, the code becomes increasingly unflexible, attempting to keep track of files becomes triple as hard (especially if you are the lone developer on the project), and there isn't even any real awesome documentation out there.

At this point, I really need convincing...how is this going to change my life, again?

+1  A: 

It is probably most convenient in the sense that it is an accepted pattern, and other people drifting in and out of your project will understand it. The big thing about Design Patterns, the book, was not that the patterns were new, but that they all suddenly had accepted names.

If you are and will be the sole updater, it may be no big deal.

john personna
Give http://www.ics.uci.edu/~redmiles/ics227-SQ04/papers/KrasnerPope88.pdf a read if you want to look at what the MVC architecture began as. It is interesting to note that the collaboration between the model, view(s), and controller have changed significantly. The one problem with design patterns is that there are many variations on any one of them that are quite substantial in practice.
D.Shawley
Great link, DS.
john personna
thanks, that is a great link indeed.
johnnietheblack
+4  A: 

It can be difficult (sometimes impossible) To convert an existing project to some new pattern/framework. It also depends on how you are implementing an MVC framework.

  • You say that keeping track of files is hard. While you may end up with more files, they shouldn't be hard to keep track of if you have a good organization and naming system, i.e. keeping models, views, and controllers in 3 separate folders, or have some kind of naming convention that tells you what is what
  • I also don't understand why you see the code as more 'unflexible'. Having code properly seperated into Models, Views, and Controllers is that it is more modular, and it can prevent code duplication.

The most important thing about having this seperation of concerns is Maintenance. One of the biggest benefits of an MVC framework is that is easier to pick out what code is misbehaving and fix it. The seperation of concers = a seperation of problems & bugs.

GSto
Nice reply, you really capture the easiness that the MVC pattern brings to coding a website in php.
AntonioCS
+7  A: 

This has been answered already, but to put a finer point on it, I think the single attribute that encompasses when to/not MVC is scalability:

  1. MVC allows clear seperation of duties (ie, front-end vs. database coders).
  2. MVC is a pattern that enforces uniform coding habits.
  3. Maintainability is increased as it's easier for a new project member (who understands MVC) to grok the codebase.

If you are the sole owner of the code and don't forsee other people joining anytime soon, then you should not need it.

r00fus
A: 

The greatest thing about MVC is that it's really just a concept. How you implement it is up to you as long as you follow the standard of separating duties.

I've written a few different MVC code bases based on what needs to happen in the project. One code base has a service layer to further separate "business logic" from the controller and views. Another one separated CLI controllers from web controllers.

This is just how I look at and use MVC. I suggest finding some credible documents or blog posts online about MVC.

Kyle Terry
+1  A: 

What I love about MVC is that when you come to hand it over to another developer, whether that be a new employee or for long-term support, anyone with a knowledge of MVC can figure out what's going on very quickly.

That's not to say it's the best way of looking at things, but it is a way that most people understand.

Jon Winstanley
+1  A: 

After doing MVC or HMVC there is no way that I could possibly go back to spaghetti coding. It will take a bit of time to switch over a large site depending on how extensive the backend is, but depending on how much maintenance you are doing, it may be worth it.

Can i ask what makes you want to do a custom framework? I mean, I don't doubt anything, it is just that technology advancements keep growing-- I don't highly recommend drupal or cake.. I would recommend something like Kohanaphp.com where it is very lightweight and has a great database connector called ORM (object relational mapping) which is a great usage of MVC. The best part is that you won't have to fully maintain your framework as it is opensource and has an active community. Although, being a programmer myself, I do understand how we grow attached to our code and want it our way :D But this saves time by already offering tools for request handers, xss filtering, routing and bootstrap configurations, etc.

Just a thought :D

Jon
haha, jon...i completely see the light in using an open source framework, etc. you basically just nailed it...i get my kicks in by tinkering around and finding my own way to do stuff (even if it is merely reinventing the wheel). I also do think that the more my hands are involved, the more in control i will be/feel in the end. in this case, a lot is riding on me, and I want to know whats going on.
johnnietheblack