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
Q

Developer specialization and focus

A

Ex: UI developers can focus exclusively on UI, without getting bogged down in business logic rules or code

26
Q

The application’s model includes

A
  1. Application state
  2. Application rules
  3. Persisten data
27
Q

Application state

A
  1. People

2. Widgets needed by application users (Shopping carts, transcripts, contact information)

28
Q

Persistent data

A

Long-term storage of data - beyond the scope and time-frame of the user’s session in the application

29
Q

View (Detail)

A
  1. Elements of the view
  2. View technologies
  3. Templating
  4. Styling
  5. The decorator pattern
30
Q

Elements of the view

A
  1. Core data
  2. Business logic widgets
  3. Navigation widgets
  4. Skin
31
Q

Core data

A

The subject of a page’s business

32
Q

Business logic widgets

A

Ex: Buttons to perform edit or save

33
Q

Navigation widgets

A

Ex: Navigation bar, logout button

34
Q

Skin

A

Standard look of the site: logos, colors, footer, copyright, etc

35
Q

View technologies

A

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
Q

Java server pages (JSPs)

A

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
Q

JSP tags

A

call compiled Java classes in the course of generating dynamic pages

38
Q

JSP directives

A

Instructions processed when the JSP in compiled. Directives set page-level instructions, insert data from external files, and specify custom tag libraries

39
Q

Java code

A

in sections called “scriptlets” - can be included in JSP pages directly, but this practice is strongly discouraged in favor of using JSP tags

40
Q

XML pipelining

A

Another technique for rendering the User Interface. Apache’s Cocoon and Orbeon’s OXF are technologies that use this technique.

41
Q

Templating

A

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
Q

Controller (Detail)

A
  1. Responsibilities of the controller

2. Controller technologies

43
Q

Responsibilities of the controller

A
  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
Q

Controller technologies

A
  1. Structs
  2. Java Server Faces
  3. WebWork
  4. Spring
45
Q

What deployment descriptors do

A

Deployment descriptor = configuration file

Used to configure an application as it starts up in its container. Configuring includes wiring its components together

46
Q

Observer pattern

A

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
Q

CSS

A

used to specify colors, backgrounds, fonts and font-size, block-element alignment, borders, margins, list-item markers, etc.

48
Q

Decorator Pattern (MVC)

A

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
Q

Code navigability

A

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
Q

Multi-artifact consistency

A

Decomposing a feature into three artifacts causes scattering. Thus, requiring developer(s) to maintain the consistency of multiple representations at once.

51
Q

Pronounced learning curve

A

Knowledge on multiple technologies becomes the norm. Developers using MVC need to be skilled in multiple technologies.

52
Q

What is the essential purpose of the Model-view-controller pattern?

A

Separate information from how it is presented

53
Q

Which of these are typical relationships among the Model, View, and Controller?

A
  1. Controller tells model to update its data

2. Model tells view that data has changed

54
Q

Think about the base 4 calculator. Which MVC components(s) does the Base4CalcState (the “actual” calculator) represent?

A

Model and View

55
Q

A swing component can be part of the View, or part of the Controller, but not both

A

true