1/22
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
abstraction
hiding implementation details while exposing only essential features
Encapsulation
protects object integrity by controlling access to data
Tight coupling
class depends on specific methods or fields of another class
Low coupling
minimizes dependencies between classes, making changes in one class less liley to impact others
abstraction and encapulsation how they related and different
They are related in a way that encapsulation helps achieve abstraction.
They are different in the sense that abstraction focuses on hiding complexity of the system and encapsulation focusses on specifically restricting access to data or methods in a clas
Private keyword
demonstrates encapsulation. Encapsulation restricts direct access to the internal state of an object and only allows controlled access through public methods (deposit, withdraw, getBalance).
high cohesion
High cohesion because the class only deals with balance (focused on one responsibility).
This
keyword used to indicate the current object's members
protected
accessible to subclasses or classes in the same
Package
super
a reference variable that points to the parent class object. It is used in a subclass to access member
Liskov Substitution Principle
Violated when a subclass modifies behavior in a way that contradicts the expectations sets by its parent class
Composition over inheritance improve software design
it allows code to be more flexible by favoring delegation over hierarchy
SRP violation
Class has more than one reason to change such as
generating invoices, printing, and sending them
Model in MVC controller
stores the application's data
Inheritance vs compositiobn
composition main class has subclass. so car has engine
class Car { public Engine engine;
Car(Engine engine){ this.engine = engine; }
void drive(){ System.out.println("Car is driving..."); }}
DIP
high level modules should not depend on low level modules.
for example,
The Computer class directly depends on the concrete Keyboard class.
class Computer {
private Keyboard keyboard;
Computer(Keyboard keyboard){this.keyboard = keyboard;}
void use() { keyboard.type(); }
}
Interface Segregation Principle
a class should not be forced to implement interfaces it doesn't need to
Open/Closed Principle
a class should be open for extension butclosed for modification
Dependency Inversion Principle
objects should depend on abstractions instead of concrete implementations
Abstract data types
Definition: A collection of well-defined behaviors, irrespective of implementation details• Examples: Lists, maps, sets, stacks, queues
Model-View-Controller
a pattern which supports separation
of concerns for applications with user interfaces.
View
Allows users to input data and displays new data from the
model
Controller
Connects the view and model by receiving user
inputs, processing data, updating the data in the model, then
triggering a refresh of the view.