In an MVC project, where should I leave the enums?

2

I'm developing a program with MVC standard, I needed to create some enum , and I left them in the Model layer, but I was in doubt about its location, what would be the correct layer to house the enum of a project?

    
asked by anonymous 03.06.2016 / 21:49

1 answer

6

Without knowing the exact problem you can not answer. It is absurd for anyone to say where they should put something without the knowledge of the specific need. This is because of the cake recipe culture that has nothing to do with professional programming.

If the enumerations are part of the model, if they are part of the business rule you are putting together, then the standard is to be in the model. Only the one who is creating the application can say this.

If the enumerations help your controller work, then that's probably where you should put it. This is usually done when it is part of the application rule.

There are cases that are not to be placed on either of them and even an extra separation ( helpers ). You need to stop with this idea because the application has 3 pasties and has the right place to put things. It even has a right place, but it is not a rule ready, you have to put it in the most appropriate place.

There is not even consensus where the business rule should go , and many say it should go in the controller. So stating that something goes somewhere without knowing the case is purely baseless opinion.

    
04.06.2016 / 02:07