Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7413335
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:40:47+00:00 2026-05-29T06:40:47+00:00

Let’s say I have an interface ICustomerService and this interface requires an enum, e.g.

  • 0

Let’s say I have an interface ICustomerService and this interface requires an enum, e.g. ProcessingMode:

namespace MyServices {
    public enum ProcessingMode { Immediate, Normal, Slow }

    public interface ICustomerService {
        void Process(ProcessingMode mode);
    }
}

The enum can’t be defined inside the interface in C# (but apparently in VB?). But having it outside the interface clutters the containing namespace MyServices. Not good, since other interfaces might also require a different enum called ProcessingMode.

So are there any “best practices” how to solve this?

I can see a few options, but none of them seems quite right to me:

  1. Put both the interface and the enum in a service-specific namespace:

    namespace MyServices.CustomerService {
        public enum ProcessingMode { Immediate, Normal, Slow }
    
        public interface ICustomerService {
            void Process(ProcessingMode mode);
        }
    }
    

    While it works and avoids clutter in the containing namespace, it does cause namespace proliferation, and I guess a service implementation might clash with the namespace or duplicate it: MyNamespace.CustomerService.CustomerService. Or where would you put the service implementation and what would you call it?

  2. Put just the enum in a separate namespace (or a static class):

    namespace MyServices {
        namespace CustomerServiceTypes {
            public enum ProcessingMode { Immediate, Normal, Slow }
        }
    
        public interface ICustomerService {
            void Process(CustomerServiceTypes.ProcessingMode mode);
        }
    }
    

    Same problems as option 1 but also requires a enum name to be qualified “everywhere”.

  3. Prefix the enum name, e.g. CustomerServiceProcessingMode. Avoids namespace proliferation and risk of name clashes with service implementations, but causes long ugly enum names.

So how would you do it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T06:40:47+00:00Added an answer on May 29, 2026 at 6:40 am

    Just because it is the customer service that does the processing doesn’t mean you have to name the enum “CustomerService…..” – if the enum is for the Customer then just call it CustomerProcessingMode; especially if the enum is going to be a property on the business class.

    If there will be many ways of processing the customer which will require different processing modes then you will have to use the name of the service instead, but the reason you don’t like the look of the name is because your service name is rubbish 🙂 “CustomerService” – what does that do exactly?

    MailingService (which runs on implementers of an interface) would be a good example for a service, because the name tells you what the service does, NOT what it works on. Even “CustomerRepository” is a good name because the name tells you what it does.

    1. Use the namespace MyModel.Services
    2. Use a name for your service which explains what it does rather than what it works on
    3. Then you end up with a nice descriptive (and unique) enum name like “MailingPriority” instead

    Naming services “CustomerService” has no indication of the task of the service, and usually end up performing anything and everything to do with customers – kind of a “Swiss Army Knife” service which should really have a single focussed task rather than be a catalogue of everything one can do with a customer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

let's say i have this public class MyClass { public string myMessage { get;
Let's say on a page I have alot of this repeated: <div class=entry> <h4>Magic:</h4>
Let's say I have a text file composed like this ##### typeofthread1 ##### typeofthread2
Let's say I have this code: <p dataname=description> Hello this is a description. <a
Let's say I have table with column 'URL' whrere I store urls like this
Let's say that I have a set of relations that looks like this: relations
Let's say I have this MySQL table: OK.. see the type field? Type 0
Let's say i have this block of code, <div id=id1> This is some text
Let say that I have xml like this: <root> <node light=somevalue>message1</node> <node dark=somevalue>message2</node> <node>message3</node>
Let's say I'm building a data access layer for an application. Typically I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.