Gerardo Herzig wrote: > Hi all. I have a question about design. The general question would > be: Where is the line beteween extending a class and adding new > methods to that class?
What do you mean by "extending"? The Java "extends", which is really inheritance? > And the particular case im involved is: > > I have a class (say USERCLASS) who implements a user interface. > One of his methods is called `login'. Later on i got the order of > implementing a `single login', which off course means a single > user cant login if a session is already started for that user. > Extending comes to my mind at first (it works good, actually). But > now im thinikng if there some problem in adding a method to the > USERCLASS class named single_login(), who will take care of > applying the rules of single sign on. > > Which one you guys will pick up? USERCLASS().single_login() or > SINGLELOGINUSERCLASS().login() Depends. Inheritance is, IMHO, only good if it makes code reusal and/or maintainability easier. I've once read that inheritance often only is wise in "is a" relationships, e. g. "car is a vehicle", which means class "car" should inherit from class "vehicle". Regards, Björn -- BOFH excuse #304: routing problems on the neural net -- http://mail.python.org/mailman/listinfo/python-list