Z
Z
Zhaz2017-04-26 15:16:50
Yii
Zhaz, 2017-04-26 15:16:50

How to properly split a project into modules? And how to properly organize the connection between them?

Hello!
I just can't figure out how to make a site based on loosely coupled modules, and therefore I decided to try it through practice on a test project. I would appreciate any advice.
Let's say there is an electronic library website. There are books , book category , authors , users and user comments .

  1. Will it be correct to put everything related to books ( books , categories , authors ) into one module (library) or is it better to put everything into separate modules?
  2. What is the best way to organize communication between modules? For example, how to correctly display the form for adding comments from the view of the comment module to the view of the book module? Or, for example, how to get a model from the user module from the comment module to get the name of the author of the comment?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry, 2017-04-26
@slo_nik

Good afternoon.
one
two
This is for starters, the rest in other blog articles.
ps
Organization of portable modules
Links of independent modules

I
Ilya, 2017-05-04
Tollu @itollu

The question is very important and complex. The division of the project into modules can be influenced both by the processes in the modeled business and the organizational structure of the development team (see "Conway's Law"). And if the second can (potentially) be changed according to needs, then the first must at least be clarified. The ability to make changes to business processes is usually limited, but in any case, you need to understand the actual state of the subject area.
In recent years, the Event Storming technique has been developed. There are already many videos on this topic and even a book [half] ( https://leanpub.com/introducing_eventstorming ). The key idea is to figure out what needs to happen before we get into any known state. The technique is of particular interest in the context of microservices. Offeroxidmod also has a lot to do with this.
But in addition to the system level, you also need to modularize individual components so that you can put them in your head, test and develop independently of each other. The Hexagonal Architecture (also called "Ports and Adapters") will help you here. This concept will help to divide the component into parts that implement business functions and (separately) external interactions: with the file system, with the database, with HTTP client-services, etc.
At an even lower level, I advise you to master 1) separating pure functions from effects and 2) functional composition - these are ideas from functional programming. I don’t know how with FP in PHP, but here practicing PHP programmers can tell.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question