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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:54:50+00:00 2026-06-14T06:54:50+00:00

I am currently working on an library that can read and set config values

  • 0

I am currently working on an library that can read and set config values on an device attached to a PC. Each of the config fields is described by a constant (public static readonly) object, which contains the name of this field, the type of its data (along with value restrictions) and the command sequences needed to read/write it.

This information is mostly just needed inside the library. However, client code needs to be able to tell the library to read/write specific fields, and I also want to pass collections of config values around in dictionaries that associate fields with their values. To do this, I need to provide public values which identify the fields.

Is it OK to use the same objects for internally describing the fields and for publicly identifying them? It feels slightly wrong, but I can’t put my finger on the reason. I hope you can either lay my doubts to rest, or tell me why it is a bad idea or what to look out for.

Update:
I ended up using the same objects for both the field identity and for implementing field access. Now, months later, I finally ran into an issue that highlighted why this was not quite a clean solution: A field object represents a config field on the device, as I noted above. This is independend from the way such a field is accessed.

In more general terms: My hidden, internal representation of the thing does not describe the thing. It describes something related to the thing which does not necessarily have a 1:1 relation.

This can become a problem if you want to alter the field access. For example, now I can’t create a Field decorator class that would offer “retry on error” access behaviour. Code working with the decorator would treat it as its own field, unrelated to the actual underlying field.

Note that this is not an answer to the original question, but rather a realisation that my assumptions were wrong. If you are really really sure that your internal description of your thing has a 1:1 relation to the thing itself, this problem does not apply.

  • 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-06-14T06:54:51+00:00Added an answer on June 14, 2026 at 6:54 am

    This really depends on how your library functions and how the client code interacts with it. One potential issue with exposing the internal representation to clients is that you don’t have as much flexibility to change the internal representation without potentially breaking client code. However, I don’t think that would be too difficult to overcome, because at the point in time in which you need a different representation internally, you could just create a new internal representation, and leave the old representation as part of the public API.

    If you decide to expose the internal representation as part of the public API, one thing to watch out for is unintended side effects. For example, let’s say client code passes you an object and then you store that object internally. Objects are passed by reference in C#, which means that any modification to that object would also occur to the one stored internally. Of course you could just make a copy of the object so that this problem doesn’t occur.

    Lastly, you may want to step back and consider the public API from a client perspective (if you haven’t already). Perhaps try using it in some unit tests. You may find that the internal representation is not the best way to represent it from a client perspective.

    For very simple API’s using the internal structure is probably ok. I always tend to lean the other direction, and would opt for an abstraction and an isolation in my design that segregates the public API from the inner workings.

    It’s all about tradeoffs and just depends on what you’re trying to accomplish. Hopefully this will help your decision a little bit.

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

Sidebar

Related Questions

The Java library that I'm currently working on can be configured with a .properties
Currently working with converting SQLException error messages into messages that are more useful for
Im currently working on a game that uses multi touch to apply zoom to
Am currently working on an application that requires users to submit posts and comments
I am currently working on a REST library for .net, and I would like
I am currently working on the linqtotwitter library. I am using cookies to store
I am currently working on a C++ sparse matrix/math/iterative solver library, for a simulation
I am currently working with a piece of code that has been written by
I need a C++ library that can store and retrieve time series on demand
im currently working in a simple program that implements plugins whith dll libraries (using

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.