• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Validation of approach using an interface

 
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I working with a device that can be accessed via serial port or IP:port (stream.) My thought was to do the following and want to know if I am on the right track or not. Just need some guidance and/or course correction. Using sort of pseudo code to get my idea across.



I think where I am going to run into an issue is with creating the connection stream in the code so it is reusable in other places. I think I understand the contract around interfaces it is taking using it with the base code. The commands are the same for the device regardless of how it access, just the details that differ between serial and IP communication is where things become difficult the reason I am trying to get the level of the data stream.

Anyway am I on the right track? What other issues might I see or need to deal with? Or do I need to provide more information?

Thanks
Mike
 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I found it quite hard to follow your question to be honest. At a very high level, you seem to want to know if your plan is the best way to solve the problem. Unfortunately, both your plan and the problem are not well defined enough, that someone might be able to give some assistance. Some more clarification is needed I feel.
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is precisely what interfaces are for; abstracting away differences, and publicly defining "sames". You just need a factory class for returning the correct implementation. Other than that, not sure what else to tell you at this point.
 
Mike Bates
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
David,

Thanks for the feedback, which is exactly what I was looking for. I know the problem was probably not defined clearly enough and I have thinking for days on to write it up. You validated I was on the right track and provided a missing part of the puzzle -- the factory class.

Thanks
Mike
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic