[SqNOS] Another aesthetic question

Frank Shearar frank.shearar at angband.za.org
Thu Jul 13 14:03:57 UTC 2006


"Gerardo Richarte" <gera at corest.com> asks:

> The device I'm working on, as well as other devices, have bits which can
> be set, cleared and tested. For this we need three different methods
> (could be two). The question is on how to name them:
>
> opt. 1:
>     isOwnedByHost    (test)
>     beOwnedByHost   (set)
>     beOwnedByCard   (clear)
>
> opt. 2:
>     ownedByHost (test)
>     etc.
>
> opt. 3:
>     isEndOfPacket   (test)
>     beEndOfPacket   (set)
>     dontBeEndOfPacket   (clear)
>
> opt. 4:
>     isEndOfPacket   (test)
>     endOfPacketSet
>     endOfPacketClear
>
>     or any mix, or anything else. Right now I have a mixture, like opt1
> and opt4. I'm not sure if this is the best thing to do (mix the flavors)
> or stick to a more strict naming convention and leave the English
> semantic aside. Remember English is not my native tongue, so I may as
> well misjudge what's sounds better.
>
>      Uses of this would be, for example
>
>     receiveRing isOwnedByHost ifTrue: [queue add: (EthernetPacket bytes:
> receiveRing message)]
>
>     transmitRing beEndOfPacket.
>     transmitRing dontBeEndOfPacket
>
>     or
>
>     transmitRing endOfPacketSet
>     transmitRing endOfPacketClear
>
>     thoughts?
>     thanks!
>     gera.

I like, as you do, #isFoo (#isEndOfPacket) for the test method.

For setting/unsetting, typically I (in Delphi, admittedly) have a property
to which I assign a value. Translated into Smalltalk, that gives
#isEndOfPacket: aBoolean. An alternative might be
#setEndOfPacket/#unsetEndOfPacket.

I had a stroll around Squeak 3.8, and HaloMorph for instance has a
#isMagicHalo/#isMagicHalo: aBoolean pair. Several other classes use that
pattern, so ja, I'd vote for

isEndOfPacket (test)
isEndOfPacket: true (set)
isEndOfPacket: false (clear)

frank



More information about the SqueakNOS mailing list