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 7053551
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:31:08+00:00 2026-05-28T03:31:08+00:00

I am about to develop a peer to peer file sharing application in Java

  • 0

I am about to develop a peer to peer file sharing application in Java for a school project and was thinking over its design. I am stuck with two alternatives :

1)

A Peer class which holds all the state information like, its ID, its preferred neighbors, number of pieces etc.

and

A PeerManager class which acts as an interface for the Peer class. It will contain a reference to Peer object, and then methods operating over it. Some of the methods are updatePreferredNeighbours, connect or disconnect to another peer, generateLogs etc.

But when I think about it in terms of OO design, I feel that a Peer object should be responsible for its behaviour. That brings me to the second alternative:

2)

A Peer interface containing all the methods like connect to other peers, update neighbors etc (that were previously in peerManager)

and a Implementation of this interface say PeerImpl , which contains all the state information and also implements all the methods in the interface.

But my problem with this approach is that, it will clutter up the Impl class. The state consists of a lot of information and then I need to have their getters and setters so that other threads can update the state. In addition if I also have to implement all the methods of the interface, it will make the implementing class huge and very difficult to maintain or even debug.


Is there another way to approach this problem, any suggestions? Or which one of the two should I choose?

PS: I cannot give all the requirements of the project here as it will make the post too big, but what I have described is more or less the essence of the project.

  • 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-28T03:31:09+00:00Added an answer on May 28, 2026 at 3:31 am

    Without know the details of your problem, it’s hard to be specific. However, if you look at the Peer class in terms of data modeling, it seems that there are (at least) two categories of data: things like ID that are properties of a Peer object and things like preferred neighbors that are relational properties between Peers. I’d give some thought into separating these into separate object classes.

    Regarding the complexity problem of the second approach: wouldn’t the same problem would exist regarding the PeerManager class of the first approach? It seems to me like this is an issue either way and doesn’t weigh in favor of one or the other approach.

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

Sidebar

Related Questions

I am using VS2008 to develop a WinForms 2.0 application. I have read about
I am using Codeigniter to develop an application, and have been reading bits about
I am about to develop a sort of web application using only static files
I’m starting to think about and develop an architecture for a big web application,
I'm thinking about starting to develop a plugin for AutoCAD, but I have absolutely
I'm planning to develop a facebook application about horoscopes. So I need users and
I work on a project website and I am about to develop a Web
I'm about to develop a web mapping application with ESRI Products like ArcGIS Server
i am about to develop a new application and I was looking at JXSE
I need to develop an ever increSing counter in C#. I am thinking about

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.