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– OldCastle09/24/2017 08:30:55Commented Sep 24, 2017 at 8:30
-
education advice is off-topic per help centergnat– gnat09/24/2017 10:55:59Commented Sep 24, 2017 at 10:55
-
1Classes and objects are OOP concepts. How can you teach OOP concepts without teaching OOP concepts?Bryan Oakley– Bryan Oakley09/24/2017 12:10:25Commented Sep 24, 2017 at 12:10
-
1So 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– Richard Chambers09/24/2017 12:43:07Commented Sep 24, 2017 at 12:43
-
2Some 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– Frank Hileman09/24/2017 17:19:44Commented Sep 24, 2017 at 17:19
1 Answer 1
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.
Explore related questions
See similar questions with these tags.