I have taught my high school students to write some simple python scripts, taking some ideas from "Automate the Boring Stuff with Python", e.g. changing file names in a folder to a specific naming pattern.
My next goal is to teach them object-oriented concepts and if possible give them some "real" examples to try themselves. But most of the materials I find (most of google's top search results) about OO programming (not just python) are laden with poor examples, if I may say so. I really don't like to use car/vehicle or animal/dog to teach them the OO concept and OOP.
A. it is boring (you know high-school kids)
B. it has no real use.
C. as one comment said "they are fatally flawed." (But if you really like to use the animal example, check this "Object-Oriented Design")
I plan to use pathlib (btw, they already have a basic idea of the difference between Windows and UNIX)
GUI development could be another good example to teach OOP but I don't want to teach them GUI yet.
Any suggestion to introduce OO with the "real" example?
BTW, I’m not a strong advocate of object-oriented programming. But the
pathlib.Path class is a useful abstraction especially compared with os.path, although the high school students are unlikely to appreciate that.
---- update ----
I find the python logging module is another good example, but it seems too complicated for non-experienced programmers.
When using the logging module we mainly use 3 objects, Logger, Handler, Formatter. Logger is the facade, as https://docs.python.org/3/howto/logging.html#loggers said,
Logger objects have a threefold job. First, they expose several methods to application code so that applications can log messages at runtime. Second, logger objects determine which log messages to act upon based upon severity (the default filtering facility) or filter objects. Third, logger objects pass along relevant log messages to all interested log handlers.
Handler is a good example to use inheritance https://docs.python.org/3/howto/logging.html#useful-handlers and handlers use formatters, which hide the complexity of LogRecord, to the format log message.
In addition to these classes, there are a number of module-level functions for convenient use.
Overall it is a good example of using composition and aggregation.
But I am not an expert on the python logging module, I hope someone who is familiar with the python logging module may add an answer to my question.
--- update 2 ----
I found Alan Kay answered the question “What are the five features of the object-oriented paradigm that you consider to be important for good software engineering practice?” with these words, in my opinion, resonate with the answer Buffy gave. But how to convey these ideas to high school students or non-experienced programmers is another challenge,
a “part” construct that can protect it's inside from its outside, and vice versa
a “communications” construct that can convey interactions and deal with dependencies
a “system” construct that is a combination of parts and communications that can fit in a part recursively, and everything is made this way
the “messages” that are communicated are also in terms of the systems
the system that is being made is made with the same kinds of system ...