Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống
1
/ 35 trang
THÔNG TIN TÀI LIỆU
Thông tin cơ bản
Định dạng
Số trang
35
Dung lượng
386,5 KB
Nội dung
07/16/14 1 OO - Basics 2 07/16/14 Introduction to Object Orientation Topics Basic Principles of Object Orientation Basic Concepts of Object Orientation Strengths of Object Orientation 3 07/16/14 Object Orientation Encapsulation Abstraction Hierarchy Polymorphism Basic Principles of Object Orientation 4 07/16/14 What Is Abstraction? The essential characteristics of an entity that distinguishes it from all other kinds of entities. Defines a boundary relative to the perspective of the viewer. Is not a concrete manifestation, denotes the ideal essence of something. 5 07/16/14 Salesperson Not saying Which salesperson – just a salesperson in general!!! Customer Product Manages Complexity What is Abstraction? 6 07/16/14 What Is Encapsulation? Improves Resiliency Hides implementation from clients. Clients depend on interface. 7 07/16/14 Encapsulation "Encapsulation is a mechanism used to hide the data, internal structure, and implementation details of an object. All interaction with the object is through a public interface of operations." (Craig Larman) A boundary exists around each object; the boundary encapsulates the object’s characteristics (data elements) and behaviors (functionality). The reason for hiding features is to: (1) keep users from touching parts of the object they shouldn’t touch; (2) allows creator of the object to change the object’s internal working without affecting the users of the object. 8 07/16/14 What Is Polymorphism? Manufacturer A Manufacturer B Manufacturer C OO Principle: Encapsulation Remote Control The ability to hide many different implementations behind a single interface. 9 07/16/14 Polymorphism Occurs with inheritance. Different subclasses may have different implementations of the identical operations Allows you to treat an object as the base class, rather than as a specific inherited type. Programmer doesn’t have to keep track of the specific subclasses, the system selects the correct operation based on the object type. Accomplished at run time using dynamic binding. lets you substitute objects that have identical interfaces for each other at run-time. 10 07/16/14 Decreasing abstraction Increasing abstraction Asset RealEstate Savings BankAccount Checking Stock Security Bond Elements at the same level of the hierarchy should be at the same level of abstraction What is Hierarchy? Levels of abstraction