Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 11: Abstract Data Types Lecture # 17. Chapter 11 Topics The Concept of Abstraction Advantages of Abstract Data Types Design Issues for Abstract.

Similar presentations


Presentation on theme: "Chapter 11: Abstract Data Types Lecture # 17. Chapter 11 Topics The Concept of Abstraction Advantages of Abstract Data Types Design Issues for Abstract."— Presentation transcript:

1 Chapter 11: Abstract Data Types Lecture # 17

2 Chapter 11 Topics The Concept of Abstraction Advantages of Abstract Data Types Design Issues for Abstract Data Types Language Examples Chapter 11: Abstract Data Types 2

3 The Concept of Abstraction An abstraction is a view or representation of an entity that includes only the most significant attributes. Chapter 11: Abstract Data Types 3

4 Abstraction in the World of Programming Languages In the world of programming languages, abstraction is a weapon against the complexity of programming. Its purpose is to simplify the programming process. It is an effective weapon because it allows programmers to focus on essential attributes, which ignoring subordinate attribute. Chapter 11: Abstract Data Types 4

5 Abstraction Used in Contemporary Programming Languages The two fundamental kinds of abstraction in contemporary programming languages are:  Process Abstraction. and  Data Abstraction. Chapter 11: Abstract Data Types 5

6 Process Abstraction The concept of process abstraction is among the oldest in programming language design. All subprograms are process abstractions o because they provide a way of program to specify that some process is to be done, o without providing the details of how it is to be done (at least in the calling program). Chapter 11: Abstract Data Types 6

7 Implementation Hiding Through access controls, unnecessary details of the type can be hidden from units outside the enclosure that use the type. An instance of an abstract data type is called an object. Chapter 11: Abstract Data Types 7

8 Advantages of Abstract Data Types (1) Abstract data types allow program portability between implementations of a particular language,  even though the implementations may use different representations for particular data types. Chapter 11: Abstract Data Types 8

9 The primary advantage of packaging the declaration of the type and its operations in a single syntactic unit is:  It provides a method of organizing a program into logical units that can be complied separately. Chapter 11: Abstract Data Types 9 Advantages of Abstract Data Types (2)

10 The advantage of having the implementation of the type and its operations in a different syntactic unit is that:  It is good to keep specifications and their implementations separate. Clients of an abstract data type need to see the specification, but cannot be allowed to see the implementation. Chapter 11: Abstract Data Types 10 Advantages of Abstract Data Types (3)

11 An important benefit of information hiding is increased reliability. Clients cannot manipulate the underlying representations of objects directly, either intentionally or by accident, thus increasing the integrity of such objects. Objects can be changed only through the provided operations. Chapter 11: Abstract Data Types 11 Advantages of Abstract Data Types (4)

12 Design Issues for Abstract Data Types (1) A facility for defining abstract data types in a language must provide a syntactic unit that can encapsulate:  the type definition and  subprogram definitions of the abstraction operations. It must be possible to make the type name and subprogram headers visible to clients of the abstraction. This allows clients to declare variables of the abstract type and manipulate their values. Chapter 11: Abstract Data Types 12

13 Although the type name must have external visibility, the type definition must be hidden. The same is often true for subprogram definitions — the headers must be visible but the bodies may be hidden. Chapter 11: Abstract Data Types 13 Design Issues for Abstract Data Types (2)

14 Language Examples: Abstract Data Types in C++ C++ was created by adding features to C. The first important additions were those to support object- oriented programming (OOP). Because one of the primary components of object-oriented programming is abstract data types, C++ obviously must support them. Chapter 11: Abstract Data Types 14

15 Class Members and Instance Members Data members and member functions appear in two categories:  Class and  instance. Class members are associated with the class. Instance members are associated with the instances of the class.  This chapter only discusses the instance members of a class. Chapter 11: Abstract Data Types 15

16 Properties of Class Instances All of the instances of a class share a single set of member functions. But each instance gets its own set of the class's data members. Chapter 11: Abstract Data Types 16

17 Definitions of Member Functions A member function of a class can be defined in two distinct ways:  The complete definition can appear in the class or  only its header. If only the header of a member function appears in the class definition, its complete definition appears outside the class and is separately compiled. Chapter 11: Abstract Data Types 17

18 Categories of Visibility A C++ class can contain both hidden and visible entities (meaning they are either hidden from or visible to clients of the class). Entities that are to be hidden are placed in a private clause. Entities that are to be visible are placed in a public clause. o The public clause therefore describes the interface to class objects. There is also a third category of visibility, protected, which is discussed in the context of inheritance. Chapter 11: Abstract Data Types 18

19 Constructor C++ allows the user to include constructor functions in class definitions, which are used to initialize the data members of newly created objects. Constructors are implicitly called when an object of the class type is created. A constructor has the same name as the class. Chapter 11: Abstract Data Types 19

20 Destructor A C++ class can also include a function called a destructor, which is implicitly called when the lifetime of an instance of the class ends. The name of a destructor is the class's name, preceded by a tilde (~). Chapter 11: Abstract Data Types 20


Download ppt "Chapter 11: Abstract Data Types Lecture # 17. Chapter 11 Topics The Concept of Abstraction Advantages of Abstract Data Types Design Issues for Abstract."

Similar presentations


Ads by Google