can anyone help me with bit of refactoring advice.
I have my App which i have in the namespace - these namespaces i am happy with.
MyCompany.MyProduct.Web (for the web app)
MyCompany.MyProduct.Windows (for the windows app)
these apps need to call my API .. The API is specifically for this application but lives separately. Currently I have it in the following form.
MyCompany.MyProduct.Api
But i really don't like it... i was th开发者_Python百科inking maybe better to put it in
MyCompany.MyProduct.Core
Is this a good way?
Under Core i will have Enums, Exception Classes etc
So these would be actually
MyCompany.MyProduct.Core.Enums.DaysOfWeek (DaysOfWeek is an example)
MyCompany.MyProduct.Core.Exceptions.ConnectionException (just an example)
Is Core a good idea and what should go in there.????
If I have a command called CreateSchedule which is under the class Schedule which is part of my api then what would be a good idea for the complete namespace including method etc
MyCompany.MyProduct.Core.Schedule.CreateSchedule ???
I presume i put under the ROOT (i.e. CORE) all enums / exceptions that are globally specific to my api. Is it good practice that my app can use Enums /Exceptions from my API - this is how i currentlt have it. if i have an enum that is specific only to a class do i keep it there in ROOT (core) or better to put it
MyCompany.MyProduct.Core.Schedule.Enums
I hope someone can help me on this
thanks in advance
I think if an enum applies to only a specific class, then it makes sense to make the enum be within that class (i.e. not at the root level). For exampe, it makes sense for DaysOfWeek to be within the Schedule class.
"Core" is certainly better than "Api", which sort of looks weird since it's an acronym.
I am not sure about having a namespace for Exceptions (i.e. MyCompany.MyProduct.Core.Exceptions.xxx). I would rather put the exception classes as siblings of the class from which they are generated.
精彩评论