
million saw the apple fall, but only Newton asked why | source:sandramoreano
Objects and Classes
Again, we'll introduce the definition of an object.
an object is a collection of data with associated behaviors
How do we tell two types of objects apart?
Let's pretend we're doing an inventory application for a fruit farm, such that apples go in barrels and oranges go in baskets.
We have four kinds of objects: apple, orange, barrels, and baskets. This four kinds of objects is what is known as the class in object oriented programming. Technically, we now have four classes of objects..
What's the difference between an object and a class?
A class describes an object, more like of a blueprint for creating an object. You may have 5 distinct oranges in front of you but note however that they all have the same attributes and behaviors associated with one class: the general class of oranges.
Unified Modeling Language
One way to visualize the relationship of each objects is by using a Unified Modeling Language class diagram. For our example, we have:

Orange is associated with Basket, while Apple is associated with Barrel.
Association is the most basic way for two classes to be related.
Why use UML?
- Some programmers consider UML a waster of time
- Others find it extremely useful in brainstorming sessions for quick and easy communications
- a reference for "What did I do?" moments in the future
Additional reading:
- Object Oriented Programming
- wikipedia: Object-oriented programming
- Python - Object Oriented
- Object-Oriented Programming in Python
Disclaimer: this is a summary of section 1.2 from the book "Python 3 - Object Oriented Programming: Dusty Phillips", the content apart from rephrasing is identical, most of the equations are from the book and the same examples are treated. All of the equation images were screenshot from generated latex form.


