From: Jamis Buck Date: 2004-11-14T09:05:37+09:00 Subject: Re: ruby sections? itsme213 wrote: > I'm curious what the experts on this list might think of this. > > My code falls into chunks. Some of those chunks correspond to methods, > classes, or modules. Many do not. For the ones that do not, I do something > like this (literally, or in my head) [snip] Hmmm. This is just me, but when I find myself with a method that can be logically broken down into different functional parts, I typically refactor the method, so that each of those parts is another method. In other words: def foo # bar stuff ... # baz stuff ... end Becomes: def foo bar baz end def bar ... end def baz ... end And if I find that I have methods that should be grouped in clusters, I typically refactor _those_ into new classes, so: class A # foo things ... # bar things ... # baz things ... end becomes: class A attr_reader :foo attr_reader :bar attr_reader :baz end class Foo ... end class Bar ... end class Baz ... end AND, if I find that I have classes that need grouping, I refactor them out into new modules...and so forth. This approach works really well with dependency injection, btw. But, as I said, this is just me... - Jamis -- Jamis Buck jgb3@email.byu.edu http://www.jamisbuck.org/jamis