[vwnc] Instantiation of Abstract Class Random

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[vwnc] Instantiation of Abstract Class Random

Runar Jordahl
Open a base 7.6 image and browse references to class Random. At least
three places "Random new" is performed. This is incorrect (design) as
Random is an abstract class. See message #nextValue which defines a
subclass responsibility.

The instantiation does not lead to any problems, but the fact that the
class is marked as abstract (by sending #subclassResponsibility) means
cleanup is necessary. I suggest FastRandom is used instead, or that
#nextValue sends #shouldNotImplement instead of
#subclassResponsibility .

Runar Jordahl
_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: [vwnc] Instantiation of Abstract Class Random

Andreas Tönne
Runar,

the implementation and usage is correct!

Random new is a factory method, calling ^self defaultGeneratorClass new

Being abstract does not rule out class side methods that delegate to
appropriate subclasses. At no time, Random instances are created.

Andreas


Am 24.07.2008 9:58 Uhr schrieb "Runar Jordahl" unter
<[hidden email]>:

> Open a base 7.6 image and browse references to class Random. At least
> three places "Random new" is performed. This is incorrect (design) as
> Random is an abstract class. See message #nextValue which defines a
> subclass responsibility.
>
> The instantiation does not lead to any problems, but the fact that the
> class is marked as abstract (by sending #subclassResponsibility) means
> cleanup is necessary. I suggest FastRandom is used instead, or that
> #nextValue sends #shouldNotImplement instead of
> #subclassResponsibility .
>
> Runar Jordahl
> _______________________________________________
> vwnc mailing list
> [hidden email]
> http://lists.cs.uiuc.edu/mailman/listinfo/vwnc

--
Andreas Tönne
Lead Consultant
Cincom Systems GmbH & Co. oHG
Tel.: +49 6196 9003 100
Mobile: +49 172 6159272
Fax: +49 6196 9003 270



Geschäftsführer/Managing Directors: Thomas M. Nies, Gerald L. Shawhan
oHG mit Sitz/based in Schwalbach/Ts. (Amtsgericht Königstein/Ts. HRA 2653)
Pers. haftender Gesellschafter/Partner liable to unlimited extent:
Cincom Systems Verwaltungsgesellschaft mbH (Amtsgericht Königstein/Ts. HRB
5069)


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: [vwnc] Instantiation of Abstract Class Random

Runar Jordahl
I see and agree.

We have a unit test that traverses our code looking for sends of #new
to classes that are abstract. I guess I need to add Random as an
exception where sending #new is OK.

Runar
_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc