views:

81

answers:

1

I am using a web framework (Grails, similar to Rails) that has abilities to auto-generate a lot of code through scaffolding. As a result, all of my CRUD pages are currently automatically generated, and I even have ability to inject additional HTML code whenever I want to to further customize the content of those pages.

I can control the scaffolding templates and so can wrap any generated fields in its own DIV, or apply styles whenever needed, all through scaffolding.

So if I have an object with name and password fields, I can have my scaffolding generate something like this for "show" page.

<div id="prop.name">Name</div><div id="prop.name.value">John</div>
<div id="prop.password">Password</div><div id="prop.password.value">***</div>

We are about to embark on putting a more real design onto the scaffolded pages, and I am wondering whether it would make sense to just have the designers come up with a basic layout (header, footer, menu, etc), but for the actual layout of my forms and display pages, have the designer style all my DIVs. This way, I can continue to create my pages through scaffolding, allowing me to easily add fields, etc, but without really having to code too much custom UI.

Obviously, there might be a few places where I'd have to adjust my scaffolding to the designs, but the goal is to reuse my scaffolding templates and style them.

Any thoughts / problems with this approach?

+2  A: 

I don't know about Grails but the Rails generators output horrible HTML. I would never use scaffolding code in a production application. As horrible as it might be, it's useful for what it is intended for, i.e. quick visual confirmation that your CRUD actions are working as intended.

You can of course completely go mad restyling the scaffold views with CSS, you're only limited by your chops and how much of the CSS your browser implements. (Believe it or not Internet Explorer 8 is the only browser to fully implement CSS 2.1!)

I recommend coding views for each project as it is unlikely that the scaffold code is going to be a perfect fit for the problem domain. Of course patterns are going to emerge across projects, but that doesn't mean it's cool to roll with untouched scaffold code!

p.s. Tag and attribute names are supposed to be lowercase! :)

Steve Graham
Thanks for your answer - I actually did a lot of customization to my scaffolding templates to have them generate fairly clean code, and have no problem with customizing them to make even cleaner. Grails (not sure about rails) also allows you to use scaffold dynamically (I.e. your views are generated upon startup) allowing a very agile experience.
Jean Barmash
I agree - customize the scaffolding templates, but use them; they are one of the strong points of Grails.
Karsten Silz