2 Abstract Data Types and Encapsulation Concepts

0.0(0)
studied byStudied by 0 people
0.0(0)
full-widthCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/108

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

109 Terms

1
New cards

abstraction

An — is a view or representation of an entity that includes only the most significant attributes

2
New cards

programming (and computer science)

The concept of abstraction is fundamental in —

3
New cards

process abstraction with subprograms

Nearly all programming languages support —

4
New cards

data abstraction

Nearly all programming languages designed since 1980 support —

5
New cards

abstract data type

An — is a user-defined data type that satisfies the following two conditions

6
New cards

representation of objects of the type

ADT 1st Condition

The — is hidden from the program units that use these objects, so the only operations possible are those provided in the type's definition

7
New cards

declarations of the type and the protocols of the operations on objects of the type

ADT 2nd Condition

The — are contained in a single syntactic unit. Other program units are allowed to create variables of the defined type.

8
New cards

Reliability

Advantages the first condition

— by hiding the data representations, user code cannot directly access objects of the type or depend on the representation, allowing the representation to be changed without affecting user code

9
New cards

range of code and variables

Advantages the first condition

Reduces the — of which the programmer must be aware

10
New cards

Name conflicts

Advantages the first condition

— are less likely

11
New cards

program organization

Advantages the second condition

Provides a method of —

12
New cards

modifiability

Advantages the second condition

Aids — (everything associated with a data structure is together)

13
New cards

Separate

Advantages the second condition

— compilation

14
New cards

syntactic unit

Language Requirements for ADTs

A — in which to encapsulate the type definition

15
New cards

type names and subprogram headers

Language Requirements for ADTs

A method of making — visible to clients, while hiding actual definitions

16
New cards

primitive operations

Language Requirements for ADTs

Some — must be built into the language processor

17
New cards

parameterized

Design Issues

Can abstract types be —?

18
New cards

access controls

Design Issues

What — are provided?

19
New cards

specification of the type

Design Issues

Is the — physically separate from its implementation?

20
New cards

C++

Language Examples: —

Based on C struct type and Simula 67 classes

21
New cards

class

Language Examples: C++

The — is the encapsulation device

22
New cards

type

Language Examples: C++

A class is a —

23
New cards

member functions

Language Examples: C++

All of the class instances of a class share a single copy of the —

24
New cards

class data members

Language Examples: C++

Each instance of a class has its own copy of the —

25
New cards

static, stack dynamic, or heap dynamic

Language Examples: C++

Instances can be —

26
New cards

Private clause

Language Examples: C++

Information Hiding

— for hidden entities

27
New cards

Public clause

Language Examples: C++

Information Hiding

— for interface entities

28
New cards

Protected clause

Language Examples: C++

Information Hiding

— for inheritance

29
New cards

Constructors

Language Examples: C++

— Functions to initialize the data members of instances (they do not create the objects)

30
New cards

heap-dynamic

Language Examples: C++

Constructors:

May also allocate storage if part of the object is —

31
New cards

parameterization of the objects

Language Examples: C++

Constructors:

Can include parameters to provide —

32
New cards

Implicitly called

Language Examples: C++

Constructors:

— when an instance is created

33
New cards

explicitly called

Language Examples: C++

Constructors:

Can be

34
New cards

class name

Language Examples: C++

Constructors:

Name is the same as the —

35
New cards

Destructors

Language Examples: C++

— Functions to cleanup after an instance is destroyed; usually just to reclaim heap storage

36
New cards

object’s lifetime ends

Language Examples: C++

Destructors:

implicitly called when the —

37
New cards

explicitly called

Language Examples: C++

Destructors:

Can be —

38
New cards

tilde (~)

Language Examples: C++

Destructors:

Name is the class name, preceded by a —

39
New cards

Friend functions or classes

Language Examples: C++

— to provide access to private members to some unrelated units or functions

Necessary in C++

40
New cards

Java

Language Examples: —

Similar to C++, except

41
New cards

user-defined types

Language Examples: Java

All — are classes

42
New cards

reference variables

Language Examples: Java

All objects are allocated from the heap and accessed through —

43
New cards

access control modifiers (private or public)

Language Examples: Java

Individual entities in classes have —, rather than clauses

44
New cards

garbage collection

Language Examples: Java

Implicit — of all objects

45
New cards

package scope

Language Examples: Java

Java has a second scoping mechanism, —, which can be used in place of friends

46
New cards

visible throughout the package

Language Examples: Java

All entities in all classes in a package that do not have access control modifiers are —

47
New cards

C#

Language Examples: —

Based on C++ and Java

48
New cards

internal and protected internal

Language Examples: C#

Adds two access modifiers —

49
New cards

heap dynamic

Language Examples: C#

All class instances are —

50
New cards

Default constructors

Language Examples: C#

— are available for all classes

51
New cards

Garbage collection

Language Examples: C#

— is used for most heap objects, so destructors are rarely used

52
New cards

structs

Language Examples: C#

— are lightweight classes that do not support inheritance

53
New cards

accessor methods (getter and setter)

Language Examples: C#

Common solution to need for access to data members:

54
New cards

