[VM][LEGO] Re: SerialPort cross-platform question...

Lex Spoon lex at cc.gatech.edu
Wed Feb 13 18:00:32 UTC 2002


> If a SerialPort is not useable until its parameters have been set, then the
> SerialPort code needs to be factored thusly:
> 
> add
>   SerialPort class>>baudRate:dataBits:parityType:stopBitsType:
> and maybe even
>   SerialPort class>>openOnBaudRate:dataBits:parityType:stopBitsType:
> and (if you are a real purist) remove
>   SerialPort class>>new
> (ie. throw an exception or do self shouldNotImplement)
> 

The downside is that you no longer get default parameters.  Thus you
either add lots of combinations of the instance creation method, or you
force everyone to use the long version even  when they only care about
one or two options.  Thus the opposite refactoring can make sense as
well: take an instance creation method with bunches of parameters, and
turn them into individual initialization methods.  A more extreme
example of this is HTTPSocket.


I really don't see a big deal with simply disabling settings changes
after the port is open.  XP-ers also get frothy-mouthed about running
your code early and frequently, and thus a run-time notification is just
about as good as a compile-time one.




-Lex



More information about the Squeak-dev mailing list