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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T11:56:22+00:00 2026-05-24T11:56:22+00:00

I have a class that needs to be sortable in a couple of different

  • 0

I have a class that needs to be sortable in a couple of different ways, many of which break the equals() contract, so I need to have a bunch of different Comparator classes. The question I have is where should those classes live?

So that there is something concrete to use as an example namespace structure and to limit the question to package structure rather than file structure, lets assume the following namespaces:

app
  domain
    exception
    hibernatemapping
  mvc
    propertyeditor
    tags
  persistence
    hibernate

Domain classes live in the domain namespace, and related exceptions and hibernate mapping files in exception and hibernatemapping respectively. persistence holds DAO interfaces, with hibernate-based implementations in hibernate. All of the MVC controllers live in mvc, with specialized property editors (this is Spring MVC) in propertyeditor and classes that back custom tags in tags.

My gut says that Comparators should live under the domain namespace, perhaps in domain.comparator, but I’m not sure.

Where would you put them and why?


Update: A number of people have suggested using a general Util package. When going that route, would you separate out the Util classes by UI helpers vs. domain helpers? For example, if the domain needed to sort things for business logic reasons, but the UI needed additional sortings that the domain doesn’t care about? Basically, would you tend to have a helper package per-layer?

  • 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-24T11:56:23+00:00Added an answer on May 24, 2026 at 11:56 am

    As suggested, something like a util or a commons package would seem to make the most sense, though be sure you don’t end up using that as a “goto” package if you don’t know where to put something.

    I’d also suggest looking into package by feature. In this cause, your compartor would just go with whatever corresponding feature its used with. Again, this is only a suggestion – you’ll have to make the call for the best layout of your project.

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

Sidebar

Related Questions

I have one class that needs to grab an attribute that is set in
If I have a class that needs to implement an interface but one or
I have a session class that needs to store session information in a MySQL
I have a generic class that needs to limit an enum depending on the
If you have data for a class that will be modified and needs to
I have a class that I need to binary serialize. The class contains one
I have a class that I need to perform some actions on but I
I have a class that I need to be able to serialize to a
I have a class that has a property that I need to stub. I
I have a simple Java class that I need to serialize to be stored

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.