Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

You can't ever have the perfect classes, I guess...

by cbraga (Pilgrim)
on Sep 27, 2003 at 05:16 UTC ( #294608=note: print w/replies, xml ) Need Help??


in reply to Inheriting Tests and Other Test Design Issues

You write: The problem arises when the super class number formatter is changed to have the comma every four digits, but the subclasses don't have tests for this and thus we're altering subclass behavior without testing it.

Well, I may be wrong, but it is my understanding that the subclasses trust the superclasses with respect to behaviour the subclasses don't define themselves. That is good, since the comma may have changed to four digits because the new protocol specification says so, and then all subclasses will have that changed automatically. I think that's a basic assumption of OO design.

That is also bad because the superclasses are responsible for all their subclasses' good behaviour, and the programmer must, when changing how the superclass works, keep in mind all the subclasses he may be breaking.

As projects grow large, that is both a blessing and a curse. The cure, well, is to keep strict documentation of what each class is supposed to do, and how. Which is also a pain in its own right.

My take on the question at hand is that tests should be subclassed so that the inherited behaviour of the superclass will be preserved on the test. That's how OO works, IMO. If the subclass isn't supposed to change in behaviour when its superclass changes, then it's got no business in being inherited on the first place.

  • Comment on You can't ever have the perfect classes, I guess...

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://294608]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (8)
As of 2020-04-01 08:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    To "Disagree to disagree" means to:









    Results (186 votes). Check out past polls.

    Notices?