[squeak-dev] code formatting
Rob Withers
reefedjib at yahoo.com
Sun Jun 27 20:59:20 UTC 2010
I found some code changes made to code I wrote several years ago. I am
thrilled someone has been working with it. However, some of the changes
were cosmetic and I wondered what people thought was better formatting: A or
B, C or D.
SocketEndpointBottom>>#send:
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]]
OR
case B:
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]
]
SocketEndpointBottom>>#getData
case C:
SocketEndpointBottom>>#getData
| buf count |
Processor yield.
buf := ByteArray new: 18432.
[self socket dataAvailable
ifTrue:
[[count := self socket receiveDataInto: buf.
^buf copyFrom: 1 to: count]
on: Error
do: [:ex | ^ nil]]
ifFalse:
[[self socket waitForDataFor: 10] on: Error do: [:e | ]].
self isConnected]
whileTrue.
^nil
OR
case D:
SocketEndpointBottom>>#getData
| buf count |
Processor yield.
buf := ByteArray new: 18432.
[
self socket dataAvailable
ifTrue: [
[
count := self socket receiveDataInto: buf.
^buf copyFrom: 1 to: count
]
on: Error
do: [:ex |
^ nil
]
]
ifFalse: [
[self socket waitForDataFor: 10]
on: Error
do: [:e | ]
].
self isConnected
]
whileTrue.
^nil
More information about the Squeak-dev
mailing list
|