Software Patterns

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

variation - research OOP more

I don' t think mutators are a major principle of OO. In fact, from OO's point of view they violate encapsulation. Mutators are a principle of component based programming and a compromise w/OO principles. ....

Inheritance OOP

Objects can relate to each other a library, for example. A library lends more than just books, it also lends magazines, audiocassettes and microfilm. On some level, all of these items can be treated the same: All four types represent assets of the library that can be loaned out to people. However, even though the 4 types can be viewed as the same, they are not identical. A book has an ISBN and a magazine does not. And audiocassette has a play length and microfilm cannot be checked out overnight. Each of these library's assets should be represented by its own class definition. Without inheritance though, each class must independently implement the characteristics that are common to all loanable assets. All assets are either checked out or available for checkout. All assets have a title, a date of acquisition and a replacement cost. Rather than duplicate functionality, inheritance allows you to inherit functionality from another class, called a superclass or base class.\\One of the most powerful features of inheritance is the ability to extend components without any knowledge of the way in which a class was implemented. Declaration options, such as Public and Private, dictate which members of a superclass can be inherited.

Core Principles of OOP

Polymorphism Abstraction Encapsulation Inheritence

Polymorphism definition

Polymorphism means one name, many forms. Polymorphism manifests itself by having multiple methods all with the same name, but slighty different functionality. Many VB6ers are familiar with interface polymorphism. I'm only going to discuss polymorphism from the point of view of inheritance because this is the part that is new to many people. Because of this, it can be difficult to fully grasp the full potential of polymorphism until you get some practice with it and see exactly what happens under different scenarios. We're only going to talk about polymorphism, like the other topics, at the basic level. There are 2 basic types of polymorphism. Overridding, also called run-time polymorphism, and overloading, which is referred to as compile-time polymorphism. This difference is, for method overloading, the compiler determines which method will be executed, and this decision is made when the code gets compiled. Which method will be used for method overriding is determined at runtime based on the dynamic type of an object. http://codebetter.com/raymondlewallen/2005/07/19/4-major-principles-of-object-oriented-programming/

Abstraction

Pulling out specific differences to make one solution work for multiple problems. Data abstraction is the simplest of principles to understand. Data abstraction and encapsulation are closely tied together, because a simple definition of data abstraction is the development of classes, objects, types in terms of their interfaces and functionality, instead of their implementation details. Abstraction denotes a model, a view, or some other focused representation for an actual item. Its the development of a software object to represent an object we can find in the real world. Encapsulation hides the details of that implementation. "An abstraction denotes the essential characteristics of an object that distinguish it from all other kinds of object and thus provide crisply defined conceptual boundaries, relative to the perspective of the viewer." — G. Booch, Object-Oriented Design With Applications, Benjamin/Cummings, Menlo Park, California, 1991. Abstraction is used to manage complexity. Software developers use abstraction to decompose complex systems into smaller components.

Encapsulation - What is encapsulation?

Well, in a nutshell, encapsulation is the hiding of data implementation by restricting access to accessors and mutators. data protection and implementation protection using accessors and mutators as the pieces that surround the data that forms the class.

object-oriented programming

____ is a style of programming that involves representing items, things, and people as objects rather than basing the logic around actions. a. Object-oriented programming c. Variable initialization b. Assembly programming d. Polymorphism

S.O.L.I.D.

five design principles (OOP) intended to make software designs more understandable, flexible and maintainable. Single responsibility principle - A class should only have a single responsibility, that is, only changes to one part of the software's specification should be able to affect the specification of the class. Open-closed principle - "Software entities ... should be open for extension, but closed for modification." Liskov substitution principle - "Objects in a program should be replaceable with instances of their subtypes without altering the correctness of that program." See also design by contract. Interface segregation principle - "Many client-specific interfaces are better than one general-purpose interface." Dependency inversion principle - One should "depend upon abstractions, [not] concretions." *source - Wikipedia

Accessors and Mutators

getter, setter An accessor is a method that is used to ask an object about itself. In OOP, these are usually in the form of properties, which have, under normal conditions, a get method, which is an accessor method. However, accessor methods are not restricted to properties and can be any public method that gives information about the state of the object. Mutators are public methods that are used to modify the state of an object, while hiding the implementation of exactly how the data gets modified. Mutators are commonly another portion of the property discussed above, except this time its the set method that lets the caller modify the member data behind the scenes.

superclass or base class, subclass

helper vocab for the above

Composition over inheritance

https://en.wikipedia.org/wiki/Composition_over_inheritance, https://en.wikipedia.org/wiki/Design_Patterns Composition over inheritance (or composite reuse principle) in object-oriented programming (OOP) is the principle that classes should achieve polymorphic behavior and code reuse by their composition (by containing instances of other classes that implement the desired functionality) rather than inheritance from a base or parent class.[2] Although an inheritance relationship is considered an is-a relationship for reasons already discussed, a composition relationship is termed a has-a relationship.

Inheritance

https://en.wikipedia.org/wiki/Inheritance_(object-oriented_programming) a "child object" - acquires all the properties and behaviors of the parent object (except constructors, destructor, overloaded operators and friend functions of the base class). Inheritance allows programmers to create classes that are built upon existing classes,[1] to specify a new implementation while maintaining the same behaviors (realizing an interface), to reuse code and to independently extend original software via public classes and interfaces. An inherited class is called a subclass of its parent class or super class.

Composition

https://en.wikipedia.org/wiki/Object_composition It is natural to think of objects as containing other objects. A television set contains a tuner and a video display. A computer contains video cards, keyboards, and drives. Although the computer can be considered an object unto itself, the drive is also considered a valid object. In fact, you could open up the computer and remove the drive and hold it in your hand. Both the computer and the drive are considered objects. It is just that the computer contains other objects—such as drives. In this way, objects are often built, or composed, from other objects: This is composition. With composition, we can also build classes by embedding classes in other classes.


Set pelajaran terkait

HA Ears, Nose, Mouth, and Throat Prep U

View Set

NCLEX Hematological and Oncological Meds

View Set

Properties, Postulates, Definitions, Theorems, and Proofs

View Set

Unit 7: Biophysychosocial Practice Questiions

View Set

History; Nixon, Ford, and Carter

View Set

BOC Prep and NATA-BOC Exam Secrets Study Guide

View Set