On Nov 2, 2008, at 9:27 AM, Mark Volkmann wrote:

I'm reading "Smalltalk Best Practice Patterns". The pattern "Indented Control Flow" recommends putting each keyword on a separated line, indented with a tab. I like that for long messages, but this one example annoys me.

        array
                at: 5
                put: #abc

Earlier the author explains the how conserving vertical space increases readability. This example contradicts that advice. Also, it just seem so verbose compared to the Java equivalent of "array[5] = "abc";".

Do experienced Smalltalkers really like this formatting for short messages like at:put: or is the following preferred?

        array at:5 put: #abc

I normally use the separate-line version, just because I find it easier to follow the same formatting nearly everywhere. I remember someone (Beck?) giving similar reasoning somewhere about using "each" as a loop variable, or "i" as a loop index - nothing to think about, and you can recognize what's going on anywhere at a glance.

I do occasionally "break" this rule, though. For example, to:do: comes to mind - I'll usually write

        1 to: 15 do:
                [:i |
                "..."
                "..."]

instead of

        1
                to: 15
                do:
                        [:i |
                        "..."
                        "..."]

Hope this helps,
Ben Schroeder

_______________________________________________
Beginners mailing list
Beginners@lists.squeakfoundation.org
http://lists.squeakfoundation.org/mailman/listinfo/beginners

Reply via email to