Activity 2 Demop
Activity 2 Demop
Activity 2 Demop
“Elaborate a report”
PRESENT:
✓ Client-server
✓ Peer to peer network
✓ Model-view-controller (MVC)
✓ Event-oriented architecture (EDA)
✓ Microservices Architecture
Client-server
This type of software architecture pattern refers to the existence of a server that
provides a service to a client (person or company). When the client requests certain
data from the server, the server accepts the process and delivers the data requested
by the client.
Among the advantages of this pattern, it is taken into account that all the
data is in the same place , it requires little maintenance and data recovery is possible.
As disadvantages, clients can be affected by viruses, trojans and phishing .
Additionally, servers are prone to denial-of-service attacks (also known as DoS
attacks), and data can be modified during transmission.
Peer to peer network
Better known as a peer-to-peer network , it is one of the software architectures that
allows sharing a large amount of data. Unlike the client-server model, this consists
of a decentralized network of clients and servers . All parts consume resources,
without the need for a centralized server.
One of its great benefits is that, due to the lack of a central server, costs are lower,
so it can be more economical . On the other hand, as a disadvantage, if one of the
peers is attacked by a virus, the possibility is high that it will carry that same virus
to the rest of the peers connected on the network.
Model-view-controller (MVC)
The MVC pattern is used because it allows you to separate components of a program
based on the responsibility of each one, therefore, if a modification is required to be
made to a specific part of the code, the rest remains intact.
It uses three components: model, view and controller. The model takes care of the
data, whether it is updates, searches or other. The controller receives the client's
orders to subsequently request the data from the model and communicate to the
view, which is the visual representation of the data (graphical interface).
It is also worth clarifying that, when we refer to microservices, we are talking about
small programs (applications) that provide services in order to solve certain tasks.
As a great advantage, the microservices architecture stands out for its encapsulated
components , since they can evolve at the required speed and each microservice
can be developed with different technologies (databases).
Factory Method
Also called: Factory method, Virtual Builder
Purpose
Factory Method is a creational design pattern that provides an interface for creating
objects in a superclass, while allowing subclasses to alter the type of objects to be
created.
Applicability
✓ Use the Factory Method when you do not know in advance the exact
dependencies and types of the objects your code must work with.
✓ Use the Factory Method when you want to offer users of your library or
framework a way to extend its internal components.
✓ Use the Factory Method when you want to save system resources by reusing
existing objects instead of rebuilding them each time.
How to implement it
1. Make all products follow the same interface. This interface should declare
methods that make sense across all products.
2. Add an empty Factory Method pattern inside the creator class. The return
type of the method must match the common interface of the products.
3. Finds all references to product constructors in the code of the creator class.
One by one, replace them with invocations to the Factory Method, while
extracting the product creation code to place it inside the Factory Method.
4. You may need to add a temporary parameter to the Factory Method to control
the type of product returned.
5. At this point, the Factory Method code may look pretty ugly. You might have
a switchlong operator that chooses which product class to instantiate. But
don't worry, we'll fix it right away.
6. Now, create a group of creator subclasses for each product type listed in the
Factory Method. Overrides the Factory Method in subclasses and extracts the
appropriate pieces of constructor code from the base method.
7. If there are too many product types and it doesn't make sense to create
subclasses for all of them, you can reuse the control parameter of the base
class in the subclasses.
Purpose
Singleton is a creational design pattern that allows us to ensure that a class has a
single instance, while providing a global access point to that instance.
Applicability
✓ Use the Singleton pattern when a class in your program should only have one
instance available to all clients; for example, a single database object shared
by different parts of the program.
✓ Use the Singleton pattern when you need tighter control of global variables.
How to implement it
1. Adds a private static field to the class to store the Singleton instance.
2. Declare a public static create method to get the Singleton instance.
3. Implements lazy initialization within the static method. You must create a new
object on your first call and place it inside the static field. The method must
always return that instance in all subsequent calls.
4. Declare the class constructor as private. The static method of the class will
still be able to invoke the constructor, but not the other objects.
5. Goes through the client code and replaces all direct calls to the Singleton
instance's constructor with calls to its static creation method.
Pros and cons
✓ You can be certain that a class has a single instance.
✓ You get a global access point to that instance.
✓ The Singleton object is only initialized when it is first required.
It violates the Single Responsibility Principle. The pattern solves two problems
at the same time.
The Singleton pattern can mask bad design, for example, when program
components know too much about each other.
The pattern requires special treatment in a multi-threaded environment, so
that multiple threads do not create a Singleton object multiple times.
It can be difficult to unit test Singleton client code because many testing
frameworks rely on inheritance when creating mock objects. Because the
Singleton class is private and, in most languages, it is impossible to override
static methods, you will have to think of an original way to simulate the
Singleton. Or just don't write the tests. Or don't use the Singleton pattern.
Flutter
Flutter is a free and open-source framework from Google that allows you to create
native applications for Android and iOS with a simple code base. It
is an innovative software development kit for developing cross-
platform applications. It stands out for its new way of creating
native applications. It is a reliable smartphone UI framework to
develop engaging apps quickly by accelerating development.
Bibliography
https://www.teclab.edu.ar/tipos-de-arquitecturas-de-software-cuales-hay-y-en-
que-se-diferencian/
https://refactoring.guru/es/design-patterns/factory-method
https://refactoring.guru/es/design-patterns/singleton
https://spdigitalagency.com/es/blog/popular-frameworks-in-2023-for-mobile-
application-development