programming_general:object-orientation_fundamentals
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
programming_general:object-orientation_fundamentals [2020/09/14 00:55] – mithat | programming_general:object-orientation_fundamentals [2020/11/15 00:03] (current) – [Object-oriented concepts] mithat | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Object-Orientation Fundamentals ====== | ====== Object-Orientation Fundamentals ====== | ||
- | |||
- | |||
- | |||
===== Why object-orientation? | ===== Why object-orientation? | ||
Line 11: | Line 8: | ||
OOAD was created to try to solve some of the issues involved in designing and managing large applications. | OOAD was created to try to solve some of the issues involved in designing and managing large applications. | ||
- | *** | + | It represents a shift in the way you typically approach a problem when using procedural/ |
- | It represents a shift in the way you typically approach a problem using procedural/ | + | In object-oriented |
- | *** | + | You can //analyze// and //design// your problem |
- | + | ||
- | In object-oriented thinking, you start with, "What are the components (objects) that make up the problem?" | + | |
- | + | ||
- | *** | + | |
- | + | ||
- | While it is possible to analyze and design | + | |
So, OOAD facilitates a higher level of modular thinking. And, especially with an object-oriented language, it allows for very effective project management of large applications. | So, OOAD facilitates a higher level of modular thinking. And, especially with an object-oriented language, it allows for very effective project management of large applications. | ||
- | |||
- | *** | ||
===== Object-oriented concepts ===== | ===== Object-oriented concepts ===== | ||
- | The concept of an object in computing comes directly from the concept of an " | + | The concept of an object in computing comes directly from the concept of an " |
* state | * state | ||
Line 37: | Line 26: | ||
We next explore each of these in the context of an object from the real world: a microwave oven. | We next explore each of these in the context of an object from the real world: a microwave oven. | ||
- | |||
- | *** | ||
==== State ==== | ==== State ==== | ||
Line 50: | Line 37: | ||
All these attributes, which can be defined in terms of data, collectively define the oven's state. | All these attributes, which can be defined in terms of data, collectively define the oven's state. | ||
- | |||
- | *** | ||
==== Behavior ==== | ==== Behavior ==== | ||
Line 63: | Line 48: | ||
These operations are ones that happen to be public-facing (i.e., operations a user can engage). We call this public-facing behavior (i.e., the operations a user can engage) the oven's **interface**. There might also be operations that go on inside the oven that the user will never be aware of to support the oven's functioning. These are not part of the oven's interface but are important behaviors all the same. | These operations are ones that happen to be public-facing (i.e., operations a user can engage). We call this public-facing behavior (i.e., the operations a user can engage) the oven's **interface**. There might also be operations that go on inside the oven that the user will never be aware of to support the oven's functioning. These are not part of the oven's interface but are important behaviors all the same. | ||
- | |||
- | *** | ||
==== Encapsulation and protection ==== | ==== Encapsulation and protection ==== | ||
Line 72: | Line 55: | ||
This idea of "not caring about how it works---I only need to know what it does" is the essence of **encapsulation** (literally, "to place in a capsule" | This idea of "not caring about how it works---I only need to know what it does" is the essence of **encapsulation** (literally, "to place in a capsule" | ||
- | |||
- | *** | ||
In fact, even if I wanted to get at, for example, magnetron inside or directly change the clock' | In fact, even if I wanted to get at, for example, magnetron inside or directly change the clock' | ||
Keeping someone out of stuff they should not be allowed to access is called **protection** or sometimes **information hiding**. In many (but not all) languages, properly hiding things the user has no business getting into is considered part of encapsulation. | Keeping someone out of stuff they should not be allowed to access is called **protection** or sometimes **information hiding**. In many (but not all) languages, properly hiding things the user has no business getting into is considered part of encapsulation. | ||
- | |||
- | *** | ||
==== Objects ==== | ==== Objects ==== | ||
Line 87: | Line 66: | ||
To put it another way, an object is a program entity that encapsulates state and behavior for some meaningful abstraction. It does this by using attributes and operations involving those attributes. | To put it another way, an object is a program entity that encapsulates state and behavior for some meaningful abstraction. It does this by using attributes and operations involving those attributes. | ||
- | |||
- | *** | ||
==== Class-based object-orientation ==== | ==== Class-based object-orientation ==== | ||
Line 99: | Line 76: | ||
Thus my oven is an instance of a Farberware 4241, and you might say the Farberware factory spends it's entire day instantiating 4241 ovens. | Thus my oven is an instance of a Farberware 4241, and you might say the Farberware factory spends it's entire day instantiating 4241 ovens. | ||
- | |||
- | *** | ||
==== Prototype-based object-orientation ==== | ==== Prototype-based object-orientation ==== | ||
Line 106: | Line 81: | ||
There is another kind of object-orientation called **prototype-based object-orientation** or **prototype-based programming**. This is the kind of object-orientation used in JavaScript and some other languages.((C++, | There is another kind of object-orientation called **prototype-based object-orientation** or **prototype-based programming**. This is the kind of object-orientation used in JavaScript and some other languages.((C++, | ||
- | *** home *** | ||
==== Ovens and code ==== | ==== Ovens and code ==== |
programming_general/object-orientation_fundamentals.txt · Last modified: 2020/11/15 00:03 by mithat