1/18
Flashcards covering the MVC architectural pattern, its benefits, components, and examples, along with Java generics and type parameters.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
MVC Architectural Pattern
A relatively old pattern introduced in the Smalltalk programming language that divides the application into three subsystems: model, view, and controller.
Model
Passive object which stores the data.
View
Renders model into specified format.
Controller
Captures user input and when necessary, issues method calls on the model to modify the stored data.
MVC Architectural Pattern Event Handling
User-generated events may cause a controller to change the model, or view, or both.
Cohesive modules (MVC Benefit)
Instead of putting unrelated code (display and data) in the same module, we separate the functionality so that each module is cohesive.
Flexibility (MVC Benefit)
The model is unaware of the exact nature of the view or controller it is working with. It is simply an observable. This adds flexibility.
Low coupling (MVC Benefit)
Modularity of the design improves the chances that components can be swapped in and out as the user or programmer desires. This also promotes parallel development, easier debugging, and maintenance.
Adaptable modules (MVC Benefit)
Components can be changed with less interference to the rest of the system.
Distributed systems (MVC Benefit)
Since the modules are separated, it is possible that the three subsystems are geographically separated.
Traffic Signal - MVC Component
Detects cars/pedestrians, regulates traffic, uses a timer, and allows manual override.
Java Generic (Before JDK 1.5)
LinkedList collection adds in Integer object and a Double object and valid type casting is required.
Java Generic (JDK 1.5)
Allows programmers to abstract over types, so a collection of objects can be restricted to contain a particular data type. Casting is not necessary because the type has been set to be a specific type.
Java Generic Benefits
Provides one single method to process any class types without a need of overloading or polymorphism.
Type parameter
A placeholder for a specific type, often indicated by a capital letter (E, K, V, T, S).
SquareInt
Integer Square
SquareFloat
Float Square
GenricMethod
genericDisplay
GenricMethod
Output