Hi Xavier, I agree that it boils down to personal preference. For me, switching contexts "horizontally" (via tabs) is easier than switching contexts "vertically" (by using bookmarks to jump up/down a single file). To convey that the subfiles are closely related together, I would put them in a single directory named after the parent class.
Thanks for providing us some insight about the Rails code. Much appreciated. George On Saturday, September 19, 2015 at 3:20:09 AM UTC+8, Xavier Noria wrote: > > I'll share my point of view. > > In general, in programming I don't think there are many rules that apply > in every single scenario. Programming is not an axiomatic system. > > In this case, one class/module == one file may be a good guideline > sometimes (app/models), maybe not so much in other cases. It depends, and > in addition it depends on personal preferences, so maybe you would organize > the code in a different way and that would be fine. > > In a large codebase like Rails, sometimes you organize the code in > higher-level units. Why? Because splitting every single class/module into > their own file, while may give you uniformity with regards to that a > priori rule, comes at the cost of loosing context when understanding that > unit of code. > > When you open that file as a reader, the message is: here's a cluster of > classes or modules together concerned with this high level functionality. > If you sit down and go through this file you'll understand a piece of > something. Otherwise you'd need to open 7 tabs, switch context, and nothing > would convey they are closely related as the single file approach (except > your inference, perhaps). > > -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/rubyonrails-core. For more options, visit https://groups.google.com/d/optout.
