Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP: Separating Business logic and Presentational logic, is it worth it? [duplicate]

Possible Duplicate:
Why should I use templating system in PHP?

I was just curious as to how many developers actually do this?

Up to this time I haven't and I was just curious to whether it really helps make things look cleaner and easier to follow. I've heard using template engines like Smarty help out, but I've also heard the opposite. That they just create unnecessary overhead and it's essentially like learning a new language.

Does anyone here have experience with templates? What are your feelings on them? Are the helpful on big projects or just a waste of time?

On a side note: The company I work for doesn't have a designer, there are just two developers working on this project charged with the re-design/upgrade. I also use a bit of AJAX, would this have issues with a template engine?

like image 245
MackDaddy Avatar asked Dec 01 '22 12:12

MackDaddy


1 Answers

Not only does this practice make the code look cleaner, it also has many long term and short term benefits.

You can never go wrong with organizing code. First off it makes it much easier to maintain and easier to read if someone else has to pick up after you. I have worked with Smarty before and it is nice, it keeps the designers work from interfering with the program code.

Using template systems and frameworks would make it much easier to accomplish tasks. There is a rule of thumb you can follow which is DRY (Don't Repeat Yourself). Frameworks help you achieve this goal.

You may want to look into MVC, this is the model that these frameworks are based off of. But you could implement this design structure without necessarily using framework. Avoiding the learning curve. For frameworks like Zend, the learning curve is much greater than some other ones.

I have found that Code Igniter is fairly easy to use and they have some VERY helpful video tutorials on their website.

Best of Luck!!

like image 196
Chris Bier Avatar answered Dec 04 '22 12:12

Chris Bier