00:00 So far, you’ve been learning about inheritance and composition through these little class diagrams that I’ve crafted. While they have served our purpose so far, they’re not an industry standard by any means, and they don’t necessarily convey all the information that we might need.
00:34 In other words, it describes the relationships between different classes and it supports composition and inheritance. By planning a project before we start coding it, we can ensure that we make smart design decisions like utilizing inheritance and composition, where it fits.
00:55 This is not a course in software architecture, but we will use UML diagrams to design a project later on. UML diagrams might contain plus (+) and minus (-) symbols next to each member of a class.
01:24 Everything in Python is basically public, and it’s up to the developer to use the class responsibly. Don’t worry too much about this. For our purposes, we’re just going to mark every member of every class as public with a + symbol. When it comes to UML diagrams in Python specifically, there isn’t really a right or a wrong way of doing things. It’s all about following a convention and then sticking to it.
You may have also seen a datatype associated with attributes and methods, written after a colon (
:). In the case of attributes, this datatype describes the type of the attribute—such as
str (string), or something custom, through composition.
02:22 Expressing inheritance with UML is fairly straightforward. A white arrow points from the derived class to the base class. We can write extends to make it clear that this is an inheritance relationship.
03:01 We can write a little number in the composite class to indicate the number of component instances it should have. We can also write a star (*) to indicate that the composite class can contain a variable number of component instances.
Become a Member to join the conversation.