Architecture Flashcards
coupling vs cohesion
If we have a number of Java classes, coupling describes the relationship between those classes, while
cohesion describes the relationships between the methods inside each one.
advice on what makes good code
- Say what you mean, mean what you say
A common mistake with method naming is to describe how it works internally, instead of describing what the outcome is. - Take care of the details in private
- Avoid accidental complexity
TDD approch
Red — think about what you want to develop
Green — think about how to make your tests pass
Refactor — think about how to improve your existing implementation
Protocol Buffers (Protobuf):
- Protobuf is a method for serializing structured data, and it’s language-agnostic.
- It provides a way to define data structures and then generate code in various programming languages to read and write data in those structures.
- Protobuf is often used for data interchange between systems, configuration files, and for storing structured data. It’s efficient, compact, and easier to maintain than hand-written data serialization code.
- Protobuf files use a .proto extension and contain the data structure definitions.
gRPC
- gRPC is a high-performance, language-agnostic remote procedure call (RPC) framework that uses Protobuf for data serialization.
- It allows you to define the structure of your service methods and message types using Protobuf.
- gRPC supports multiple programming languages and enables efficient communication between distributed systems.
- It uses HTTP/2 as the transport protocol, which offers features like multiplexing, flow control, and header compression.
Scaling
Vertical scaling, referred to as “scale up”, means the process of adding more power (CPU, RAM, etc.) to your servers
* Vertical scaling has a hard limit. It is impossible to add unlimited CPU and memory to a
single server.
* Vertical scaling does not have failover and redundancy. If one server goes down, the
website/app goes down with it completely.
Horizontal scaling, referred to as “scale-out”, allows you to scale by adding more servers into your pool of resources.
Advantages of database replication:
- Better performance: In the master-slave model, all writes and updates happen in master nodes; whereas, read operations are distributed across slave nodes. This model improves performance because it allows more queries to be processed in parallel.
- Reliability: If one of your database servers is destroyed by a natural disaster, such as a typhoon or an earthquake, data is still preserved. You do not need to worry about data loss because data is replicated across multiple locations.
- High availability: By replicating data across different locations, your website remains in operation even if a database is offline as you can access data stored in another database server.
Cache Consideration:
What is throttling?
Throttling is a process of limiting the amount of data that can be transferred between two systems in a given period of time. This is often done to prevent one system from overloading another system with too much data, or to prevent one user from consuming too much of a shared resource.
What Is Aspect-Oriented Programming (AOP)?
Aspects enable the modularization of cross-cutting concerns such as transaction management that span multiple types and objects by adding extra behavior to already existing code without modifying affected classes.
What Are Aspect, Advice, Pointcut and JoinPoint in AOP?
Aspect – a class that implements cross-cutting concerns, such as transaction management
Advice – the methods that get executed when a specific JoinPoint with matching Pointcut is reached in the application
Pointcut – a set of regular expressions that are matched with JoinPoint to determine whether Advice needs to be executed or not
JoinPoint – a point during the execution of a program, such as the execution of a method or the handling of an exception
What Is Weaving?
weaving is a process that links aspects with other application types or objects to create an advised object. This can be done at compile time, load time, or runtime. Spring AOP, like other pure Java AOP frameworks, performs weaving at runtime.
Reactive Princples
Responsive – The system should respond in a timely manner.
Resilient – In case the system faces any failure, it should stay responsive.
Elastic – Reactive systems can react to changes and stay responsive under varying workload.
Message-driven – Reactive systems need to establish a boundary between components by relying on asynchronous message passing.