D
D
Denis Morozov2015-03-10 19:09:22
IDE
Denis Morozov, 2015-03-10 19:09:22

Why are files/classes grouped by layers in a project (ModelLayer/UILayer, etc.)?

The structure usually looks something like this:

models
----UserModel
----NoteModel
controllers
----UserController
----NoteController
ui
----UserView
----NoteView

I always notice that as a rule I make changes to one thing (I mean one thing, for example, from my example, I make changes to users). You have to scroll back and forth. First, edits in the model, then in ui, then in the controller, and so on in a circle. In a decent project, there are many entities, more layers, between model and ui, for example, there may be more than the height of the monitor screen.
Everything is vehemently structured this way, and I thought maybe there is a good reason to do so?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
D', 2015-03-10
@Denormalization

Standard MVC Model .
Recently, I prefer to break into logical blocks like this:
Users
-- Controllers
---- UsersController
-- Models
---- UserModel
-- View
---- UserView
-- Services
---- UserRegistrationService
Notes
-- Controllers
---- NotesController
-- Models
---- NotesModel
-- View
---- NotesView
So it turns out more compact and more convenient to work with a specific entity.

I
Igor Kalashnikov, 2015-03-12
@zo0m

IMHO, this approach should be abandoned. It came out of Internet examples like this.
Break everything into modules, each is responsible for some kind of decision, and inside already divide into layers as you wish.
Imagine that you have 8000 classes. Will you put them in 3 folders?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question