Chapter 3 - Inheritance, Class Hierarchy, UML, OOP vs Procedural Programming Flashcards
OOP (8)
- divided into objects
- importance is given to data rather than functions because it works with real world objects
- bottom up (design objects then interactions)
- different specifiers are used for different levels of data protection
- data can only move via member functions
- public or private access specifiers are used to control data access
- more secure because of data hiding
- function overloading and overloading operator
procedural programming (8)
- divided into small functions
- importance is given to procedures before data
- top down (design functions first)
- no access specifiers
- data can move freely from function to function
- global data is acceptable and freely accessible
- no particular method for data hiding, so less secure
- overloading is not possible
UML private, public and protected symbol
private: -
public: +
protected: #
UML function syntax
string getName() or getName() string are both acceptable, virtual functions are italicized
UML interfaces
has strictly pure virtual functions, italicized class names, <> (not in italics) above the class name
UML abstract functions
at least one pure virtual function but other functions may be defined, italicized class name
UML inheritance (“is-a”)
white triangle arrowhead facing the parent class, means that every instance of one class is also an instance of the other class but not the other way around
UML inheritance (“has-a”)
filled diamond arrow facing toward the class that “has” the other thing in it, means that every instance of one class is or may be associated with one or more instances of the other
UML inner class
when we define a class within a class, circle with a cross through it with the circle closest to the class that contains the inner class/structure
abstract class
cannot be instantiated (objects cannot be created), declares at least one abstract member function (which must be defined in its derived classes), used when a base class can define attributes and functions that are common to derived classes or when actual derived classes may have unique and shared implementations
abstract function or pure virtual function
virtual function that is declared but for which no body (definition) is provided
form: virtual function-declaration = 0
pure abstract functions
must be defined by derived concrete classes
multiple inheritance
the ability of a class to extend more than one class, all data fields for the derived class are inherited from its base classes, constructors are called in the same order in which they are called form: class Object_Name : public Derived_Class1, public Derived_Class2 { };
refactoring
a better solution than multiple inheritance, the creation of a separate common base class, often used in object-oriented design, sanitizing your code
namespaces
used to group collections of declarations into a fictional unit, nested
form: namespace name {…}