Skip to main content
Tweeted twitter.com/#!/StackProgrammer/status/556680341717790722
edited title
Link
jimwise
  • 7.7k
  • 1
  • 32
  • 32

Seperation Separation of concerns between objects

Source Link

Seperation of concerns between objects

I have two objects which work together to provide interaction with HIDs on a machine. One object is responsible for the communication (read/write) to the HID and the other object is responsible for modelling the HID. Information is read and written to the HID as byte arrays.

As a contrived example:

class Hid { private HidComms comms; public DateTime? GetPropertyB() { return comms.GetPropertyB(); } } class HidComms { public DateTime? GetPropertyB() { // request property B from HID // get 1 or more byte[] in response return new DateTime(); } } 

Which of these two objects should be responsible for encoding/decoding the byte arrays, or should a third object be responsible for this? Meaning the Hid object only knows about state and the HidComms object only knows how to read/write with a third object responsible for the conversion?