Mark Drew (Redux)- cf_etc...

a compendium of railo, cfml, cfeclipse and technology topics

Mark Drew (Redux)- cf_etc...

Model Glue Tips Part 3: Keep your views tidy

August 12, 2007 · 5 Comments

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!

Tags: model-glue

5 responses so far ↓

  • 1 Doug Boude // Sep 22, 2008 at 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.
  • 2 Bob C // Sep 22, 2008 at 4:13 PM

    So far all of these tips are also good ideas when working with Mach-ii....
  • 3 Mark Drew // Sep 22, 2008 at 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.
  • 4 Jatin Nanda // Sep 22, 2008 at 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
  • 5 Mark Drew // Sep 22, 2008 at 4:13 PM

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

Leave a Comment