Where to create a Helpers layer?

6

I need to create a Helpers layer that will contain classes that will be made available for the entire project. These classes will contain functions like calculations, string cleaners, in short, those functions we use all the time ...

My project has layers Presentation , Application , Domain , infra/Data , infra/crosscutting .

I thought about creating the Helpers layer within infra/crosscutting , is it the right place?

    
asked by anonymous 28.02.2018 / 10:59

2 answers

5
Right or wrong in these things is relative. Everything works and overall it is not falling apart. It's often priceless to try to do so right, as long as you know what you're doing . Not knowing the right thing is not good.

I think your project is too layered, but it's just my general opinion.

In general it is confusing to have generic helpers so, but has cases that is the best solution. We can not answer this.

It can be in helpers if you organize well, do not become a heap of things. These helpers can be extension methods. Or they can be in some kind that is not just a helper , maybe even an existing type. You can not separate too much, or put too much together.

Otherwise you should put the helper , if it is appropriate to have one, where it makes the most sense, can be totally separate from the rest (so it seems to be the case for almost everything) or it can be in one of these layers, it depends on whether it is for single use in it. Do not put anything in a specific place and use solution everywhere. Separate the general library of the application. Not necessarily as helper .

    
28.02.2018 / 12:39
3

Given that your project already has these layers and you wanted to implement some helpers, one way to keep everything organized and respecting the layers would be to let the helper type determine what layer it will be on. If it is a helper that has to do with the database it will be in the layer below, if it is one to format something in the UI it will be in the presentation layer and so on.

This is not a law, it's just a way to organize your helpers. You have to use whatever organization suits you best according to the project.

    
28.02.2018 / 12:37