2009/10/27 Niko Schwarz <[email protected]>

> The example discussed above would read in code as follows:
>
> EGExample subclass: #ForExampleStack
>        …
>
> shouldBeEmpty
>        "Create the empty stack"
>        | stack |
>        stack := Stack new.
>        stack should be isEmpty.
>        stack size should = 0.
>        ^ stack
>
> shouldPushElement
>        "Push one element"
>        | stack |
>        stack := self given: #shouldBeEmpty.
>

I'd suggest this to be:

       stack := self given: [self shouldBeEmpty].

This way it's easier to follow what happenning, and refactoring can be
applied.


>        stack push: 42.
>        stack should not be isEmpty.
>        stack size should = 1.
>        stack top should = 42.
>        ^ stack
>
-- 
Dennis Schetinin
_______________________________________________
Pharo-project mailing list
[email protected]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project

Reply via email to