Search code examples
c#asp.netarchitecturetiers

What is the Best place to store constants in n-tiers asp.net App?


I wonder what is the best place to store the enums I should use like constants in my n-tiers Application.

So I have an application with a DAL(connect to database), a BLL(Business processes), a Data Transfert object "Layer" (classes without any methods but just fields, this one is reacheable by all the others) and the interface layer with the asp pages.

My question is : I have a enum:

 public enum ID_FOO : uint
 {
     ALL = 1,
     FOOOne= 2,
     FOOTwo= 3
 }

Where can I put this enum(and all the others) to be clean? Not in the Data Access Layer the Interface layer will not see the struct, not in the Business Logic Layer, this is not really business.. Maybe in the Data Transfert Object but is it really a "Transfert object"? Should I Create an another layer??

Thanks for all responses!..


Solution

  • I think it depends on what layers will access this struct.

    You say it will be accessed by DAL and DTOs. If used by DTOs, I feel it will also be exposed to any layer that uses DTO layer.

    If you feel its not part of BAL, create a seperate assembly (Common) to share such types and reference to that assembly instead. This will keep it clean.