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

  • Home
  • SEARCH
  • 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 4026826
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T11:01:14+00:00 2026-05-20T11:01:14+00:00

I have to implement a Client/Server architecture in Java, where the Server may change

  • 0

I have to implement a Client/Server architecture in Java, where the Server may change in the future (well, it definitely will at some point).

What would be the best way to take that possible change into account? Here’s what I thought of:

1.) Create an interface for the Server:

public interface AlarmService {
  ...
}

2.) Create a concrete implementation:

public AlarmServiceImpl implements AlarmService {
  ...
}

3.) Write a static factory to get some sort of implementation

public AlarmServiceFactory {
  private AlarmService AlarmServiceFactory() {
    return new AlarmServiceImpl();
  }
}

Is this a good idea? Or is this too much? Or maybe I shouldn’t take that change into account?

  • 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-05-20T11:01:14+00:00Added an answer on May 20, 2026 at 11:01 am

    There is a mantra that goes something along the lines of “always program to an interface, not an implementation”. While true in many cases, a lot of time it is overkill. In your case though, since you KNOW the implementation will change, and you won’t have as much control over the clients as you do the server, you should definitely program to an interface.

    The factory will only really be useful in two cases. The first being that you have several Implementations available, and you need to decide which one to produce at run-time. The other is if you are creating new AlarmServiceImpl() all over the place, and the implementation changes. Otherwise, I see the use of a factory as overkill.

    So.. definitely build an interface for the client/server to communicate through. Only use a factory if swapping or choosing implementations isn’t one or two lines of code, and is scattered in various places.

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

Sidebar

Related Questions

Well, i have a task to write Tcp Client for Andoid on java. Before,
I have implement one client server base application for ipad (sdk 3.2). I have
I have implement the simple TCP server and TCP client classes which can send
I have a custom control that implements IPostBackEventHandler. Some client-side events invoke __doPostBack(controlID, eventArgs).
I have to implement the VinPower application. They offer a Java version, a C
I was having a discussion with coworkers. We have to implement some security standards.
I would like to implement an distributed Point-Of-Sale system, somewhat like the one described
I am developing a Client-Server based application in which client application will access server
I've a server/client architecture implemented, where all state changes are sent to the function,
We have to implement a two tier architecture to distribute a cache from a

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.