Object-Oriented Python
Written by Mike James   

Author: Irv Kalb
Publisher: No Starch Press
Date: January 2022
Pages: 416
ISBN: 978-1718502062
Print: 1718502060
Kindle: ‎ B0957SHYQL
Audience: Python developers
Rating: 3
Reviewer: Mike James
Python, Object-Oriented? Not a lot of programmers know that!

It is true that you can sit down and start to program using Python as if it was a scripting language with no thought of objects or orientation. This is a shame, but the phase soon passes. In most cases you cannot avoid learning about Python objects for the simple reason you have to use them before you get very far. This is an intermediate, but very very common, stage of development. Most programmers are consumers of objects rather than the creators of objects. In this blissful state a programmer can mostly avoid all of the fairly difficult and often controversial ideas of object-oriented programming. If you are not building a big hierarchically structured library of objects why should you care about inheritance and all of the wonderful principles of hierarchical type?

Put simply most programmers can just get on with using objects and leave the theory to others.

Banner

This book is about object-oriented Python and as such it has declared that it is going to do objects in a Pythonic way - but it doesn't. What it does is to present the standard object-oriented material with lots of Python examples. Its subtitle is "Master OOP by Building Games and GUIs and to be honest this is probably a better reason for reading it then learning about objects. Graphics is one area where objects are so obvious - shapes, sprites and so on - that you would invent the basics of objects if they werent' available. 

The first part of the book introduces objects and it does so via a card game and a bank simulation example. This is a reasonable way to start, but it then makes a big deal out of the idea of using a class to create instances and misses that fact that a class is an object too. In Python a class isn't an abstract entity that is used to create objects; it is an object in its own right. Understanding the relationship between the objects that a class creates and the class object itself is important, as it is the way functions, which are also objects, become bound methods. This is something a Python programmer needs to understand to avoid subtle errors. None of this is explained; instead we have a treatment of Python as if it was Java or any object-oriented language.  This isn't about Python object-oriented programming, but rather object-oriented programming that happens to use Python for its examples.

Part II of the book is about graphical user interfaces with Pygame. This is a set of examples that do illustrate object oriented-programming, but could just as well be said to illustrate event driven or asynchronous programming. It does make good sense to create graphics entities as objects - a ball for example as at the very basic level it allows you to create multiple instances complete with animation.

Part III is about object-orientation pure and simple. It covers the usual subject matter - encapsulation, polymorphism and inheritance. This is a very thin explanation from the point of view of theory and it uses the very familiar example of geometric objects -  square, rectangle, triangle, etc. This standard example contains one of the problems with the idea that program object hierarchies should mirror world object hierarchies, yet it goes uncommented. Is a square a subclass of a rectangle or vice versa. The problem is ignored because the proposed hierarchy isn't deep, so not really modelling anything much. There is no discussion of the meaning or role of type hierarchies and multiple inheritance is mentioned without any discussion of the diamond problem and how Python avoids it using the mro. The Liskov substitution principle is also noticeable by its absence. This is a very standard, very lightweight, and mostly non-Pythonic, examination of object-orientation.

The final part of the book is about OOP in game development and having covered the implementation of a card game, goes on to animation, state machine animation and MVC design. I can't say that I think that MVC fits in with game design, but I could be wrong.

Verdict

This is a book more about graphics and game programming that about object-oriented ideas. If you are interested in this area then you might get something out of this book. If you want to really understand objects and the philosophies behind programming with them then you might not be so happy. You will learn the basics but you won't discover the unique and powerful approach to the problem that Python brings to the table. 

  •  Mike James is the author of  Programmer's Python: Something Completely Different series of books.Currently a three-volume set, the first title, Programmer's Python: Everything is an Object, looks at what makes Python's approach to objects different from that of Java and other OO languages, 

To keep up with our coverage of books for programmers, follow @bookwatchiprog on Twitter or subscribe to I Programmer's Books RSS feed for each day's new addition to Book Watch and for new reviews.

Banner


Learn Quantum Computing with Python and Q#

Author: Dr. Sarah Kaiser and Dr. Chris Granade
Publisher: Manning
Date: June 2021
Pages: 384
ISBN: 978-1617296130
Print: 1617296139
Kindle: B098BNK1T9
Audience: Developers interested in quantum computing
Rating: 4.5
Reviewer: Mike James
Quantum - it's the future...



HTML, CSS & JavaScript (In Easy Steps)

Author: Mike McGrath
Publisher: In Easy Steps
Date: July 2020
Pages: 480
ISBN: 978-1840788785
Print: 184078878X
Kindle: B08FBGXGF1
Audience: would-be web developers
Rating: 5
Reviewer Mike James
The three core web technologies in a single book.


More Reviews

<ASIN:B0CK3X93KF>

<ASIN:1871962749>

<ASIN:1871962595>

<ASIN:1871962765>

Last Updated ( Wednesday, 22 November 2023 )