Skip to main content
Tweeted twitter.com/StackSoftEng/status/892981384708579328
Fixed sentence.
Source Link
packoman
  • 291
  • 2
  • 5

My question is: How can I maximize encapsulation for wrapper-classes that interface with hardware.

The hardware is connected to a PC through COM-Ports or USB ports and I am either reading/writing to it directly or through an API. Either of which I want to wrap in a class.

I have been reading about software development and architecture in general (in C#), but I still do not have a feeling for how to architecture classes and objects around hardware.

Things that have been going through my head in this regard are the following aspects:

  1. When and how should I initialize the hardware, so that the clients of the encapsulating class need not worry about this (or the littlest possible), e.g.: Is it OK to initialize the hardware/port once at program startup and close it at the end or should I always (which is what I am currently doing) or should I always open and close the hardware/port as needed.
  2. Related to the first point: When and how should I release and destruct the hardware and their wrapping/related class.
  3. Should I store hardware state in the class or always query the device?
  4. How to handle hardware errors/exceptions (gracefully)? Right now, since I am initializing the hardware at startup, if some of it is not found, my program will not startup correctly. I would prefer it to startup and signal that some hardware was not found, so that it can be connected. But I cannot think of a decent architecture to achieve this.
  5. How can I make this fit in with dependency inversion: I am currently using factories to initialize the hardware and pass out the wrapper-classes through a DI-container. This however means that I am initializing only once at startup.

I realize that this is a broad topic with various subtopics, but these points are all closely related to each other and I am finding it difficult to find good and coherent information on this topic.

FYI: I am a C# developer, but I am interested in the general concepts.

My question is: How can I maximize encapsulation for wrapper-classes that interface with hardware.

The hardware is connected to a PC through COM-Ports or USB ports and I am either reading/writing to it directly or through an API. Either of which I want to wrap in a class.

I have been reading about software development and architecture in general (in C#), but I still do not have a feeling for how to architecture classes and objects around hardware.

Things that have been going through my head in this regard are the following aspects:

  1. When and how should I initialize the hardware, so that the clients of the encapsulating class need not worry about this (or the littlest possible), e.g.: Is it OK to initialize the hardware/port once at program startup and close it at the end or should I always (which is what I am currently doing).
  2. Related to the first point: When and how should I release and destruct the hardware and their wrapping/related class.
  3. Should I store hardware state in the class or always query the device?
  4. How to handle hardware errors/exceptions (gracefully)? Right now, since I am initializing the hardware at startup, if some of it is not found, my program will not startup correctly. I would prefer it to startup and signal that some hardware was not found, so that it can be connected. But I cannot think of a decent architecture to achieve this.
  5. How can I make this fit in with dependency inversion: I am currently using factories to initialize the hardware and pass out the wrapper-classes through a DI-container. This however means that I am initializing only once at startup.

I realize that this is a broad topic with various subtopics, but these points are all closely related to each other and I am finding it difficult to find good and coherent information on this topic.

FYI: I am a C# developer, but I am interested in the general concepts.

My question is: How can I maximize encapsulation for wrapper-classes that interface with hardware.

The hardware is connected to a PC through COM-Ports or USB ports and I am either reading/writing to it directly or through an API. Either of which I want to wrap in a class.

I have been reading about software development and architecture in general (in C#), but I still do not have a feeling for how to architecture classes and objects around hardware.

Things that have been going through my head in this regard are the following aspects:

  1. When and how should I initialize the hardware, so that the clients of the encapsulating class need not worry about this (or the littlest possible), e.g.: Is it OK to initialize the hardware/port once at program startup and close it at the end (which is what I am currently doing) or should I always open and close the hardware/port as needed.
  2. Related to the first point: When and how should I release and destruct the hardware and their wrapping/related class.
  3. Should I store hardware state in the class or always query the device?
  4. How to handle hardware errors/exceptions (gracefully)? Right now, since I am initializing the hardware at startup, if some of it is not found, my program will not startup correctly. I would prefer it to startup and signal that some hardware was not found, so that it can be connected. But I cannot think of a decent architecture to achieve this.
  5. How can I make this fit in with dependency inversion: I am currently using factories to initialize the hardware and pass out the wrapper-classes through a DI-container. This however means that I am initializing only once at startup.

I realize that this is a broad topic with various subtopics, but these points are all closely related to each other and I am finding it difficult to find good and coherent information on this topic.

FYI: I am a C# developer, but I am interested in the general concepts.

fixed grammar
Source Link
packoman
  • 291
  • 2
  • 5

My question is: How can I maximize encapsulation for wrapper-classes that interface with hardware.

The hardware is connected to a PC through COM-Ports or USB ports and I am either reading/writing to it directly or through an API. Either of which I want to wrap in a class.

I have been reading about software development and architecture in general (in C#), but I still do not have a feeling for how to architecture classes and objects around hardware.

Things that have been going through my head in this regard are the following aspects:

  1. When and how should I initialize the hardware, so that the clients of the encapsulating class need not worry about this (or the littlest possible), e.g.: Is it OK to initialize the hardware/port once at program startup and close it at the end or should I always (which is what I am currently doing).
  2. Related to the first point: When and how should I release and destruct the hardware and their wrapping/related class.
  3. Should I store hardware state in the class or always query the device?
  4. How to handle hardware errors/exceptions (gracefully)? Right now, since I am initializing the hardware at startup, if some of it is not found, my program will not startup correctly. I would prefer it to startup and signal that some hardware was not found, so that it can be connected. But I cannot think of a decent architecture to achieve this.
  5. How can I make this fit in with dependency inversion: I am currently using factories to initialize the hardware and pass out the wrapper-classes through a DI-container. This however means that I am initializing only once at startup.

I realize that this is a broad topic with various subtopics, but these points are all closely related to each other and I am finding it difficult to find good and coherent information on this topic.

FYI: I am a C# developer, but I am interested in the general concepts.

My question is: How can I maximize encapsulation for wrapper-classes that interface with hardware.

The hardware is connected to a PC through COM-Ports or USB ports and I am either reading/writing to it directly or through an API. Either of which I want to wrap in a class.

I have been reading about software development and architecture in general (in C#), but I still do not have a feeling for how to architecture classes and objects around hardware.

Things that have been going through my head in this regard are the following aspects:

  1. When and how should I initialize the hardware, so that the clients of the encapsulating class need not worry about this (or the littlest possible), e.g.: Is it OK to initialize the hardware/port once at program startup and close it at the end or should I always (which is what I am currently doing).
  2. Related to the first point: When and how should I release and destruct the hardware and their wrapping/related class.
  3. Should I store hardware state in the class or always query the device?
  4. How to handle hardware errors/exceptions (gracefully)? Right now, since I am initializing the hardware at startup, if some of it is not found, my program will not startup correctly. I would prefer it to startup and signal that some hardware was not found, so that it can be connected. But I cannot think of a decent architecture to achieve this.
  5. How can I make this fit in with dependency inversion: I am currently using factories to initialize the hardware and pass out the wrapper-classes through a DI-container. This however means that I am initializing only once at startup.

I realize that this is a broad topic with various subtopics, but these points are all closely related to each and I am finding it difficult to find good and coherent information on this topic.

FYI: I am a C# developer, but I am interested in the general concepts.

My question is: How can I maximize encapsulation for wrapper-classes that interface with hardware.

The hardware is connected to a PC through COM-Ports or USB ports and I am either reading/writing to it directly or through an API. Either of which I want to wrap in a class.

I have been reading about software development and architecture in general (in C#), but I still do not have a feeling for how to architecture classes and objects around hardware.

Things that have been going through my head in this regard are the following aspects:

  1. When and how should I initialize the hardware, so that the clients of the encapsulating class need not worry about this (or the littlest possible), e.g.: Is it OK to initialize the hardware/port once at program startup and close it at the end or should I always (which is what I am currently doing).
  2. Related to the first point: When and how should I release and destruct the hardware and their wrapping/related class.
  3. Should I store hardware state in the class or always query the device?
  4. How to handle hardware errors/exceptions (gracefully)? Right now, since I am initializing the hardware at startup, if some of it is not found, my program will not startup correctly. I would prefer it to startup and signal that some hardware was not found, so that it can be connected. But I cannot think of a decent architecture to achieve this.
  5. How can I make this fit in with dependency inversion: I am currently using factories to initialize the hardware and pass out the wrapper-classes through a DI-container. This however means that I am initializing only once at startup.

I realize that this is a broad topic with various subtopics, but these points are all closely related to each other and I am finding it difficult to find good and coherent information on this topic.

FYI: I am a C# developer, but I am interested in the general concepts.

added 2 characters in body
Source Link
packoman
  • 291
  • 2
  • 5

My question is: How can I maximize encapsulation for wrapper-classes that interface with hardware.

The hardware is connected to a PC through COM-Ports or USB ports and I am either reading/writing to it directly or through an API. Either of which I want to wrap in a class.

I have been reading about software development and architecture in general (in C#), but I still do not have a feeling for how to architecture classes and objects around hardware.

Things that have been going through my head in this regard are the following aspects:

  1. When and how should I initialize the hardware, so that the clients of the encapsulating class need not worry about this (or the littlest possible), e.g.: Is it OK to initialize the hardware/port once at program startup and close it at the end or should I always (which is what I am currently doing).
  2. Related to the first point: When and how should I release and destruct the hardware and their wrapping/related class.
  3. Should I store hardware state in the class or always query the device?
  4. How to handle hardware errors/exceptions (gracefully)? Right now, since I am initializing the hardware at startup, if some of it is not found, my program will not startup correctly. I would prefer it to startup and signal that some hardware was not found, so that it can be connected. But I cannot think of a decent architecture to achieve this.
  5. How can I make this fit in with dependency inversion: I am currently using factories to initialize the hardware and pass out the wrapper-classes through a DI-container. This however means that I am initializing only once at startup.

I realize that this is a broad topic with various subtopics, but these points are all closely related to each and I am finding it difficult to find good and coherent information on this topic.

FYI: I am a C# developer, but I am interested in the general concepts.

My question is: How can I maximize encapsulation for wrapper-classes that interface with hardware.

The hardware is connected to a PC through COM-Ports or USB ports and I am either reading/writing to it directly or through an API. Either of which I want to wrap in a class.

I have been reading about software development and architecture in general (in C#), but I still do not have a feeling for how to architecture classes and objects around hardware.

Things that have been going through my head in this regard are the following aspects:

  1. When and how should I initialize the hardware, so that the clients of the encapsulating class need not worry about this (or the littlest possible), e.g.: Is it OK to initialize the hardware/port once at program startup and close it at the end or should I always (which is what I am currently doing).
  2. Related to the first point: When and how should I release and destruct the hardware and their wrapping/related class.
  3. Should I store hardware state in the class or always query the device?
  4. How to handle hardware errors/exceptions (gracefully)? Right now, since I am initializing the hardware at startup, if some of it is not found, my program will not startup correctly. I would prefer it to startup and signal that some hardware was not found, so that it can be connected. But I cannot think of a decent architecture to achieve this.
  5. How can I make this fit in with dependency inversion: I am currently using factories to initialize the hardware and pass out the wrapper-classes through a DI-container. This however means that I am initializing only once at startup.

I realize that this is broad topic with various subtopics, but these points are all closely related to each and I am finding it difficult to find good and coherent information on this topic.

FYI: I am a C# developer, but I am interested in the general concepts.

My question is: How can I maximize encapsulation for wrapper-classes that interface with hardware.

The hardware is connected to a PC through COM-Ports or USB ports and I am either reading/writing to it directly or through an API. Either of which I want to wrap in a class.

I have been reading about software development and architecture in general (in C#), but I still do not have a feeling for how to architecture classes and objects around hardware.

Things that have been going through my head in this regard are the following aspects:

  1. When and how should I initialize the hardware, so that the clients of the encapsulating class need not worry about this (or the littlest possible), e.g.: Is it OK to initialize the hardware/port once at program startup and close it at the end or should I always (which is what I am currently doing).
  2. Related to the first point: When and how should I release and destruct the hardware and their wrapping/related class.
  3. Should I store hardware state in the class or always query the device?
  4. How to handle hardware errors/exceptions (gracefully)? Right now, since I am initializing the hardware at startup, if some of it is not found, my program will not startup correctly. I would prefer it to startup and signal that some hardware was not found, so that it can be connected. But I cannot think of a decent architecture to achieve this.
  5. How can I make this fit in with dependency inversion: I am currently using factories to initialize the hardware and pass out the wrapper-classes through a DI-container. This however means that I am initializing only once at startup.

I realize that this is a broad topic with various subtopics, but these points are all closely related to each and I am finding it difficult to find good and coherent information on this topic.

FYI: I am a C# developer, but I am interested in the general concepts.

I revised the question, so that it is more to the point, even though it is broad. I also removed the request for literature.
Source Link
packoman
  • 291
  • 2
  • 5
Loading
Source Link
packoman
  • 291
  • 2
  • 5
Loading