1: Fundamentals of Programming Flashcards
Encapsulation
Ensuring that atributes can only be accessed using methods, that are contained in the class definition
Inheritance
Creating a subclass, which inherits the atributes and methods of the original class
Aggregation
It defines a one-way ‘has-a’ relationship between two classes, where each class can exist separately
Composition
It defines a one-way ‘is-part-of’ relationship between two classes, where the second object cannot exist separately
Polymorphism
Where a method exhibits different behaviours depending on the object on which the method is invoked
Overriding
When a subclass has a different implementation for a method to the base class
Class Diagrams (6)
- Inheritance: Arrow
- Composition: Black diamond line
- Aggregation: White diamond line
- Public specifier: +
- Private specifier: -
- Protected specifier: #
Subroutines + (5)
- Make programs shorter
- Can be tested separately
- Allow for decomposition of large programs
- Make code reusable
- Can be used in other programs
Local Variables + (5)
- Memory allocated to local variables can be reused when subroutine not in use
- Local variable only exists while the subroutine is executing
- Using local variables makes subroutines self-contained
- Prevents accidental changes
- Easier debugging
Variables vs Constants
The value assigned to a variable can changed whereas it cannot for a constant
Named Constants + (2)
- Using constants instead of literals in code means that a change to a value only needs to be done once
- It also makes code easier to understand
Structured Programming + (5)
- Easier to debug
- Subroutines can be called many times
- Subroutines can manipulate shared data
- Subroutines can be used in other programs
- Large programs can be worked on by multiple programmers
Object-Oriented Paradigm + (3)
- Classes support code re-use
- Classes are easy to update
- Encapsulation provides data protection