-
An object is a software “bundle,” usually thought of as being a class or structure consisting of a set of variables which defines the states the object can exist in, and a set of functions that defines the behavior of the object.
Object
-
List and briefly explain the three characteristics of an object?
- 1. State – the member variables or fields
- 2. Defined Behavior – the member functions
- 3. Defined ways of modifying the state – by the member functions.
-
What is the purpose of a friend function?
Tells the function that it is a friend and can touch its private parts.
-
Show how to declare a function, not part of a class, as a friend function.
char *presentTime(time_class tz) {}
- friend char *presentTime(time_class tz);
-
A single version of an object/class.
Instance
-
The process of creating a new version of an object/class.
Instantiation
-
The header file, one of the two files needed to define a class. Contains the definition of the class, using a syntax similar to that for defining a data structure.
Interface File
-
The second file needed to define a class. It contains all of the functions that are members of that class.
Implementation File
-
In C++ classes you can assign to the variables and functions an access scope using: public, private, and protected.
Member Access Specifiers
-
A function that is not a part of a class, but has been given access to the private members (variables and functions) of the class.
Friend Function
-
A mechanism by which one class acquires the properties (member variables and member functions) of another class.
Inheritance
-
A class can have more than one superclass.
Multiple Inheritance**
-
The ability to use the same named functions in sub-classes of a parent class to perform different actions.
Polymorphism**
-
Show how you would indicate in the definition of the class DemoClassChild that it is a subclass of DemoClass.
class DemoClassChild : public DemoClass;
-
1. Show how you would indicate in the definition of the class cString that it is a subclass of both cShape and String.
2. What is the name of this process?
- 1. class cString : public cShape, public String
- 2. Multiple Inheritance**
-
The source code for an object can be written and maintained independently of the source code for other objects.
Modularity
-
By interacting only with an object's methods, the details of its internal implementation remain hidden from the outside world.
Information Hiding**
-
If an object already exists (perhaps written by another software developer), you can use that object in your program.
Code re-use
-
If a particular object turns out to be problematic, you can simply remove it from your application and plug in a different object as its replacement.
Pluggability and debugging ease
-
A block of code in an application which can be written, compiled, and maintained independently of the rest of the code in the application.
Module**
-
Reducing the interdependency of objects in an application to make the application more flexible and to enable modifying an object without affecting other objects in the application.
Loose Coupling
-
When an object needs to perform a certain task, but instead of doing that task directly it "asks" another object to handle the task, or sometimes just part of the task.
Delegation
-
Hiding the internal state of an object and requiring all interaction to be performed through an objects methods. (Note: the answer is not Data Hiding)
Encapsulation**
-
What is the Structured or Classical paradigm approach to software engineering that was primarily used from 1975 to 1985.
- 1. Structured Systesm Analysis
- 2. Data Flow Analysis
- 3. Structured Programming
- 4. Structured Testing
-
What are the six steps in the Unified Process of Software Engineering developed by Booch, Jacobson, and Rumbaugh?
- 1. Requirements workflow
- 2. Object-oriented analysis workflow
- 3. Object-oriented design workflow
- 4. Object-oriented implementation workflow
- 5. Post-delivery maintenance
- 6. Retirement
-
What are the "three easy steps" to developing great software?
- 1. Great software must satisfy the customer. Make sure the software does what the customer wants it to do.
- 2. Great software is well-designed, well-coded, and easy to extend. Apply basic OO principles to add flexibility.
- 3. Great software can be reused. Strive for a maintainable, reusable design.
-
Given one of the eight Design Principles discussed in class be able to briefly explain what it means relative to object oriented software design.
- 1. Identify the aspects of your application that vary and separate them from what stays the same.
- 2. Program to an interface, not an implementation.
- 3. Favor composition over inheritance.
- 4. Strive for loosely coupled designs between objects that interact.
- 5. Classes should be open for extension, but closed for modification.
- 6. Depend on abstractions. Do not depend on concrete classes.
- 7. Principle of Least Knowledge – talk only to your immediate friends.
- 8. A class should have only one reason to change.
-
An expression of desired behavior for a software system. It is specific thing your system has to do to work correctly.
Requirement**
-
What are the four steps which should be followed in determining the requirements of a system?
- 1. Elicitation – Find out what the requirements are.
- 2. Analysis – Make sure you understand the requirements.
- 3. Specification – Clearly state the requirements.
- 4. Validation – Make sure they are correct.
-
Determining a set of components (objects, classes, etc.) and interfaces between those components in a software system that will satisfy the requirements and solve the problem.
Object Oriented Design*
-
The Unified Modeling Language (UML) consists of what three parts?
- 1. The basic building blocks
- 2. Rules controlling how the blocks are put together
- 3. Common mechanisms that apply throughout the language
-
What are the three types of building blocks (one of the three parts) that make up the Unified Modeling Language (UML)?
- 1. Things
- 2. Relationships
- 3. Diagrams
-
What are the four types of things (one of the three types of building blocks) that make up the Unified Modeling Language (UML)?
- 1. Structural Things
- 2. Behavior Things
- 3. Grouping Things
- 4. Annotation Things
-
What are the four types of Relationships?
- 1. Dependency
- 2. Association
- 3. Generalization
- 3. Realization
-
A semantic relationship in which a change on one thing (the independent thing) may cause changes in the other thing (the dependent thing).
Dependency
-
A structural relationship describing links between objects. May also include labels to indicate number and role of the links.
Association
-
A specialization relationship. Simply put this describes the relationship of a parent class to its subclasses.
Generalization
-
Defines a relationship in which one class specifies something that another class will perform.
Realization
-
Draw the Structural thing in UML: Class
-
Draw the Structural thing in UML: Interface**
-
Draw the Structural thing in UML: Collaboration
-
Draw the Structural thing in UML: Use Case
-
Draw the Structural thing in UML: Active Class
-
Draw the Structural thing in UML: Component
-
Draw the Structural thing in UML: Node
-
Draw the Behavior thing in UML: Interaction
-
Draw the Behavioral thing in UML: State Machine
-
Draw the Grouping thing in UML: Package
-
Draw the Annotational thing in UML: Node
-
Show how you would define an enumerated data type called RoyalCards with 4 values, JACK, QUEEN, KING, and ACE with each set to corresponding values, i.e. 11, 12, 13, and 14.
enum RoyalCards{JACK=11, QUEEN, KING, ACE};
-
What are the three places in memory where variables and instances of structs and classes can be allocated?
Stack, Heap, and Microprocessor
-
Give examples of variables declarations that would be allocated in each of the three location.
int gVal;
void someTestFunction(int x, double y) {
double d;
static float f;
int *iptr;
iptr = new int();
}
register int rx;
- int gVal; = Heap
- void someTestFunction(int x, double y) { = Stack
- double d; = Stack
- static float f; = Heap
- int *iptr; = Stack
- iptr = new int(); = Heap
- }
- register int rx; = Microprocessor
-
Refers to where a variable can be accessed in
a program.
Scope
-
A specifier used to specify access to a global variable in one source file when the actual global variable is defined in another source file.
Extern
-
A variable defined this way will be allocated on the heap.
Static
-
Identifying, at run time, the sub-class type of an object given only a parent class pointer or reference to the object.
RTTI**
-
Given an int variable (int iCount) show how you would declare a reference variable called iRef and set it to reference iCount.
int &iRef = iCount;
-
Show the proper C++ type casting syntax in each of the following cases. Note this is NOT the simple C type-casting such as int c = (int)(‘A’);
1) Cast ‘A’ to 65 (ASCII value of ‘A’): int x = ____________
2) Cast int x = 0 to long pointer: long *lpt = ____________
3) Cast const int x to non-constant: int nc ____________
4) Cast cShape *s to cRectangle pointer cRectangle *r = ____________
5) Cast 7.9 to 7 int x = ____________
6) Cast int *iptr (address sotred in iptr) to long; long l = ____________
- 1) int x =static_cast<int>(‘A’);
- 2) long *lpt = reinterpret_cast<long *>x;
- 3) int nc = const_cast<int>x;
- 4) cRectangle *r = dynamic_cast<cRectangle *>(s);
- 5) int x = static_cast<int>(7.9);
- 6) long l = reinterrupt_cast<long>(iptr);
-
Show how you would define a pointer to a function called fptr when the function it must point to is: int testFunction(double d, char *c). Also show how you would set fptr pointing to testFunction.
- int(*fptr)(double, char *);
- fptr = testFunction;
-
Given the following code, fill in the blank with a line which will test for value being positive using the assert test.
double value, sqRoot; // code to set value
// test for value not negative using assert
_______________
sqRoot = sqrt(value); // If positive proceed
with the calculation
assert(value >= 0);
-
Given the following code, fill in the blank with a line which will test for division by zero using the assert test.
double dividend, divisor, quotient;
// code to set value of dividend and divisor is here
// test for zero divisor using assert
assert ___________________;
// If positive proceedwith the calculation
assert(divisor != 0);
-
Show how you would write a try…catch block in which the value of a char variable, ch, is tested. If it is a digit (‘0’ … ‘9’) throw and int exception, if it is an upper case letter (‘A’ – ‘Z’) throw a char * (character array-string) exception, and for all non-printable characters (ASCII value < 32 or > 127) throw a general exception (…). (Hint: In conditional statements like: if ((ch < 97) || (ch > ‘z’)) you can test both characters and ASCII values, e.g. if ((ch < 97) || (ch >122)) will both be true if ch is not a lower case letter. ‘a’ = ASCII 97 and ‘z’ = ASCII 122)
- try {
- if((ch >= ‘0’) && (ch <= ‘9’)) throw 0;
- else if((ch >= ‘A’) && (ch <= ‘Z’)) throw “opps!”;
- else if((ch < 32) || (ch > 127)) throw;
- }
- catch(int i) { }
- catch(char *) { }
- catch(…) { }
-
List and briefly define three of the five ways discussed in class on controlling access to shared resources in threads.
- 1. Semaphores
- 2. Mutexes
- 3. Event Objects
- 4. Waitable Timers
- 5. Critical Sections
-
Show two ways of passing a pointer into a function so that the function can change what the pointer is point to, i.e. passing a pointer to a pointer or passing a reference to a pointer.
- Pass a pointer to a pointer (a handle) to the
- function:
- incPointerWithHandle(&iptr);
- Pass a pointer reference to the function:
- incPointerWithReference(iptr);
-
What is a function prototype and why is it needed?
The purpose of a function prototype is to tell the compiler the correct syntax required to call the function.
-
Show how to create an overloaded function in a class.
- bool MyList::insert(Node *newNode);
- bool MyList::insert(list of args giving data to insert into a new Node);
-
Explain what default arguments to functions are and show how you would declare default values for arguments to a function.
void someFunction(int x=0, double d=1.0, char c=’a’, long l = 1);
-
What are virtual functions? Why is it best to make a function in a parent class virtual so that sub-classes have to implement it, i.e. explain early vs. late binding.
- Early / Static / Compile time binding
- Late / Dynamic / Run time binding
-
A section of code (usually one or more functions) in a program that is running independently of the rest of the program. Threading is a type of multi-tasking, and there are two types: Process based and Thread based.
Threads
-
If a function in a parent class is labeled this, all subclasses are forced to override and implement their own version of that function.
Virtual
-
A system that allows a software designer to graphically layout and model a software application.
UML
-
The process of creating the design by starting at a high level of abstraction and iteratively working down to more detail.
Step-Wise Refinement
-
The process of studying and analyzing what the customer wants in order to develop a stated list of requirements.
Requirement Analysis
-
Flags if a resource is being used.
Semaphores
-
Works like a token in a token ring network.
Mutexes
-
A way for threads to communicate between themselves.
Event objects
-
Another way for threads to communicate or time events.
Waitable timers
-
Provides synchronization similar to mutex.
Critical Sections
-
List two to four ways of referring to the relationship between a subclass and its' parent class.
- 1) A-Kind-Of
- 2) Is-A
- 3) Part-Of
- 4) Has-A
|
|