Home > Archive > Smalltalk > March 2005 > Null objects and DeafObject
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Null objects and DeafObject
|
|
| Fernando 2005-03-13, 3:59 pm |
| Hi,
Assume I have an instance variable that will contain a Book object.
I'd like to initialize it to some sort of null Book. A book whose
methods are all NOPs.
Should I create a subclass for this purpose or is this what DeafObject
is for?
Thanks
| |
| Can Altinbay 2005-03-13, 3:59 pm |
| "Fernando" <frr@easyjob.net> wrote in message
news:mfm831pcpbgmqmnctuml8f6g5rrjanlvhr@
4ax.com...
> Hi,
>
> Assume I have an instance variable that will contain a Book object.
> I'd like to initialize it to some sort of null Book. A book whose
> methods are all NOPs.
>
> Should I create a subclass for this purpose or is this what DeafObject
> is for?
>
> Thanks
The first step IMHO is to ask why you want to do this. Step back and ask
why you want to approach it that way.
You may already have done that, but we don't know that. My purpose in
asking is that we need to solve the problem, not come up with ways to do a
particular task. If your approach is in fact a good one, we can deal with
it at that level.
| |
| Reinout Heeck 2005-03-13, 3:59 pm |
| Fernando wrote:
>
> Assume I have an instance variable that will contain a Book object.
> I'd like to initialize it to some sort of null Book. A book whose
> methods are all NOPs.
>
> Should I create a subclass for this purpose or is this what DeafObject
> is for?
Yes and yes :-)
I guess it depends on your preference and on which phase your project is in.
DeafObject is nice to do exploratory programming without having to write any
scaffolding. My preference is to refactor to using a specialized class when
the code has to go beyond being of exploratory quality.
HTH,
Reinout
-------
|
|
|
|
|