Midterm Superdeck Flashcards
What is procedural programming?
Methods/functions calling each other.
Downside of procedural programming?
It can become unmanageable/harder to manage as they become larger.
How does OOP handle complexity?
Decomposition. Design objects to contain data and related behaviors.
Benefits of OOP?
Maintainability and extensibility.
What is a class.
A blueprint or instruction on how to make an object.
What is an object.
An instance of a class that has been created.
What is a field?
An attribute. Data relevant to the systems purpose.
What is an entity?
Models a real “thing”.
What is a container?
A data structure to hold entities.
What is an interface?
Communicates with the “outside world”.
What is a control object?
Organizes computation.
I.e. The main program.
Types of entitites?
Concrete objects. People, buildings, etc.
Conceptual objects. Organizations, agreements, etc.
Event and state-change objects. I.e. purchase, sale, birth.
Types of methods.
Accessors/getters.
Mutators/setters.
Hybrid. Access and mutate, but this is discouraged.
5 stages to software development.
Requirements.
Design.
Implementation.
System testing and verification.
Maintenance.
UMLs describe…
What it does, not how.
What is a primary actor?
Triggers a use case to happen.
What is a supporting actor?
Indirectly involved with a use case. I.e. A user (primary actor) tries to withdraw money. The bank (supporting actor) verifies there’s enough money.
Extends. (non-class uml)
Base use case may conditionally execute the associated use case. Dashed line, solid arrow, «extend» in the middle
Include.
The base case will always execute the associated use case. Dashed line, solid arrow, «include» in the middle.
Generalization. (non-class uml)
A child use case inherits from parent. Solid line, hollow arrow, from child to parent.
Visibility symbols in UML.
+ public
- private
# protected
Class UML inheritance.
Solid line, hollow arrow, child to parent.
Class UML generalization.
Dashed line, hollow arrow, “child to parent”. “Class B implements A”.
Class UML association.
A and B call eachother.
Solid line.
Class UML one way association.
B can call A. Arrow from B to A, solid line, arrow is not complete triangle.
Class UML reflexive association.
A class may have multiple functions or responsibilities. A smaller box in the lower right underneath.
Aggregation.
A contains B, B can survive if A is deleted. Solid line from B to A. Hollow diamond.
Composition.
A contains B. B cannot exist without A. Solid line from B to A. Filled diamond.
When are multiplicities used in class UML?
For association, aggregation, composition.
I.e. 1 teacher may call at least 1 student ( 1..* ).
A classroom (1) holds at least one student (1..*).
Encapsulation.
Group related variables and functions. Reduce complexibility and increase reusability.
Abstraction.
Hide details and show the essentials. Isolate impacts of change.
Inheritance benefit.
Eliminate redundant code.
Polymorphism.
Refactor ugly if and switch/case statements.
What is the substitution principle?
You can always use a subclass object when a superclass object is expected.
I.e. Cat is an Animal, so if you ask for an Animal, I can give you a Cat.
What is dynamic method lookup?
Methods called are from the actual objects, not the variable type. I.e. You have a bunch of Animals, and you want them to make noises. Calling something like “makeNoise()” on each animal checks the actual object, so you might get a Cat, a Dog, a Bird making different noises, even though the variable type is just Animal.
What is an interface made for?
To group related methods with empty bodies, deferring implementation to subclasses. Something that implements an interface must implement it’s methods. This way, if you know an object implements an interface, you know what functions it will have from that.
What is an abstract class?
Cannot be instantiated. However, its subclasses can. I think this means we could have an abstract “Animal” class, since you don’t want to have general “Animals”, but you can have “Cats” or “Dogs” that inherit from it and can be instantiated.
What is static typing?
Expressions are checked at compile time. Code must be fixed before it can be ran.
Illegal expression - Compile-time error
What is dynamic typing?
Expressions are checked at run time.
You can run the program, but it may crash.
Illegal expression - Run-time error
Java. main function syntax.
public static void main(String[] args)
What are Java’s numeric types similar to?
Very similar to C/C++.
What are Strings in java?
A class, not a primitive.