Tuesday, December 8, 2009

CakePHP oh CakePHP

I've seen alot of people with PHP experience of 2-3 years, when being presented with CakePHP, they say something along the line of "Oh this is hard", "Why is it so different?", "What's this arrow and arrays inside array thingie?", etc.

Lots of young programmers working with PHP that I've seen in Malaysia hardly understand the OO (object oriented) concept. When you look at their codes, it's alot of functions and alot of includes. Classes? Nowhere to be seen. It's probably the most hardest concept to grab while they were in college when actually it's not that hard at all. If you don't understand OO then it's likely you don't know why it's good. And of course the MVC (Model-View-Controller) concept in many programming language frameworks you will find it very very hard to digest. Those frameworks are for RAD (Rapid Application Development) - just look at the name, don't you think it will have something to do with your development speed? It's like you have a bicycle and a car. You know you can get there faster by car, you only have to learn how to use it. It may takes time but for the next 20 years you're going to need the car so you can get anywhere faster. So would you or would you not learn how to use the car?? If you still picks bicycle, that's not a wrong answer. It only shows your preference.

Having MVC, for example, gives you the advantage of having multiple people working on the same page at the same time. A can work on the controller part, B can work on its layout and C can totally change the database engine from MySQL to Postgresql (for example) without having A or B amending their codes at all after that. Also I believe, it's easier to take over an MVC-ed application than a non-MVC ones. I can't imagine having to wade through all those includes/requires/imports. All I need to know is where the models, controllers and views are.

Want to try CakePHP? Just one thing you MUST have - the discipline to put your codes to where it belongs, follow the standards. Don't make your queries in the layouts - it just doesn't make sense. It's likely that you're going to forget about it in a week or two, you're going to curse your way through it when you can't find it later for maintenance work (not to mention the other new programmer working on the same app). Just plan for the future. The time that it takes you to do it properly now will save you a heck of a time later. That includes proper comments in your codes.

The learning curve is a bit steep - yes it is if you don't understand OO. So get to know your OO stuff. And then go for CakePHP, or any framework you fancy. You'll be surprised how much you'll like it.

1 comment:

  1. it is sad when interviewing candidate, only 1 out of 10 have an idea of OOP. some of them have more than 3 years of experience. what gone wrong?

    ReplyDelete