I'm trying to clean up Rriki. Yes, this is procrastination and I should do my research, but clean code looks soooo nice !
Any way, I'm trying to program the rails way (some mumbo jumbo about MVC and DRY). For Rriki's 'sources' (storage for research articles, books etc.) I have a certain amount of processing that I have to do - I export the table data to BibTeX so I can use it with LaTeX, I import publication data from pubmed, and I write to auxiliary databases such as for bibus.
Currently code for this is placed in the model, in the controller and in sources_helper. But I have learned that this is not the true way. The proper coding etiquette is as follows
Any way, I'm trying to program the rails way (some mumbo jumbo about MVC and DRY). For Rriki's 'sources' (storage for research articles, books etc.) I have a certain amount of processing that I have to do - I export the table data to BibTeX so I can use it with LaTeX, I import publication data from pubmed, and I write to auxiliary databases such as for bibus.
Currently code for this is placed in the model, in the controller and in sources_helper. But I have learned that this is not the true way. The proper coding etiquette is as follows
- Thin controllers : put as much of your logic in the model as possible and keep the controller slim and trim. Ideally, you should be able to glance at a controller method and figure out what information it grabs. [Jamis Buck]
- Fat models : Most of the logic will be about fetching, manipulating and parsing model data. So this IS the model's business.
- Use layouts : its a bit like css for rhtml
- Slim views : resist the temptation to write ruby code in rhtml - use a helper
- Fat helpers : move involved view code from views and controllers into helpers
Comments
Post a Comment