Chapter 12 OOP using C ++

Source: Internet
Author: User
Chapter 12 OOP using C ++
• 12.1 OOP Language
Requirements
• 12.2 ADTs in non-Oop
Ages
• 12.3 clients and
Manufacturers
• 12.4 reuse and
Inheritance
• 12.5 Polymorphism
• 12.6 Language
Complexity
• 12.7 C ++ oopb and
Wagon
• 12.8 Platonism: tabula
Rasa Design
• 1 2.9 Design Principles
• 12.10 schema. diagrams.
And tools
• 12.11 Design Patterns
• 12.12 C ++: A Critique
• Summary
• Exercises
Chapter 12 OOP using C ++
• C ++ is a hybrid language.
• Object-oriented programming (o0p) and
C ++ were embraced by the industry very
Quickly.
• The key new ingredients are inheritance and
Polymorphism, that is, its capability
Assume terraforms.
12.1 OOP language requirements
• OOP Language Characteristics
• Encapsulation with data hiding
E n c a p s u l a t I o n w I t h d a T A H I N G
: The ability
Distinguish an object's internal state and Behavior
From its external State and behavior.
• Type-extensibility
T y p e-e x t e n s I B I t y
: The ability to add user-defined
Types to augment the native types.
• Inheritance
I n h e r I t a n C E
: The ability to create new types
Importing or reusing the description of existing
Types.
• Polymorphism with dynamic binding
P o l y m o r p h I s m w I t h d y n a m I c B I n d I n g
: The ability
Of objects to be responsible for interpreting
Function invocation.
12.2 ADTs in non-oop languages ages
• Existing ages and methodology
Supported much of the OOP methodology
By combining language features
Programmer discipline.
12.3 clients and manufacturers
• Black box for the client
-Simple to use, easy to understand, and familiar
-Cheap, efficient, and powerful
-In a component relationship within the system
• Black box for the manufacturer
-Easy to reuse and modify, and hard to misuse
And reproduce
-Cheap, efficient, and powerful
-Profitable to produce with a large client base
12.4 reuse and inheritance
• Library Creation and reuse are crucial
Indicators of successful language strategies.
• The OOP Design Methodology
• 1.
Decide on an appropriate set of ADTs.
• 2.
Design in their relatedness, and use
Inheritance to share code and interface.
• 3.
Use virtual functions to process related
Objects dynamically.
12.5 Polymorphism
• Types
Of Polymorphism
• 1. Coercion (ad hoc polymorphism):
Function or operator works on several
Different types by converting their values
The expected type.
• 2.
Overloading (ad hoc polymorphism):
Function is called based on its signature
Defined as the list of argument types in its
Parameter List.
12.5 Polymorphism
• 3.
Partition Sion (pure polymorphism): A type is
A subtype of another type. Functions
Available for the base type will work on
Subtype.
• 4. parametric polymorphism (pure
Polymorphism): The type is left unspecified
And is later instantiated.
12.6 language complexity
12.7 C ++ OOP bandwagon
• OOP using C ++ has gained dazzling
Acceptance in industry, despite
Acknowledged flaws.
• OOP = type-extensibility
T y pe-e xt e n s I Bi L I t y
+ Polymorphism.
Pol y m or pH I S M.
12.8 Platonism: tabula rasa Design
• Tabula rasa-given an empty slate-no simple
Methodology exists, because each design
Must be strongly tied to the problem domain
And reflect its own actions.
• Discovering these processing actions is a design
Philosophy we call Platonism
PL at on I s m
.
.
12.8 Platonism: tabula rasa Design
• In the Platonic paradigm, there is an ideal
Object.
12.9 Design Principles
• Most programming shocould involve the use
Of existing designs.
• Occam's Razor is a useful design principle. It
States that entities shocould not be multiplied
Beyond necessity-or beyond completeness,
Invertibility, orthogonality, consistency,
Simplicity, efficiency, and expressiveness.
-Invertibility
I n v e r t I B I L I t y
Means that the program shocould
Have member functions that are inverses.
12.9 Design Principles
-Completeness
C o m p l e t e n e s
Is best seen in Boolean algebra,
Where the NAND operation suffices to generate
All possible boolean expressions.
-Orthogonality
O r t h o g o n a L I t y
Is a principle that says each
Element of a design shoshould integrate and work
With all other elements without overlapping or
Being redundant.
-Hierarchy
H I e r A R C H Y
Is captured through inheritance.
Designs shoshould be hierarchical.
12.10 schema. diagrams. and tools
• CRC stands for class, responsibility, and
Collaboration.
-A responsibility is an obligation the class must keep.
-A collaborator is another object that cooperates
This object to provide some overall set of behaviors.
-The front of the card corresponds to public behavior.
-The back of the card can be used to show
Implementation Details, including ISA, likea, and
Hasa relationships.
12.10 schema. diagrams. and tools
12.10 schema. diagrams. and tools
• Wasserman-pircher diagrams are derived
From entity-relation modeling and structured
Design.
12.10 schema. diagrams. and tools
• A sophisticated Integrated Software
Environment that uses these to develop OOP
Code is provided by interactive
Development Environments (IDE), San
Francisco, California.
12.10 schema. diagrams. and tools
12.11 Design Patterns
• Reuse is a primary theme in modern programming.
• Thus the iterator classes of STL are a design
D e S I g N
Pattern.
P a t e r n.
• Elements of a design pattern
-1. The pattern terminology. For example, iterator
I t e r a t o r
.
.
-2.
The problem and conditions. For example, visitation
V I s I t a t I o n
Over a container.
-3.
The solution. For example, pointer-like objects
A common interface.
-4. The evaluation. For example, the trade-off
Defining an iterator on a vector or using a native array.
12.11 Design Patterns
• A design pattern is an alternative action that
Suggests a useful solution to a participant
Programming Problem.
• Design Patterns in this text
Itseragxhnptdtn
• 1. iterator
I t e r at or
.
.
• 2. composite.
2. c om pos I t e.
• 3. template method.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.