CPSC 3200 Object-Oriented Development Midterm Review
Highly recommend review of material covered in class and book as well as P1, P2 and P3
Midterm logisitics
The exam will be online during the scheduled Zoom class period, 1230 – 155pm
It is set up as an Assignment that requires a file upload
A Word document containing the exam will be released at the beginning of class
You should download this document and type your answers directly into your copy
You may use more than one page per question, if needed
Students will be placed in individuals breakout rooms
If you have a question at any time during the exam, send me a message
You must submit (upload) your completed document by the end of class
If you experience technical difficulties, you must contact me via Zoom or email BEFORE the exam end.
Consultation of Canvas course materials, the textbook, personal notes and PAs is permitted
Consultation of other online sources or other individuals is not permitted
Professor Dingle makes up new problems for each exam
It is highly recommended that time is not wasted trying to look up solutions online
The exam must be submitted via Canvas by the exam end time.
If you previously made special arrangements for testing (DS or different time zone), you will receive a confirmation email from me to which you must reply
ACADEMIC INTEGRITY:
You are bound by the honor system, as stated on the syllabus.
It is unlikely that you will find answers to the questions online.
Remember the explicitly stated expectation that you do not confer with anyone else, using only the permissible resources described in #2 and 3 under midterm logistics.
Exams will be thoroughly checked for collaboration.
I reserve the right to give an incomplete and request additional testing if exam submissions appear compromised.
Plagiarism or collusion will be considered and treated as an academic integrity violation. .
Types of midterm questions
Analysis: given C++ and/or C# code snippets
evaluate, and possibly alter, with respect to stated criteria
convert sample code from one language to the other
Code Construction: in C# or C++ — language will be specified or choice left open
IF language specified, code in that language
IF given choice of language for implementation, document which language used
sketch design solution to given problems, providing level of detail requested
NO need to import/include libraries, use namespaces, etc.
NO use of generics (STL, Collections) permitted
Do not use vectors, lists, Array types, etc
May use sort, swap, if needed – no other built in functions
Comparative Evaluation: given defined OO principles, relationships and/or design guidelines
assess how the defined design constructs, relationships, or principles differ, overlap,…
OO principles and design guidelines do not need to be memorized.
Idea is to demonstrate an understanding of the OO concepts addressed
e.g OCP (Open Closed Principle) emphasizes that classes should be open for extension but closed to modification.
Dependency Injection shifts responsibility for resource acquisition to the client.
How do these two approaches overlap and/or conflict?
Topics NOT covered on midterm
Programming by Contract
Unit Testing
C# cloning
Smart pointers
Function pointers
Virtual function table (vtab)
REMEMBER TIME CONSTRAINT: DO NOT comment extensively or give detailed I/O
Topics covered on midterm
C# and C++ basic coding constructs (including object allocation and binding)
Differences & Similarities
Class Design: ADT + encapsulation
Information hiding: private data => set/get carefully designed
Control over state
e.g. constructors initialize state, removing dependency on client
conditional set functions filter values & possibly revert to default, etc.
Memory management in C++ and C# — Power + Responsibility + Efficiency vs. Ease of Use
Stack versus heap memory
Ownership
Copying: shallow vs deep
C++: copy constructor, destructor, overloaded=
C++ Move semantics
(Data corruption, Memory leaks)
Holds-a, Has-a, Is-a: structure of each relationship
Costs & Benefits
Cardinality, Association, Ownership, Lifetime
Dependency Injection — Constructor, Method, Property
Subtype Polymorphism — Heterogeneous collections, Isolation of object construction code
Implementation Details Covered on Midterm – C# and C++:
Variable manipulation – note differences between C++ and C#
Objects (non-primitives) manipulated as references in C#
vs. C++ objects (stack or heap allocation)
No pointer construct for C# programmer, unless in unsafe mode
Variable declaration: know what MyObj x; means in C# and in C++
Differences in array allocation and initialization
Memory deallocation
C++ heap deallocation must be explicitly requested by programmer — delete
C++ classes with dynamically allocated memory must define
Copy constructor, Destructor, Overloaded assignment operator
Move semantics
Composition – control over internal state, state transitions
Dependency Injection
Inheritance
Substitutability: child can stand in for parent but not vice-versa
C++ slicing
C++ can suppress base class functionality by declaring inherited methods private
C++ and C# may NOP overridden inherited methods
Polymorphism — default binding is static in C++ and C#
Run-time binding in C++ requires
Function declared virtual in base class (& overridden in derived classes)
Client invokes virtual function through base class pointer
Run-time binding in C# requires
Function declared virtual in base class (&override in derived classes)
Flexibility in C++ yields more power and, potentially, more confusion