0

I've been teaching Python to someone that was new to programming; and so far, so good. Now, I'm about to teach Classes and Objects. However, I still think it's too soon for the whole OOP concept, plus we don't have much time left. My idea is to give her some basic, but useful introduction on Classes and Objects without including a full list of abstract OOP concepts. One example that come to mind is to use a Class as a wrapper for related methods. So, my question is how do I explain Classes and Objects without touching other OOP concepts?

Note: Sorry if my wording is confuse. What I mean is if can I avoid get into the encapsulation, abstraction, polymorphism and inheritance paradigms? But still make use of Classes?

  • A comment from the downvotes would be helpful. – OldCastle Sep 24 '17 at 8:30
  • education advice is off-topic per help center – gnat Sep 24 '17 at 10:55
  • 1
    Classes and objects are OOP concepts. How can you teach OOP concepts without teaching OOP concepts? – Bryan Oakley Sep 24 '17 at 12:10
  • 1
    So you can teach classes and objects without OOP concepts. A primary concept, encapsulation, does not require OOP concepts yet it dovetails nicely into teaching classes and objects. Abstraction is also not an OOP specific concept. Boith encapsulation and abstraction have been around for before OOP became mainstream. I suggest you also include a discussion of module cohesion and module coupling as well. – Richard Chambers Sep 24 '17 at 12:43
  • 2
    Some concepts you describe were used in other fields before OOP. Abstraction is a fundamental component of human language, and more formal ideas about abstraction can be explained without reference to programming. Polymophism is not specific to OOP, and can be best explained as how to convert an algorithm to work with multiple data types, by introducing the concept of lookup tables containing function pointers. Inheritance is very specific to OOP, but can also be explained in terms of how to emulate it using composition and method forwarding. – Frank Hileman Sep 24 '17 at 17:19
2

Your wording is a bit strange. (That may also have been the reason for the downvote.) The concept of classes/objects really is an integral part of OOP. So “classes without OOP” just sounds really strange. Perhaps add a clarifying sentence about which parts of OOP you don’t want to touch.

I’ll try to answer anyway. :)

There is nothing wrong with introducing classes as grouping wrappers for a bunch of related attributes and methods. After all, tying together related state and behaviour is one major reason for having classes in a programming language.

You can happily use classes for grouping things without concerning yourself with anything else OOP related. Actually I think that’s not a bad way to approach the whole OOP topic. Huge and massively polymorphic class hierarchies have fallen out of favour for good reasons. And accordingly the focus has shifted to using classes for grouping and hiding of internal data/behaviour – though that might not be that obvious in Python with its everything is public philosophy.

So how do you teach classes/objects without “advanced” OOP concepts? Just leave them out. Maybe hint at them for later. But they’re not necessary for understanding and using classes/objects.

protected by gnat Sep 29 '17 at 11:26

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.