properties

Language Examples: C#

C# provides — as a way of implementing getters and setters without requiring explicit method calls

55
New cards

Parameterized Abstract Data Types

Also known as generic classes

56
New cards

static typed languages

Parameterized ADTs allow designing an ADT that can store any type elements (only an issue for —)

57
New cards

C++, Java 5.0, and C# 2005

— provide support for parameterized ADTs

58
New cards
<p>C++</p>

C++

Parameterized ADTs in —

Classes can be somewhat generic by writing parameterized constructor functions

59
New cards

declaration

Parameterized ADTs in C++

A — of a stack object

<p><strong>Parameterized ADTs in C++</strong></p><p>A  — of a stack object</p>
60
New cards
<p>templated class</p>

templated class

Parameterized ADTs in C++

The stack element type can be parameterized by making the class a —

61
New cards

Instantiation

Parameterized ADTs in C++

—: Stack myIntStack;

62
New cards

Java 5.0

Parameterized Classes in —

Generic parameters must be classes

63
New cards

LinkedList and ArrayList

Parameterized Classes in Java 5.0

Most common generic types are the collection types, such as

64
New cards

cast objects

Parameterized Classes in Java 5.0

Eliminate the need to — that are removed

65
New cards

multiple types in a structure

Parameterized Classes in Java 5.0

Eliminate the problem of having —

66
New cards

Users

Parameterized Classes in Java 5.0

— can define generic classes

67
New cards

store primitives

Parameterized Classes in Java 5.0

Generic collection classes cannot

68
New cards

Indexing

Parameterized Classes in Java 5.0

— is not supported

69
New cards

myArray.add(0, 47); // Put an element with subscript 0 in it

Parameterized Classes in Java 5.0

Example of the use of a predefined generic class: ArrayList myArray = new ArrayList ();

70
New cards

Instantiation: Stack2 myStack = new Stack2 ();

Parameterized Classes in Java 5.0

Example

<p><strong>Parameterized Classes in Java 5.0</strong></p><p>Example</p>
71
New cards

C# 2005

Parameterized Classes in —

Similar to those of Java 5.0, except no wildcard classes

72
New cards

Array, List, Stack, Queue, and Dictionary

Parameterized Classes in C# 2005

Predefined for

73
New cards

indexing

Parameterized Classes in C# 2005

Elements of parameterized structures can be accessed through

74
New cards

organization

Encapsulation Constructs

Large programs have two special needs:

Some means of —, other than simply division into subprograms

75
New cards

partial compilation

Encapsulation Constructs

Large programs have two special needs:

Some means of — (compilation units that are smaller than the whole program)

76
New cards

separately compiled (compilation units)

Encapsulation Constructs

Obvious solution: a grouping of subprograms that are logically related into a unit that can be

77
New cards

encapsulation

Encapsulation Constructs

Such collections are called

78
New cards

Nested Subprograms

Organizing programs by nesting subprogram definitions inside the logically larger subprograms that use them

79
New cards

Python, JavaScript, and Ruby

Nested subprograms are supported in —

80
New cards

Encapsulation in C

Files containing one or more subprograms can be independently compiled

81
New cards

header file

Encapsulation in C

The interface is placed in a

82
New cards

linker

Encapsulation in C

Problem 1: the — does not check types between a header and associated implementation

83
New cards

inherent problems with pointers

Encapsulation in C

Problem 2: the —

84
New cards

#include preprocessor specification

Encapsulation in C

– used to include header files in applications

85
New cards

Encapsulation in C++

Can define header and code files, similar to those of C

86
New cards

encapsulation

Encapsulation in C++

Or, classes can be used for —

87
New cards

interface (prototypes)

Encapsulation in C++

The class is used as the —

88
New cards

separate file

Encapsulation in C++

The member definitions are defined in a —

89
New cards

Friends

Encapsulation in C++

— provide a way to grant access to private members of a class

90
New cards

C# Assemblies

A collection of files that appears to application programs to be a single dynamic link library or executable

91
New cards

separately compiled

C# Assemblies

Each file contains a module that can be —

92
New cards

DLL

C# Assemblies

A — is a collection of classes and methods that are individually linked to an executing program

93
New cards

internal

C# Assemblies

C# has an access modifier called —; an —member of a class is visible to all classes in the assembly in which it appears

94
New cards

naming encapsulation

Large programs define many global names; need a way to divide into logical groupings.

A — is used to create a new scope for names

95
New cards

C++ Namespaces

C#

– Can place each library in its own namespace and qualify names used outside with the namespace

— also includes namespaces

96
New cards

Java Packages

partial friends

Naming Encapsulations

— Packages can contain more than one class definition; classes in a package are —

97
New cards

import declaration

Naming Encapsulations: Java Packages

Clients of a package can use fully qualified name or use the —

98
New cards

modules

Naming Encapsulations

Ruby classes are name encapsulations, but Ruby also has

99
New cards

constants and methods

Naming Encapsulations: Ruby Modules

Typically encapsulate collections of —

100
New cards

Modules

Naming Encapsulations: Ruby Modules

cannot be instantiated or subclassed, and they cannot define variables