Lamonte Harris wrote:
It works well for me. Its just a snippet i grabed from my class O_o.
The fact that it works doesn't mean it's good practice.
This also works:
a = 1
b = a + 1
c = b + 1
d = c + 1
e = d + 1
but it's much more common (and better practice) to just straight-away say
e = 5
unless you really need all those intermediate values. And still that
wouldn't be the best way to assign them.
Your class isn't designed correctly if your methods don't do anything
but return values.
This is for many reasons: efficiency, maintainability, readability, etc.
etc.
But in general, the Object Oriented paradigm is centered around objects
that are collections of data and methods (related functions) that act on
data. If your classes just take in external data and output data
externally to the class, they're not objects. Then you're just using
classes to group functions which may or may not be related, and no data
involving them.
I was trying to word it in a way that was less critical, but that's the
general meaning I was trying to get across: your class should be
modifying data internally.
It's possible that the rest of your class does, and for some reason or
another you just had to code this method this way, but since I can't see
your code I can only assume.
-Luke