Aug 12 2007

Model Glue Tips Part 3: Keep your views tidy

Posted by Mark Drew at 9:16 AM
5 comments
- Categories: model-glue

When you develop model-glue apps, you start adding your view files in the /views directory, this all fine as a demo or in a small application, but it can get very full of items. An easy way to sort out your views a bit, is to use the same naming convention we used for the event-handlers but to create directories to hold the views named after the controller they relate to, for example:
	/views
		/pages
		/security
		/products
		/layouts
		/nav
	...
I tend to keep views that are used in multiple places (lets say a top nav) in a /nav directory and the layouts in a /layouts directory. Another way to distinguish your view files comes in the way with prefixes for what kind of file they are, so for example listing pages have dsp_, form pages have frm_, pages that output XMl start with xml_ and navigation pages start with nav_. Hopefully following these tips it will be a lot easier for you to find the right view quicker!

Comments

Doug Boude

Doug Boude wrote on 09/22/08 4:13 PM

Dang, Mark, why didn't I think of that? Something so simple yet I'm always so focused on the "meat"of the app that it never occurred to me to take the time to organize my views, and they have indeed gotten out of hand. Excellent tip.
Bob C

Bob C wrote on 09/22/08 4:13 PM

So far all of these tips are also good ideas when working with Mach-ii....
Mark Drew

Mark Drew wrote on 09/22/08 4:13 PM

@doug: Glad they helped!
@bob: indeed, they work with most MVC frameworks, and not just in CF, I also so something similar with Ruby on Rails.
Jatin Nanda

Jatin Nanda wrote on 09/22/08 4:13 PM

Hey Mark, its very refreshing to know that the stuff I've been doing is deemed good practise. So far your first 3 tips are exactly what I started to do a few months ago when I need to start scaling my app. Thank you
Mark Drew

Mark Drew wrote on 09/22/08 4:13 PM

@Jatin: Good to see common-sense is universal! :)

Write your comment



(it will not be displayed)





Search Archives

Contribute


MD on Twitter

Categories

coldfusion cfeclipse personal apple cfconferences ukcfug model-glue webdev blogging cfunited coldspring railo presentations adobe cfobjective scotch on the rocks reactor lost jobs ajax eclipse flex model-glue frameworks max google podcast podcasting reference ask md fusebox getrailo spam cfml donations eventvalidation fusiondebug air blue dragon cloud development flying funny java microsoft music snipex tattoo tips apple aptana blog cfml derby eventguard graphic novels hosting itunes metrics open bluedragon rant wishlist apollo barcamp bolt cebit cfdevcon cfonwheels cfug codeshare codeswarm coldfusioncamp directing doh! firefox flash gadgets groovy jquery mdc mvc ooops pownce quack regex spry subversion tashr transfer webservices xml

Monthly Archives