--- Begin Message ---
Hello,

I have it now working but as you said there is a lot of code smells and my exact question is how to get rid of them.

solution
     | computer |
     computer := self new.
     computer readRam: computer masses.
     computer patchRam: 1 value: 12.
     computer patchRam: 2 value: 2.
     computer processData: computer ram.
     computer at: 0


this is now a class method but I need a lot the computer variable.


here you can find the whole code under intComputer class.






Op 31-12-2019 om 19:29 schreef Sean P. DeNigris:
Pharo Smalltalk Users mailing list wrote
when I call on the class side the method which
should reed the masses which are on the instanc side , the masses
cannnot be found.
IntComputer class >> solution
        | computer ram |
        computer := self new.
        computer readRam: masses.
        ...

In your code above, you are not actually "calling a class-side method"
(which BTW in Smalltalk the term is "sending a message", an important
philosophical distinction if you want to grok Smalltalk), but referring to a
class-side instance variable named "masses". The clue to this would have
been that when you tried to compile the method, a dialog came up telling you
about the undeclared variable. You seem to have clicked through choosing to
create a variable, which you can now see in the class-side class definition:
     IntComputer class
        instanceVariableNames: 'masses'

Probably you forgot to add "computer" before "masses", like so: `computer
readRam: computer masses.`

For future exploration, there are some design smells in your code, but it
seems like you're currently at the "get it to work" stage, so it seems
premature to dive into them here.

NB: It will be much easier to help you in the future, if you include both of
the following in your questions:
1. the exact error
2. "steps to reproduce"

IOW in this case, something like: "I'm seeing '#splitOn: was sent to nil'
from IntComputer class>>#readRam:. To reproduce, do `IntComputer solution`"

This way we don't have to go hunting for an entry point, which will stop
many (busy) people from even trying!



-----
Cheers,
Sean
--
Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html





--- End Message ---

Reply via email to