Squeak coding style...

Jack Keel jhkeel at facstaff.wisc.edu
Sun Feb 29 00:01:34 UTC 2004


And of course #7 (probably number 1):
7. Don't invent a new pattern or selector sequence when an old one 
(that everyone else expects) already exists:
  asSilly: aString

	"Take the String argument and sillyfy it"
	^ aString, ' is silly'.

see String category converting, e.g..   String>>romanNumber instead of 
asRomanNumber

and while you implied it you didn't state it explicitly #8 (probably 
number 2):

8. The argument name or the comment must specify all the valid classes 
(or protocols) that are valid for the argument.
There is nothing more annoying than trying to look for all messages 
passed to a references to the value passed into a method trying to 
figure out what is valid to pass into the method (i.e., can the 
argument be a list, an array or a single object, multiple objects and 
what can those objects be?  If you can't tell the class of the argument 
object  by looking at the method you want to call -- it is a bitch!)

  asSilly: aThingWhichIKnowandYouNeedToDiscoverToMakeSilly

	"Take the argument and sillyfy it"
	^ aThingWhichIKnowandYouNeedToDiscoverToMakeSilly, ' is silly'.

Which for everyone but the original author yields:

whateverYouThoughtWasValid doesNotUnderstand:,

arrrrrghhh!

Jack



> From: goran.krampe at bluefish.se
> Date: February 28, 2004 6:52:51 AM CST
> To: squeak-dev at lists.squeakfoundation.org
> Subject: Squeak coding style...
> Reply-To: The general-purpose Squeak developers list 
> <squeak-dev at lists.squeakfoundation.org>
>
>
> Hi all!
>
> I have been BFAVing quite a bit the latest week and one thing that has
> annoyed me a bit :) is our lack of consistency in coding style. Sure, 
> it
> is not a BIG THING - but at the same time a consistent style improves
> the impression.
>
> Now - we all have different preferences here, but let me show you a
> hypothetical example:
>
> sillyFy: string
> "take the argument and sillyfy it"
> ^ string, ' is silly'.
>
>
> Ok, there are 6 things here that annoys me. :) Note though that I write
> this with toungue in cheek! Some of these things are plain silly but I
> confess - they still bug me. :) Here goes:
>
> 1. The comment starts with lower case and has no period. Just looks
> sloppy IMHO. This one is actually one that I think we could agree on.
> Right?
>
> 2. There is no empty line between the code and the comment. I like an
> empty line there so that I can easily see where the code starts. If
> there is no comment at all then I usually still have an empty line 
> below
> the signature before the code. Also hopefully a style convention we
> could try to follow perhaps.
>
> 3. The code should be indented. Agree? :)
>
> 4. There is a space after ^. Sure, people do it differently. :)
>
> 5. The naming of the parameter "string" is not really in my taste. I
> would have liked "aString" better.
>
> 6. There is a period after the last statement. Not needed.
>
>
> Anyway, the above was just to spark the thread. I know this topic is of
> very low importance though so.... well. :)
>
> regards, Göran
>
> PS. Perhaps we could write a "styleifier"? Some of these things are 
> both
> easily detected and corrected.




More information about the Squeak-dev mailing list