Object Oriented Programming: Objects and Classes

in #programming7 years ago


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:

  1. Object Oriented Programming
  2. wikipedia: Object-oriented programming
  3. Python - Object Oriented
  4. 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.

  1. Python 3 - Object Oriented Programming: Dusty Phillips

Thank you for reading ...


1524729086676.png

Sort:  

Thank you so much for using our service! You were protected from up to 20% losses!

Help us grow by delegating to us! 100sp, 500SP, 1000SP, ANY SP

You just received 4.94% upvote from @onlyprofitbot courtesy of @sinbad989!

Coin Marketplace

STEEM 0.13
TRX 0.34
JST 0.036
BTC 109207.95
ETH 4399.20
USDT 1.00
SBD 0.84