Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

While implementing a flash game portal I decided to "component-ize" my views. The repeating elements were a no brainer and the templates for these were placed in elements. I pass through data from the controller to the element via the view using the Html helper.

This is all working fine, and except for a very minor subset of elements, I haven't had too many issues with complicated logic in the view in order to massage parameters - in other words they have all been completely pass-through and therefore very transparent to the elements.

Here-in lies my problem. I realize I have over 20 elements which far eclipses my paltry 8-10 views and 3 controllers. I've also had the urge to turn almost everything into a "component" and convert it into an element. For example, I have a rating control that is used on only one page - the game play page - and I recently contemplated converting it to an element. I'm wondering if I've gone overboard at this point.

So, in summary, my question boils down to what are the best practices when using the CakePHP Html helper and what makes a chunk of html a candidate for an element (aside from the the obvious of only writing it once). I've read the cakePHP manual and it gives "rough" guidelines but I'm looking for some "field level" or real world experience to guild my decisions.

TIA

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

I think you are right on with taking it down to the micro-level, even with an element that is only used on a single page. It's a great way to keep everything very compartmentalized.

I use CodeIgniter predominantly but have found the same practice to be very beneficial. Imagine that you want to modify your rating control... you just duplicate the element, rename, modify, and reference the new element.

It's just very clean!

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.