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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T03:35:16+00:00 2026-06-02T03:35:16+00:00

My application is used for communication with electronic device. It reads some identification data

  • 0

My application is used for communication with electronic device. It reads some identification data (like device firmware version), some configuration data, and periodically data from sensors. Program is divided into three layers:

  1. Data layer – simple structures describing how data are stored in device memory.

  2. Business layer – classes used for communication with device. They contains structures from data layer and using them to store data when reading from and writing to device.

  3. Presentation layer – user interface (WinForms); using businnes layer classes.

Assume that:

Data structures looks like:

public struct Configuration
{
 public int Option1;
 public int Option2;
}

public struct Visualization
{
 public int Temperature;
 public int Pressure;
}

Business layer classes wraps these structures and contains logic for communication:

public abstract class BaseEntity<DataStructureType>
{
 protected DataStructureType dataStructure;
 public BaseEntity()
 {
  this.dataStructure = new DataStructureType();
 }
 /*
  device communication logic
 */
 public abstract bool GetAllData();
}

public class ConfigurationEntity : BaseEntity<Configuration>
{
 public override bool GetAllData()
 {
  //getting configuration data from device
 }
 public int Option1
 {
  get { return this.dataStructure.Option1; }
  set { this.dataStructure.Option1 = value; }
 }
 public int Option2;
 {
  get { return this.dataStructure.Option2 * 100; }
  set { this.dataStructure.Option1 = value / 100; }
 }
}

public class VisualizationEntity : BaseEntity<Visualization>
{
 public override bool GetAllData()
 {
  //getting visualization data from device
 }
 public int Temperature
 {
  get { return this.dataStructure.temperature; }
 }
 public float Pressure;
 {
  get { return Conversions.IntToPressure(this.dataStructure.pressure); }
 }
}

And Conversions class used to convert binary data:

public static class Conversions
{
 public static float IntToPressure(int parameter)
 {
  return PressureAlgorithmA(parameter);
 }
 private static float PressureAlgorithmA(int parameter)
 {
  //some algorithm (called A) to convert binary pressure to pressure in bars
 }
}

Problem is new firmware version, because application should handle both device versions(older and newer). New version has been updated with couple of new structures to read, new conversion algorithms, new configuration options. It looks like:

public struct Configuration
{
 /*
  old options are here
 */
 //and updated goes here:
 public int Option3;
 public int Option4;
}

public class ConfigurationEntity : BaseEntity<Configuration>
{
 /*
  old code is here
 */
 //and updated goes here
 public int Option3
 {
  get { return this.dataStructure.Option3; }
  set { this.dataStructure.Option3 = value; }
 }
 public int Option4;
 {
  get { return this.dataStructure.Option4 * 20; }
  set { this.dataStructure.Option4 = value / 20; }
 }
}

Also Conversions has beem changed:

public static class Conversions
{
 public static float IntToPressure(int parameter)
 {
  return PressureAlgorithmB(parameter);
 }
 private static float PressureAlgorithmB(int parameter)
 {
  //some algorithm (called B) to convert binary pressure to pressure in bars
 }
}

Now I have to check for device version every time I need to use new funcionality (when changing Option3 or Option4 from Configuration or when I need to use new data etities or which algorithm use when showing pressure to user).

My question is how can I do that with OOP practicies? What is correct way to do this in C#?

I was thinking about factory pattern, but what with new options in Configuration, or with new data entities?

  • 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-02T03:35:18+00:00Added an answer on June 2, 2026 at 3:35 am

    If you need to maintain the same architecture for different versions of external component (device in your case) the plug-in based architecture can help you.

    For example, you can:

    Every BusinessLayer class should implement IPluginInterface (say), as this the layer where actuall communication with device should happen.

    There should be some Communicator class, who reads device version information and picks from collection of available BusinessLayers, that one which is aable to manage required version.

    Just to give you an idea.

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

Sidebar

Related Questions

My application is used to upload rather big files (~500mb) and some of them
I have an application that used Macro. In this macro I would like to
I see an application have used Log.info = some info where are these logs
I have win32 application in which winsock is used for TCP/IP communication. I am
I have an application which is used internally and uses WCF for communication between
Could tools like SWFAddress be used in some clever ways to alleviate an existing
I've been asked to make an ETL-style application that transfers information from one data
I have a VC++2008 Form Application with some unmanaged socket communication code. I want
I have a Rails web app that is used to gather data from an
I need some help regarding interprocess communication. I have an Application A and Application

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.