[SPAM] [squeak-dev] code formatting

Sven Van Caekenberghe sven at beta9.be
Mon Jun 28 07:30:36 UTC 2010


On 27 Jun 2010, at 22:59, Rob Withers wrote:

> case A:
> SocketEndpointBottom>>#send: data
> 	self isConnected
> 		ifTrue: [[self socket sendSomeData: data]
> 			on: Error
> 			do: [:ex |
> 				self socket notNil
> 					ifTrue: [self socket closeAndDestroy].
> 				SSLSendError signal: ex messageText]]
> 		ifFalse: [self socket notNil
> 			ifTrue: [self socket closeAndDestroy]]

I like A the best, its the most compact and still sematically structured.
Personally I add extra space inbetween square brackets, like this:

case A:
SocketEndpointBottom>>#send: data
	self isConnected
		ifTrue: [ [ self socket sendSomeData: data ]
			on: Error
			do: [ :ex |
				self socket notNil
					ifTrue: [ self socket closeAndDestroy ].
				SSLSendError signal: ex messageText ] ]
		ifFalse: [ self socket notNil
			ifTrue: [ self socket closeAndDestroy ] ]

It gives the code a bit more 'breathing room'.
I picked this up from exiting code, I see it a lot in the Seaside code base.

Sven





More information about the Squeak-dev mailing list