19Jul/090
Design pattern/flow for building a website
So here's how I normally do things:
- Do as much of the models as possible in this first pass, skipping validation but including schema stuff
- Stick a couple things into the controllers that I think I'll need
- Build out some of the views, giving them some basic styles
- Revisit the models to add validation, helper methods
- Build out the rest of the views, give them real styles
- Muse about specs, then give up before starting
- Put more stuff into the controllers
- Iterate on random components until you're done
Needless to say, I'm getting to the point where my lack of organization kills my mini-projects before I hit step 4, sometimes even sooner than that. So I'm going to try a slightly more...conventional (or widely suggested, at least) approach:
- Create controllers with just enough information so that your pages will display. No setting variables yet or other logic!
- Fill out the views with as much HTML and fake data as you need. Site have a sign-in page? Leave a link to "force sign-in" the user that simply sets them to an authenticated state. All it should do is set a session variable
- Spec out the models. Don't check for validation yet, just check for core functionality, i.e. there is a User table, the first user has a name of Foo and email of [email protected], etc.
- Fill out your model code so that the specs pass -- this includes migrations with sample data (these can be removed in a later migration).
- Spec out your controllers/views.
- Fill out your controllers/views so they pass specs.
- Do the rest of the little things that need doing, like validation, error messaging, authentication, styling, etc.
- Revel in having finished a project.
Hopefully I'll get further than step 3 this way! I'm going to try to focus more on content/frontend instead of getting bogged down in the backend, and I want to actually write specs.
Any comments/suggestions?