Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Kind of class is it?

 
Rancher
Posts: 527
6
IntelliJ IDE Spring Fedora
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,

I have a class that is basically responsible for talking on a socket with a specific protocol.
I have a service class that uses objects of this class to continuously check for changed values to send value changes from user input.
I'm guessing it's in the data layer because there is IO.
Right now I have it in my model namespace but that doesn't seem right.
The project doesn't have any database connections, just the socket class for talking, so there's no repository namespace.

How should I classify this class? What namespace should it be in?


Thank you for any insight.

 
 
Sheriff
Posts: 15801
264
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds a bit like a Gateway - I'd look through Fowler's catalog of Enterprise Application Architecture patterns for some ideas: https://www.martinfowler.com/eaaCatalog/gateway.html
 
Saloon Keeper
Posts: 12154
258
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Assuming that your class wraps around a socket and provides methods for sending and receiving messages, I'd call it SomethingSomethingProtocol and put it in a package named protocol.

That's what I have done in the past at least. I don't know if there is a more generalized approach to this, it seems that Junilu might be onto something with Gateway, although I believe that's just another name for the Facade pattern.
 
Junilu Lacar
Sheriff
Posts: 15801
264
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are really a few ways you can categorize this. SomethingSomethingProtocol is also reasonable. I think it kind of just depends on the semantics you want to have around the idea and how far up or down in the spectrum of abstraction you want the idea to sit. And there's nothing to prevent you from layering this as well. For example, if you combine the ideas of Gateway/Facade and Protocol, I'd imagine you could layer it like so:

/com.myapp.connections
    /gateway  # or facade
         /protocol
              /ipv6
                  ServiceAIpV6Gateway     # or *Facade
                  ServiceBIpV6Gateway
                  ServiceCIpV6Gateway
              /x25
                  ServiceAx25Gateway
                  ServiceCx25Gateway
              /sms
                  ServiceDsmsGateway
                  ServiceEsmsGateway
              /irc
                  ServiceDircGateway
                  ServiceEircGateway

Something like that maybe, I don't know, that's just off the top of my head. Your full context may require some variation of that idea.
 
Can you hear that? That's my theme music. I don't know where it comes from. Check under this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic