H
H
hbuser2016-01-20 02:26:01
Laravel
hbuser, 2016-01-20 02:26:01

How is modularity implemented in web application architecture?

Hello. They often talk about modularity in the context of the topic of creating web applications. What is this very modularity, how is it implemented (context: PHP, Laravel)?
What do I mean by modularity?
The ability to create a homogeneous structure for modules and easily add these modules to the application to expand functionality. For example, there is some functionality for calculating the cost of delivery by various transport companies (TC). Naturally, there is more than one TC and I want to offer an exhaustive list of options. I want to be able to add new variants (let's call them drivers). Tell us about the best practices and indicate whether my version has the right to exist.
As I see it myself or my version.
First, for a certain task (in my case, this is delivery), I define a set of similar actions for each module (and they will definitely be of the same type, because they are all united by a common generic feature - delivery-> delivery method). Next, for each of the actions, I create class methods. I select them in the interface. Each driver (delivery method) implements the generated interface. In this way, the homogeneity of the structure of the modules is achieved. Adding modules - this could be a simple addition of files (classes that implement the required interface) to a folder specially designated for this. With the help of reflection in php, it would be possible to determine the quantity and quality of these modules.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey, 2016-01-20
@hbuser

To begin with, let's figure out what a module is, this word has too many meanings . Even in the context of development.
What you described follows from:
- the principle of single responsibility - to allocate an operation on an object for each scenario
- polymorphism - the union of different objects with different implementations under one interface
- dependency inversion - the application code will depend on the interface (abstraction), and palm off its implementation we will proceed from the context.
And yes .... this moment:
It's a little unclear where Reflections has to do with the quality of the modules.
For the task you describe, there are already a lot of behavioral patterns. Specifically, the strategy pattern is applicable here.

F
fuckman, 2016-01-28
@fuckman

In the context of Laravel, I recommend the book Laravel: From Apprentice To Artisan Advanced Architecture With Laravel 4 Taylor Otwell.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question