Architecture Patterns Flashcards

1
Q

Can you describe application without layers?

A

For example desktop application. Everything inside 1 file.
When you click button -> SQL starts doing something directly.

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

What 3 the most important layers do you know?

A
  • presentation
  • domain ( business logic)
  • data source
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How to check that your layers are independent from each other?

A

Business logic check:
- Replace interface ( for example from WEB to console) and ask if you need to duplicate domain code?
- Replace data source ( for example from DB to XML file) and ask if you need to change something inside the domain logic

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

What 3 pattern to handle domain layer do you know?

A
  • Transaction Script ( Receive something from the view -> do some procedures -> return the result ) Example: Money transfer
  • Domain Model ( You create many models -> every model has some methods ) Example: Internet Shop Cart
  • Table module ( Organizes domain logic with one class per table in the database, something like singleton)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is Active Record pattern?

A

An object that wraps a row in a database table or view, encapsulates the database access, and adds domain logic on that data.

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

What is Table Data Gateway pattern?

A

An object that acts as a Gateway to a database table. One instance handles all the rows in the table. ( Something like update_all in rails)

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

What are the difference between Row Data Gateway and ActiveRecord?

A

It’s often hard to tell the difference between a Row Data Gateway and an Active Record.The crux of the matter is whether there’s any domain logic present; if there is, you have an Active Record. A Row Data Gateway should contain only database access logic and no domain logic.

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

What is Data Mapper pattern?

A

The Data Mapper is a layer of software that separates the in-memory objects from the database. With the Data Mapper Pattern, the in-memory objects have no idea there is a database, and the database schema is unaware of any objects that use it. This separation is the main purpose of a Data Mapper.
(Something like decorator that accept clear object and gives you active_record methods. Customer and CustomerMapper classes)

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

What is Unit of Work pattern?

A

The Unit of Work pattern is used to group one or more operations (usually database CRUD operations) into a single transaction or “unit of work” so that all operations either pass or fail as one unit. ( Something like our Unit on the project)

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

What is Identity Map pattern?

A

Ensures that each object gets loaded only once by keeping every loaded object in a map (hash/variable). Looks up objects using the map when referring to them. ( Looks like object that we create inside initialize which preload all required db records and then we work with this object through multiply classes)

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

What is Lazy Load pattern?

A

An object that doesn’t contain all of the data you need but knows how to get it.
For example ActiveRecord object doesn’t load all association by default, but can request them if needed.

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

What is Service Stub pattern?

A

Removes dependence upon problematic services during testing. ( the same as stub in rspec)

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

What is Identity Field pattern?

A

Saves a database ID field in an object to maintain identity between an in-memory object and a database row. ( The same as active record id)

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

What is Foreign Key Mapping pattern?

A

Maps an association between objects to a foreign key reference between tables. ( the same as association in rails)

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

What is Dependent Mapping pattern?

A

Has one class perform the database mapping for a child class. ( It’s like dependent destroy or strict foreign key. A separate class where changes to parent class requires to change and child association as well)

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

What is Association Table Mapping pattern?

A

Saves an association as a table with foreign keys to the tables that are linked by the association. ( When you have many to many associations and create ‘through’ table with foreign keys )

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

What is Embedded Value pattern?

A

Maps an object into several fields of another object’s table. ( For example DB has separated filed for amount and currency but you combine them into one on the object level. ( or day/time/year separated)

18
Q

What is Single Table Inheritance pattern?

A

Represents an inheritance hierarchy of classes as a single table that has columns for all the fields of the various classes. ( You use only one table for all related classes)

19
Q

What is Concrete Table Inheritance?

A

Represents an inheritance hierarchy of classes with one table per concrete class in the hierarchy. ( Create a new table for every classes exept abstract with common attributes )

20
Q

What is Class Table Inheritance?

A

Represents an inheritance hierarchy of classes with one table for each class.( Create a new table for every classes including abstract with common attributes )

21
Q

What is Metadata Mapping pattern?

A

Holds details of object-relational mapping in metadata. [to be updated]

22
Q

What is Query Object pattern?

A

An object that represents a database query. ( As queries on the smart project)

23
Q

What is Serialized LOB pattern?

A

Saves a graph of objects by serializing them into a single large object (LOB), which it stores in a database field. ( it’s like create a big object and save it to the json DB table)

24
Q

What is Repository pattern?

A

Mediates between the domain and data mapping layers using a collection-like interface for accessing domain objects.

25
Q

What is Registry pattern?

A

A well-known object that other objects can use to find common objects and services. [To be updated]

26
Q

What is Application Controller pattern?

A

A centralized point for handling screen navigation and the flow of an application. ( looks like controller in rails )

27
Q

What is Input Controller?

A

Something like routing and middleware to handle request. ( take request, get data and call domain logic)

28
Q

What is Transform View pattern?

A

A view that processes domain data element by element and transforms it into HTML. ( Something like representer to build HTML)

29
Q

What is Template View?

A

Renders information into HTML by embedding markers in an HTML page. ( The same as ERB)

30
Q

What is Two Step View pattern?

A

Turns domain data into HTML in two steps: first by forming some kind of logical page, then rendering the logical page into HTML. ( for example create XML at the first step and then transform to HTML)

31
Q

What is Page Controller?

A

An object that handles a request for a specific page or action on a Web site. ( the same as rails)

32
Q

What is Front Controller?

A

A controller that handles all requests for a Web site. ( the same as application controller)

33
Q

Wha is lost update problem? ( Concurrency)

A

When 2 people update the same party together and only the second changes were saved.

34
Q

What is Layer Supertype?

A

A type that acts as the supertype for all types in its layer. ( For example common methods that you age going to reuse in other classes)

35
Q

What is Optimistic Offline Lock?

A

Prevents conflicts between concurrent business transactions by detecting a conflict and rolling back the transaction.( is it just optimistic lock?) User still can read data which other user tries to update.

36
Q

What is Pessimistic Offline Lock?

A

Prevents conflicts between concurrent business transactions by allowing only one business transaction at a time to access data.

37
Q

What is Coarse-Grained Lock?

A

Locks a set of related objects with a single lock. A Coarse-Grained Lock is a single lock that covers many objects.

38
Q

What is Implicit Lock?

A

Allows framework or layer supertype code to acquire offline locks. ( Application will decide pessimistic or optimistic lock to use)

39
Q

What is Client Session State?

A

Stores session state on the client.

40
Q

What is Server Session State?

A

Keeps the session state on a server system in a serialized form

41
Q

What is Database Session State?

A

Stores session data as committed data in the database.

42
Q

What is Money pattern?

A

Represents a monetary value. ( the same as money gem)