Introduction to Design Patterns Flashcards

1
Q

Software design pattern

A

A general reusable solution to a commonly occurring problem within a given context in software design

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Algorithm strategy patterns

A

High-level strategies describing how to exploit application characteristics on a computing platform

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Computational design pattern

A

Key computation identification

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Reader

A

Used to read from the keyboard or from disk files or other media, or to obtain information over the net

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

StringTokenizer

A

To separate a larger string into different token

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

BufferedReader

A
  1. Read a lot of characters at once

2. Provide any other reader with the ability to buffer its input

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Java Input

A
  1. Java uses a set of classes called readers to read text from files
  2. Store in ASCII, but later replaced by Unicode form
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Strategy Pattern

A
  1. Layout objects in the Java AWT implements a strategy pattern
  2. 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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Decorator Pattern

A
  1. A set of objects defined by an interface.
  2. Java I/O classes are mostly decorators
  3. A bufferedReader is just a decorator for a reader
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Composite Pattern

A
  1. To have a container that implements an interface and it contains objects that also implement the same interface
  2. Java AWT Panel is built with the composite pattern
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Panel

A
  1. A component, but it also contains component

2. A container that contains things that implement the same interfaces

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Iterator Pattern

A

An iterator is used to traverse a container and access the container’s element

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Model-View-Controller

A
  1. A software architectural pattern for implementing user interfaces on computers
  2. To achieve a clean separation between three components of most any web application
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Model (Component)

A

The application’s behavior in terms of the problem domain, independent of the user interface

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

View (Component)

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Controller (Component)

A

Accepts input and converts it to commands for the model or view

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Model (Interactions)

A

Stores data that is retrieved according to commands from the controller and displayed in the view

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

View (Interactions)

A

Generates new output to the user based on changes in the model

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

Controller (Interactions)

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

Simultaneous development

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

Code reuse

A

By creating components that are independent, developers are able to reuse components quickly and easily in other applications

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

MVC (Advantage)

A
  1. Separation of concerns in the codebase
  2. Developer specialization and focus
  3. Parallel development by separate teams
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

MVC (Disadvantage)

A

Code navigability

Multi-artifact consistency

Pronounced learning curve

24
Q

Separation of concerns

A
  1. One layer doesn’t care how another layer is implemented

2. Discourages “cut-&-paste” repetition of code, streamlining upgrade & maintenance tasks

25
Developer specialization and focus
Ex: UI developers can focus exclusively on UI, without getting bogged down in business logic rules or code
26
The application's model includes
1. Application state 2. Application rules 3. Persisten data
27
Application state
1. People | 2. Widgets needed by application users (Shopping carts, transcripts, contact information)
28
Persistent data
Long-term storage of data - beyond the scope and time-frame of the user's session in the application
29
View (Detail)
1. Elements of the view 2. View technologies 3. Templating 4. Styling 5. The decorator pattern
30
Elements of the view
1. Core data 2. Business logic widgets 3. Navigation widgets 4. Skin
31
Core data
The subject of a page's business
32
Business logic widgets
Ex: Buttons to perform edit or save
33
Navigation widgets
Ex: Navigation bar, logout button
34
Skin
Standard look of the site: logos, colors, footer, copyright, etc
35
View technologies
Used to render the user interface (UI) in a way that properly and dynamically links it to the application's business-logic and data layer
36
Java server pages (JSPs)
A widely-utilized technology for constructing dynamic web pages. JSPs contain a mix of static markup and JSP-specific coding that references or executes Java. In brief: 1. JSP Tags call compiled Java classes in the course of generating dynamic pages 2. JSP Directives are instructions processed when the JSP is compiled. Directives set page-level instructions, insert data from external files, and specify custom tag libraries 3. Java code - in sections called "scriptlets" - can be included in JSP pages directly, but this practice is strongly discouraged in favor of using JSP Tags
37
JSP tags
call compiled Java classes in the course of generating dynamic pages
38
JSP directives
Instructions processed when the JSP in compiled. Directives set page-level instructions, insert data from external files, and specify custom tag libraries
39
Java code
in sections called "scriptlets" - can be included in JSP pages directly, but this practice is strongly discouraged in favor of using JSP tags
40
XML pipelining
Another technique for rendering the User Interface. Apache's Cocoon and Orbeon's OXF are technologies that use this technique.
41
Templating
Render a consistent header, footer, and navigation UI around the core business content standardizes a site's graphics presence, which tends very strongly toward making users' experience smoother and less prone to error
42
Controller (Detail)
1. Responsibilities of the controller | 2. Controller technologies
43
Responsibilities of the controller
1. Parse a user request 2. Validate the user request 3. Determine what the user is trying to do 4. Obtain data from the Model to include in response to user 5. Select the next view the client should see
44
Controller technologies
1. Structs 2. Java Server Faces 3. WebWork 4. Spring
45
What deployment descriptors do
Deployment descriptor = configuration file Used to configure an application as it starts up in its container. Configuring includes wiring its components together
46
Observer pattern
A software design pattern in which an object, called the subject, maintains a list of its dependents, called observers and notifies them automatically of any state changes, usually by calling one of their methods
47
CSS
used to specify colors, backgrounds, fonts and font-size, block-element alignment, borders, margins, list-item markers, etc.
48
Decorator Pattern (MVC)
Wrapping some core object in something that gives it additional functionality. 1. Core business information in a 2. Template (header + footer + navigation), which includes (in the common HTML header) reference to a CSS stylesheet (where background, colors, fonts, etc)
49
Code navigability
The framework navigation can be complex because it introduces new layers of abstraction and requires users to adapt to the decomposition criteria of MVC.
50
Multi-artifact consistency
Decomposing a feature into three artifacts causes scattering. Thus, requiring developer(s) to maintain the consistency of multiple representations at once.
51
Pronounced learning curve
Knowledge on multiple technologies becomes the norm. Developers using MVC need to be skilled in multiple technologies.
52
What is the essential purpose of the Model-view-controller pattern?
Separate information from how it is presented
53
Which of these are typical relationships among the Model, View, and Controller?
1. Controller tells model to update its data | 2. Model tells view that data has changed
54
Think about the base 4 calculator. Which MVC components(s) does the Base4CalcState (the "actual" calculator) represent?
Model and View
55
A swing component can be part of the View, or part of the Controller, but not both
true