Introduction to Design Patterns Flashcards
Software design pattern
A general reusable solution to a commonly occurring problem within a given context in software design
Algorithm strategy patterns
High-level strategies describing how to exploit application characteristics on a computing platform
Computational design pattern
Key computation identification
Reader
Used to read from the keyboard or from disk files or other media, or to obtain information over the net
StringTokenizer
To separate a larger string into different token
BufferedReader
- Read a lot of characters at once
2. Provide any other reader with the ability to buffer its input
Java Input
- Java uses a set of classes called readers to read text from files
- Store in ASCII, but later replaced by Unicode form
Strategy Pattern
- Layout objects in the Java AWT implements a strategy pattern
- To factor out variables that might be a set of problems and build an interface for that. Then write solutions in terms of the interface
Decorator Pattern
- A set of objects defined by an interface.
- Java I/O classes are mostly decorators
- A bufferedReader is just a decorator for a reader
Composite Pattern
- To have a container that implements an interface and it contains objects that also implement the same interface
- Java AWT Panel is built with the composite pattern
Panel
- A component, but it also contains component
2. A container that contains things that implement the same interfaces
Iterator Pattern
An iterator is used to traverse a container and access the container’s element
Model-View-Controller
- A software architectural pattern for implementing user interfaces on computers
- To achieve a clean separation between three components of most any web application
Model (Component)
The application’s behavior in terms of the problem domain, independent of the user interface
View (Component)
Any output representation of information, such as a chart or a diagram. Multiple view of the same information are possible, such as a bar chart for management and a tabular view for accountants
Controller (Component)
Accepts input and converts it to commands for the model or view
Model (Interactions)
Stores data that is retrieved according to commands from the controller and displayed in the view
View (Interactions)
Generates new output to the user based on changes in the model
Controller (Interactions)
Send commands to the model to update the model’s state. It can also send commands to its associated view to change the view’s presentation of the model
Simultaneous development
Because MVC decouples the various components of an application, developers are able to work in parallel on different components without impacting and/or blocking one another
Code reuse
By creating components that are independent, developers are able to reuse components quickly and easily in other applications
MVC (Advantage)
- Separation of concerns in the codebase
- Developer specialization and focus
- Parallel development by separate teams