[Tutor] designing POOP

Alan Gauld alan.gauld at btinternet.com
Thu Feb 7 23:17:02 CET 2008

"bhaaluu" <bhaaluu at gmail.com> wrote

> What is the equivalent of JUnit in Python?

I think the nearest equivalent is

> writing my own is probably out the question. Also I'm not familiar 
> with
> Java, and am just learning Python OOP, so I'm not getting much out
> of that one. Sorry. Absolute Beginner here.

Note that Unit testing is orthogonal to OOP.
You can use TDD and unit tests(and should!) when
doing procedural programming just as well.

> Well, most of these were local variables in main() in the procedural
> version of this program. So DataClass() is what I should name such
> a class. I was wondering about that.

While you can use classes that way it leads to a style of
programming called object based rather than object oriented.
It uses objects but the underlying design is still procedural.
Thats why its better to focus on the behaviour of the objects
and add the data attributes needed to support that behaviour.
Remember we communicate with objects by sending them
messages asking them to *do* stuff not to get data out of
them, or at least we should do.
"Objects do it to themselves": The Law of demeter.
Ask What does this object do? What data does it need to
achieve that?

> Castle setup in it's own class because it is an object (using the
> "model as a real-world object" method).

Yes, each object should initialise its own data.
(Albeit maybe based on values passed into the constructor.)


Alan G. 

More information about the Tutor mailing list