Chapter 11 - Abstract data types Flashcards Preview

Advanced Topics in Programming Languages > Chapter 11 - Abstract data types > Flashcards

Flashcards in Chapter 11 - Abstract data types Deck (21):
1

what is an abstraction?

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

2

what is an abstract data type?

-a data representation of one specific data type

-the subprograms that provide the operations for that type

3

6 Design issues for abstract data types

-what is the form of the container

-what types can be abstract

-can abstract types be parameterized

-what access controls are provided

-is the specification of the type physically separate from its implementation

-should general built-in operations be provided from objects of abstract data types

4

What is an object

an instance of an abstract data type

5

What is the encapsulation construct in Ada

the package

6

4 characteristics of C++ class

-an encapsulation device

-all class instances share a single copy of the member functions

-each instance of a class has its own copy of the class data members

-instances can be static, stack dynamic, or heap dynamic

7

6 characteristics of C++ constructors

-they initialize objects

-may allocate storage for any parts that are heap-dynamic

-can include parameters to provide parameterization of the objects

-implicitly called when an instance is created

-can be explicitly called

-name the same as class

8

5 characteristics of C++ destructors

-implicitly called when the lifetime of an instance of the class ends

-often used for delete of heap-dynamic data allocated within the class

-often used for debugging or statistical analysis

-can be explicitly called

-the name is ~class_name

9

3 differences of Java objects than C++ objects

-all objects are allocated on the heap and accessed through reference variables

-individual entities in classes have access modifiers (public, private) rather than clauses

-has an extra scoping mechanism "package scope" to be used in place of friends

10

3 characteristics of abstract data types in C#

-all class instances are heap dynamic

-default constructors are predefined for all classes

-C# allows destructors but it uses garbage collection so they are rarely used

11

6 characteristics of C# structs

-they can have constructors, properties, methods, and data fields

-can implement interfaces but do not support inheritance

-they are value types (their data is allocated to memory on the stack)

-they default to pass by value when used as parameters

-they can be declared like other types

-they can also be created using new operator with invokes the constructor

12

3 characteristics of Ruby classes (that I probably don't know)

class methods are distinguished from instance methods by having a class name appended to the beginning of their names with a dot separator

constructors are called "initialize"

classes can be "updated" any place in the text

13

Ruby undef_method vs remove_method

undef_method - blocks any reference to a given method

remove_method - block deletes method from class but allows those class objects to look for method definition in parent

14

4 characteristics of information hiding in Ruby

-access control violations are only detected at runtime

-uses public (default), protected, and private

-all data members of a class are private and cannot be changed

-data access is via methods only

15

what is an encapsulation construct?

-a way of organizing programs into collections of logically related code and data, each of which can be compiled without recompilation of the rest of the program

16

Examples of encapsulation constructs in C, C++, Ada, C#

C --> header and implementation files

C++ --> header/implementation and class header/implemenatation files

Ada --> packages (can include any number of interfaces to ADTs)

C# --> assemblies (mimics a dll or exe)

17

why use named encapsulations?

when dealing with large programs written by many coders working independently named encapsulations define scopes that help avoid name collisions/duplication

18

4 examples of named encapsulation?

C++ namespace

Java package

Ada package

Ruby modules

19

5 characteristics of Java packages

-may contain multiple type definitions

-all types in the package are partial friends

-package declaration must be the first line of the file

-all types outside of a package are part of the default unnamed Java package

-access similar to C++ (add using import blah)

20

2 things for using Ada package data

-visibility to the package is gained by using "with" clause

-member references must be qualified "Ada.pkg_name.method or use the "use" clause

use Ada.pkg_name
method...

21

6 characteristics of Ruby modules

-may contain methods and constants

-cannot define variables

-cannot be instantiated

-cannot be inherited

-a method defined in a module must include the module name

-clients access module first by "require" then by module name