Stephen Nelson-Smith wrote: > Hello friends, > > Over lunch today some colleagues discussed a question they are using > as a conversation starter in some preliminary chats in our developer > hiring process. > > The question was: > > "Place the following three in order: Inheritance, Polymorphism, > Encapsulation." > > They specifically did not define in *what* order, leaving that for > the answerer to decide. > > I responded thus: > > Encapsulation comes with OO - you get it for free.
Encapsulation does not come with OO. It is something you must code in your classes. > Polymorphism is a > hugely important enabler, but this in itself is enabled by > Inheritance, so I put them in this order: Inheritance, Polymorphism, > Encapsulation. > > My colleagues felt that of the three options this was the least > satisfactory, and showed a lack of understanding of OO design. One > even suggested that one could have polymorphism without inheritance. > IMHO you can have polymorphism without inheritance. Why shouldn't you? It does NOT depend on inheritance I guess you could say it depends on namespaces defined by the classes, but not inheritance. _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor