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 6648805
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:41:55+00:00 2026-05-26T00:41:55+00:00

I want to develop a library for communicating with a circuit via serial port.

  • 0

I want to develop a library for communicating with a circuit via serial port. This circuit understands roughly 100 serial commands and returns a response string.

The commands are divided into 3 categories (settings, environment, and outputs) so I would like to use properties or some other means to nest the categories and methods within the overall class. Instead of throwing all the command methods under a single class, what would be the recommended way to nest them? I want to avoid the following at all costs, it would just be a mess:

public class CircuitLib
{
   ...
   // Methods.
   public string SettingCommand1(string command) {...}
   ...
   public string SettingCommand30(string command) {...}

   public string EnvironmentCommand1(string command) {...}
   ...
   public string EnvironmentCommand30(string command) {...}

   public string OutputCommand1(string command) {...}
   ...
   public string OutputCommand30(string command) {...}
}

It would be nice to be able to use properties to get to the specified category:

circuitLibInstance.GetSettingsProperty.OneOfTheSettingsMethods(stringCommand);

Any guidance would be GREATLY appreciated.

Thanks Everyone!

  • 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-26T00:41:56+00:00Added an answer on May 26, 2026 at 12:41 am

    Well you could have:

    public class Circuit
    {
        // Initialize these in the constructor
        private readonly SettingCommands settings;
        private readonly EnvironmentCommands environment;
        private readonly OutputCommands output;
    
        public SettingCommands Settings { get { return settings; } }
        public EnvironmentCommands Environment { get { return environment; } }
        public OutputCommands Output { get { return output; } }
    }
    
    public class SettingCommands
    {
        public string Foo(string command) { ... }
    }
    

    Then:

    string result = instance.Settings.Foo("hello");
    

    Is that what you were after?

    Of course if all your command methods actually have the same structure, you might potentially want an enum, for example:

    public enum SettingCommand { Foo, Bar, Baz }
    public enum EnvironmentCommand { Alice, Bob, Charlie }
    public enum OutputCommand { Ender, Bean, Alai }
    

    then:

    public class Circuit
    {
        public string Execute(SettingCommand command, string data) { ... }
        public string Execute(EnvironmentCommand command, string data) { ... }
        public string Execute(OutputCommand command, string data) { ... }
    }
    

    and use as:

    string result = instance.Execute(SettingCommand.Foo, "data");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to develop a simple windows manager, but do not know which library
Possible Duplicate: Open source iPhone Coverflow like library hello all i want to develop
I want to write a generic (C/C++) library that I will use to develop
I want to develop a GUI like Yahoo Pipes. Can anyone suggest some library
I want to develop a library to handle mail client’s address book. And, I
I want to develop a library to handle mail client’s address book. And, I
I want to develop a java library for bitbucket issues API access. I've already
I want to develop a Business card reader or OCR Library (Open Source) for
I want to develop a workflow for a SharePoint Publishing Page Library. When someone
I want to develop an extension using the PBC library . The amount and

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.