I have a project that is currently all over the place and i'm thinking of making it MVC.
The problem is that the system is currently being used and I can not change the interface (It's in frames :s) Also there are certain things that I will need to handle myself such as password generation, login and user levels.
I already have the model side down of the MVC so I am wondering is it worth using a framework like Zend Framework or CakePHP or just to code my own View and Controllers to work around this problem?
I am going to have to work this in slowly and I'm not sure if i will be able to do that if I use one of the ready made frameworks.
When we're programming and we just need to do simple stuff, it is better to just write our own code from scratch and/or get some libraries to help us with that. But when we need to tackle many big projects, it is better to use a framework, because the project is big and frameworks can save us time.
The MVC pattern helps you break up the frontend and backend code into separate components. This way, it's much easier to manage and make changes to either side without them interfering with each other.
No, not at all. It's used widely in many web frameworks like e.g. Spring MVC, and it can be applied to many programming languages in web development context.
Do you know you can build your own framework, with no dependencies, compatible with all browser since IE8+ in less than 350 lines of code? Using vanilla Javascript, no third party code, without compilers, transpilers, npm, webpack, ... Just your code!
I wrote my own MVC framework for Coldfusion because the current "flavour of the month" Mach-II was horrendously slow. After switching my page generation time dropped from 2-5 seconds down to 9 milliseconds.
Over the last 3 years I've developed this framework into a rival for any commercial or open-source framework I've used (and I've used quite a few) by building in function libraries and components for a range of common tasks (CMS, CC processing, Image manipulation, etc..)
Although there was no doubt some "re-inventing the wheel" the wheel I ended up with was exactly what I need to do my job. I understand how it works with an intimacy that no documentation could ever provide.
Of course, one day some future programmer may be cursing over my code wishing a pox on me for not using their favorite library - but frankly - I just couldn't care less. I wrote it for ME, it does what I need and it does it well. I also learned a lot in the process.
Having said that you are NOT automatically doing your customers/co-workers a disservice by writing your own framework. Public frameworks tend to have no real direction so they tend to bloat massively trying to keep everyone happy. This bloat means more to learn, more that can go wrong. Your framework will be meeting a much smaller set of requirements and with good documentation could be a lot easier to understand and setup than a more established public one.
I say go for it, live on the edge a little. Maybe in 5 years you'll release the next "Mach-II" or whatever and we can all bitch about it.
Normally I would recoil in horror and advise against bringing yet another web MVC framework into the world, but it's fair to note that our hosts Joel and Jeff have another opinion on the matter:
From Joel: In Defense of Reinventing the Wheel From Jeff: Don't Reinvent the Wheel
One last thought: If it's a one-person project, then you only affect yourself with this choice. My resistance would spike up if a team developing a long-lived product was involved. You may do a disservice to the team and the customer if you roll your own.
You will find CakePHP in particular to be quite "invasive". IMHO for this you should use a lightweight framework or write your own. I don't normally advise writing your own for this kind of thing but when you're dealing with software you can't change it can sometimes be the best solution. Also, a controller in PHP is not a hard thing to write so you can sometimes end up unnecessarily overcomplicating the solution if you use a prefab solution that's either too heavyweight or just not a good fit for your current constraints.
For lightweight MVC frameworks I highly recommend CodeIgniter.
Wheel reinvention is bad. Use a tried and tested framework like Zend Framework unless you have a really, really special reason not to.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With