A Handful of Code

In my last post about page controllers, Jason Holden asked on which pages I use page controllers. This is a great question and speaks to a larger issue of code organization that applies to CSS and JavaScript as well.

[More]

Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
I've been using your PageController ideas since your last post. I really like how clean it makes my view page, but it seems like readability/manageability is the major advantage. I haven't found an instance where code in my controller would have broken encapsulation if it were placed directly into my view page. What do you think?
# Posted By Jason Holden | 4/13/08 6:48 PM
Jason,

I think most of the things that you could put in a view but might go in a page controller rightly belong in the controller rather than the view (as JavaScript belongs in a .js file and CSS belongs in a .css file).

I don't think I would exactly call that an encapsulation issue though, perhaps more of an issue of separation of concerns.

The only reason I mentioned encapsulation is that I don't think the "Handful of code" rule should be used to justify breaking encapsulation. For example, I don't think it should be used to justify using shared-scope variables in a model component.
# Posted By Steve Bryant | 4/14/08 2:21 PM
BlogCFC was created by Raymond Camden. This blog is running version 5.8.001.