System Design and Layered Architectures Flashcards

1
Q

Microservices

A

It’s a small, independent, and self-contained unit of functionality inside of a larger application. They communicate via RESTful API’s.

An example microservice is an order download feature on an order website.

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

Function as a service (FaaS)

A

This is a small, self-contained piece of code that does a very specific task. Can be triggered by an event. It can also be run by the cloud. Scaling can be automatic. Only pay for the compute time your functions use.

FaaS can be built out into microservices.

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

Stateless

A

When a service doesn’t have or use any information from previous interactions.

Example: Azure cloud services, HTTP

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

Stateful

A

When a service does have or use any information from previous interactions.

Example: data storage, online banking

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

Monolithic Architecture

A

This is when one code base performs multiple business functions. Components are tightly coupled and interdependent. The application is deployed as a single unit.

Example: WeChat

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

Service-oriented Architecture (SOA)

A

This is when applications are assembled as a collection of loosely coupled components that provided services to each other. Services can be used in different applications. They can communicate with each other regardless of the underlying platform or technology. They have clear and standardised interfaces, and can be self-contained and deployed and managed independently.

Example: e-commerce, travel cooking systems, healthcare systems

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

Event-driven Architecture

A

This is when applications communicate by producing and consuming events. An event is a change in state, or an update, like an item being put in a shopping cart on an e-commerce website.

Event Producers: Applications that generate events, such as a shopping cart.
Event Consumers: Applications that subscribe to events and react to them, such as a recommendation system reacting to an item added to a cart.
Event Router/Broker: this routes events from producers to consumers, such as a messaging queue or a more complicated event mesh.

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

Layered Architecture

A

This is when applications are organised into a hierarchy of layers. Each layer handles a distinct part of the application’s functionality, hides complexity of lower layers, and are in a top-down fashion.

Here are some common layers:
1. User Interface (UI) (i.e. shopping cart)
2. Application Layer (Business Logic) (i.e. order processing)
3. Data Access Layer (i.e. DB for orders)
4. Infrastructure Layer (i.e. logging, security, and support services)

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

SOLID Principles

A

These are five design principles to make object-oriented programming more readable, flexible, and maintainable.

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

Single Responsibility Principle

A

There should never be more than one reason for a class to change. Each class should only have one responsibility.

This makes classes easier to understand and modify, write unit tests with more focus, and reduces the impact of changing the class responsibility.

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

Open-closed Principle

A

Software entities should be open for extension, but closed for modification.

Extension: adding new features without modifying existing code. This includes overriding existing functions.
Modification: changing existing function.

This reduces the risks of bugs when making changes, and adapts to changing requirements better.

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

Liskov Substitution Principle

A

Functions that use pointers or references to base classes must be able to use objects of derived classes without knowing it.

This ensures polymorphic behaviour, that subclasses adhere to superclass parameters, and that replacing a superclass object with a subclass object won’t break the programme.

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

Interface Segregation Principle

A

Clients shouldn’t be forced to depend upon interfaces that they don’t use.

This decouples classes, making the code more modular and maintainable, allows for more flexible implementations of interfaces, and avoid unnecessary dependencies.

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

Dependency Inversion Principle

A

Depend upon abstractions, not concretes.

This results in loose coupling, more flexibility, and better maintainability.

High-level modules shouldn’t import anything from low-level modules. The two should depend on abstractions, such as interfaces.

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

ACID Properties

A

These are four properties for SQL databases that help preserve data validity despite power failures, error, and other accidents.

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

Atomicity (ACID)

A

Each transaction, often composed of multiple statements, are treated as single units, which fail or succeed completely.

17
Q

Consistency (ACID)

A

A transaction can only bring the database from one consistent state to another. Any data written to the database must be valid according to the rules. This prevents the database from corruption by an illegal transaction.

18
Q

Isolation (ACID)

A

Each transaction is executed concurrently. This ensures that such an execution leaves the database in the same state it would’ve been had it been executed sequentially.

19
Q

Durability (ACID)

A

Once a transaction is committed, it’ll remain committed even in the case of a system failure.

20
Q

CAP Theorem

A

Any distributed data store can only guarantee two of the three principles:

Consistency: every read receives the most recent write or an error.
Availability: every request from a non-failing node in the system must lead to a response.
Partition Tolerance: the system continues to function despite an arbitrary number of messages being dropped/delayed by the network between nodes.

21
Q

BASE Principles

A

NoSQL databases have the following properties.

Basic Availability: the system operates even with some node failures.
Soft State: data may not be immediately consistent across all nodes.
Eventual Consistency: data will eventually become consistent across all nodes.

22
Q

RESTful API

A

It’s an application programming interface (API) that uses HTTP requests to get data and that adheres to the REST (Representational State Transfer) architectural style, which have the following principles.

  1. Client-Server Architecture: the client (application requesting data) and the server (application providing data) are separate entities.
  2. Statelessness: each request from the client to the server must have all relevant information to process the request, as the server doesn’t store any information about previous requests.
  3. Cacheability: responses from the server can be cached by the client to improve performance.
  4. Uniform Interface: the API has a consistent way for clients to interact with the resources.
  5. Layered System: the API can be built with multiple layers of servers, such as load balancers and proxies, that don’t affect client interaction with the API.
23
Q

GraphQL

A

This is a query language and runtime for API’s that has a more efficient and flexible way for clients to interact with data as opposed to RESTful API’s. Here are some key concepts.

  1. Schema: a core component defining the structure and types of data available in the API. It’s the contract between the client and the API.
  2. Queries: used to request data from the server.
  3. Mutations: used to change data on the server.
  4. Resolvers: functions on the server that retrieve the data for each field in the schema.
24
Q

Data Access Object (DAO)

A

It has commands and logic for accessing and interacting with the database. It separates two parts of an application that don’t need to know about each other. Make adjust to business logic changes easier.