User Tools

Site Tools


programming_general:object-orientation_fundamentals_slides

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
programming_general:object-orientation_fundamentals_slides [2020/09/14 00:27] – created mithatprogramming_general:object-orientation_fundamentals_slides [2021/11/28 19:14] (current) – [Object-oriented languages] mithat
Line 1: Line 1:
 ~~SLIDESHOW~~ ~~SLIDESHOW~~
 ====== Object-Orientation Fundamentals ====== ====== Object-Orientation Fundamentals ======
- +Mithat Konar 
-====== Why object-orientation? =====+===== Why object-orientation? =====
   * **Object-oriented programming** came about to support **object-oriented analysis and design** (OOAD).    * **Object-oriented programming** came about to support **object-oriented analysis and design** (OOAD). 
   * OOAD created to solve issues involved in designing and managing large applications.   * OOAD created to solve issues involved in designing and managing large applications.
  
-====== Procedural/structured programming thinking ====== +===== Procedural thinking ===== 
-  * What needs to happen? +  * Break down large problems into functions or procedures. 
-  * Focus on creating a set of functions to do the things that need to get done.+  * //What needs to happen?//
   * "Verb" oriented.   * "Verb" oriented.
  
-====== Object-thinking ====== +===== Object-oriented thinking ===== 
-  * What are the components (objects) that make up the problem?+  * Break down large problems into the components (objects) that make up the problem.
   * How do they behave?   * How do they behave?
-  * How do the components interact?+  * How do they interact?
   * "Noun" oriented.   * "Noun" oriented.
  
-====== Object-oriented languages ====== +===== Object-oriented languages =====
   * Possible to implement OOAD in any language.   * Possible to implement OOAD in any language.
-  * Much easier and more robust when language has support for defining and using objects: an **object-oriented language**.+  * Easier and more robust when language has support for defining and using objects: an **object-oriented language**.
  
-====== Object-oriented concepts ======+===== Object-oriented concepts =====
  
   * The concept of "object" in computing comes directly from the concept of “object” in the real world.   * The concept of "object" in computing comes directly from the concept of “object” in the real world.
Line 31: Line 31:
   * Let’s explore this with the example of a microwave oven.   * Let’s explore this with the example of a microwave oven.
  
-====== State ======+===== State =====
  
   * At any given instant, a microwave oven has a particular **state**.   * At any given instant, a microwave oven has a particular **state**.
Line 40: Line 40:
   * These attributes (and others) collectively define the oven’s state.   * These attributes (and others) collectively define the oven’s state.
  
-====== Behavior ======+===== Behavior =====
  
   * A microwave also has predefined **behavior**:   * A microwave also has predefined **behavior**:
Line 49: Line 49:
   * **interface**: the public-facing behavior (i.e., the operations a user can engage).   * **interface**: the public-facing behavior (i.e., the operations a user can engage).
  
-====== Encapsulation ======+===== Encapsulation =====
  
-  * Consider: +  * User changes the state of the oven only by engaging one or more of the operations in the oven’s interface. 
-    * One changes the state of the oven only by engaging one or more of the operations in the oven’s interface. +  Don’t need to know how a magnetron, the clock’s electronics, or anything else works to use the oven. 
-    You don’t need to know how a magnetron, the clock’s electronics, or anything else works to use the oven. +  Only need to know what changes in state to expect from the “cook 1 minute” or “add 30 seconds” operations. 
-    You only need to know what changes in state to expect from the “cook 1 minute” or “add 30 seconds” operations. +  * “I don’t care about how it works—I only need to know what it does,” is part of **encapsulation**.
-  * “I don’t care about how it works—I only need to know what it does,” is part of **encapsulation**: “to place in a capsule.+
  
-====== Protection ======+===== Protection =====
  
   * Oven internals are protected against unwanted fiddling by screws and scary labels—for a reason.   * Oven internals are protected against unwanted fiddling by screws and scary labels—for a reason.
Line 63: Line 62:
   * **protection**: keeping the user out of stuff that the user should not be allowed to access.   * **protection**: keeping the user out of stuff that the user should not be allowed to access.
  
-====== Objects ======+===== Objects =====
  
   * The microwave oven takes responsibility for managing its own state using a set of predetermined behaviors: it’s **self-governing**.   * The microwave oven takes responsibility for managing its own state using a set of predetermined behaviors: it’s **self-governing**.
Line 70: Line 69:
   * **object**: a program entity that encapsulates state (via attributes) and behavior (via operations involving those attributes) for some meaningful abstraction.   * **object**: a program entity that encapsulates state (via attributes) and behavior (via operations involving those attributes) for some meaningful abstraction.
  
 +===== Class-based object-orientation =====
 +
 +  * My Farberware 4241 microwave.\\ 
 +{{:python:about_python:farberware4241-200.jpeg?nolink|}}
 +  * All Farberware 4241s made from a master plan.
 +    * Defines what the Farberware 4241 //is//.
 +  * In computing terminology, the master plan is a **class**.
 +  * A class contains all the specifications needed to make a particular kind of object.
 +
 +===== Class-based object-orientation =====
 +
 +  * Objects that have been created from classes are also called **instances**.
 +  * The process of creating an instance from a class definition is called **instantiation**.
 +
 +===== Prototype-based object-orientation =====
  
 +  * **Prototype-based object-orientation**: used in JavaScript and some other languages.
 +  * Currently less common than class-based OOP.
  
programming_general/object-orientation_fundamentals_slides.1600043231.txt.gz · Last modified: 2020/09/14 00:27 by mithat

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki