Everything Joachim Tuchel wrote about this is fine EXCEPT that
this is an Exercism task, where Roelof has to implement an API
that he is given and is not at liberty to do it right.

Thanks to the way that IsbnVerifierTest is structured,
- the IsbnVerifier class has NO use for ANY variables of ANY
  kind: no instance variables, no class variables, and no
  class instance variables.
- the IsbnVerifier class has only ONE method that is called,
  and that is on the INSTANCE side.
That is, it's a simple pure function disguised as an object.

A good design might have an ISBN class, and would put
#isValidISBN10: and #isValidISBN13: on the class side.

But to solve the Exercism exercises, you HAVE to implement
the API that the test class is expecting, not something
better.  If it passes the tests, it is by definition right.
If it doesn't, it is by definition wrong, even if it is a
far better design.  So
 - one class, IsbnVerifier
 - with no variables of any kind
 - with one and only one method, #isValidIsbn,
   on the instance side.

It all gets so much clearer when you realise that the Exercism
tasks are NOT designed to teach Object-Oriented Design.  The
problems have to serve many programming languages, some of
which, like bash and x86 assembly code, are not object-oriented.


On Wed, 2 Sep 2020 at 18:42, jtuc...@objektfabrik.de <
jtuc...@objektfabrik.de> wrote:

> Roelof,
>
> I don't think so.
>
> A Class cannot access instance variables. Why? because a Class doesn't
> know which of its instances to ask for it.
> Ask yourself: who is "self" in a Class method? Is it the Class or is it an
> individual instance of the Class?
>
> (Hint: in a Class, #self is the Class, while in an instance, #self is the
> instance) .
>
>
> "Who" do you want to validate the ISBN number? An individual instance of
> your Class (like Book)? Or is validating an ISBNNumber a Task that is
> independent of an individual item? If it is independent, then why would you
> want to use semething specific in that method?
>
> You need to understand the differences between Class and Instance
> variables. I suggest reading Chapter 4 of "The Art and Science of
> Smalltalk
> <http://stephane.ducasse.free.fr/FreeBooks/Art/artAdded174186187Final.pdf>"
> or better: read the whole book. It's easy to read and sparks quite a few
> A-HA's per hour.
>
>
> HTH
>
> Joachim
>
>
> Am 02.09.20 um 08:18 schrieb Roelof Wobben:
>
> Hello,
>
> I have now a challenge where I have to validate a ISBN number.
>
> Can I do something like this on the class side :
>
> (string isEmpty)
>    ifTrrue: [ ^ false]
>   ifFalse:  [ digits:= something.
>                    controlDigit := something.
>                    self validateISBNNumber]
>
> where on the validateISBNNumber I use the instance variables digits and
> controlDigit to validate the ISBN number on the instance side.
>
> Roelof
>
>
>
>
>
>
>
>
>
> --
> -----------------------------------------------------------------------
> Objektfabrik Joachim Tuchel          mailto:jtuc...@objektfabrik.de 
> <jtuc...@objektfabrik.de>
> Fliederweg 1                         http://www.objektfabrik.de
> D-71640 Ludwigsburg                  http://joachimtuchel.wordpress.com
> Telefon: +49 7141 56 10 86 0         Fax: +49 7141 56 10 86 1
>
>
>
>

Reply via email to