Software Architecture and Design Patterns Flashcards
(20 cards)
What are design patterns?
Reusable solutions to common coding problems (like blueprints for software).
Why use design patterns?
- Save time 2. Improve team communication 3. Make code easier to maintain.
What are creational patterns?
Patterns for creating objects (e.g., Singleton, Factory).
What does the Singleton pattern do?
Ensures only ONE instance of a class exists (e.g., a settings manager).
How is a Singleton implemented?
- Private constructor 2. Static instance 3. getInstance() method.
What are structural patterns?
Patterns for organizing classes/objects (e.g., Adapter, Decorator).
What are behavioral patterns?
Patterns for object communication (e.g., Observer, Strategy).
What is MVC?
Model-View-Controller: splits app into data (Model), UI (View), and logic (Controller).
What does the Model do in MVC?
Manages data (e.g., bank account balances, product inventory).
What does the View do in MVC?
Displays data to users (e.g., balance screen, product catalog).
What does the Controller do in MVC?
Handles user input and updates Model/View (e.g., processes payments).
Why separate Model/View/Controller?
Easier to update one part without breaking others (e.g., change UI without touching data logic).
How does MVC help testing?
Each part can be tested alone (e.g., test Model math without UI).
What’s the flow in MVC?
User → Controller → Model → View → User (like a loop).
What should NEVER talk directly in MVC?
View and Model (Controller must mediate all communication).
How to spot MVC in code?
Look for classes named *Model, *View, *Controller (e.g., CartModel, CartView).
What’s a passive View?
View only shows data - no logic (Controller tells it what to display).
What’s the Singleton’s global access point?
getInstance() method (always returns the same object).
When to use MVC?
For complex apps needing clean separation (e.g., banking, e-commerce).
What’s the key MVC rule?
Controller owns the flow; Model and View are ‘dumb’ workers.