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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T00:18:25+00:00 2026-05-17T00:18:25+00:00

I am creating a java API for an addressbook Is it a good practice

  • 0

I am creating a java API for an addressbook
Is it a good practice to use Enums in my API ?

I am using it as follows:

public enum AddressType {

 WORK,HOME

}

public class AddressBook implements Function{

  Map<String, Details> byName = new TreeMap<String,Details>();


    public void addNewContact(String name,  String address, AddressType 
            addressType) {

        byName.put(name, new Details(name,new Address(address,addressType)));
// addressType is my enum AddressType
    }

Please advise if there is a better way to do this?

Also could you guide on how I could determine which methods I should declare as protected and private?
I want this API to be accessible for public so my understanding was that all the methods, classes, enums I create should be public.
But would that not be overlooking encapsulation property of Java??

Please help.

Thank you
}

  • 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-17T00:18:26+00:00Added an answer on May 17, 2026 at 12:18 am

    Enums as a general rule are a good idea. For any data that can be represented as a small number of unchanging strings, it’s a very useful datatype to have around. (It’s especially nice that you can attach metadata and behaviors to them if desired)

    That said, the one hesitation I have about your idea of using it for contact types such as WORK and HOME is that it makes it impossible for the user to have their own custom contact type. For example, what if I have two part time jobs and want to categorize people based on which job they are at?

    If you’re okay with that limitation, I’d say go for it.

    If you want the additional flexibility, I’d suggest either storing the contact type as a string or going for a database solution. For something like this, it may make sense to store your data in a SQLite database as that allows you to easily build a relational model.

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

Sidebar

Related Questions

I'm Creating a facebook application using apache-tomcat. I use the Java Facebook API. It
I am creating a REST Web Service using Java and Jersey API. The basic
I am successfully creating a Task using the SalesForce API SOAP API through Java.
I'm Writing a facebook application using the Java-facebook-api and MySQL 5.1. I'm trying to
I am creating a Clojure interface to a Java API with a method that
Java fb API I am creating facebook web application, to create even following is
I'm trying to do a document classification using Weka java API. Here is my
I have gotten almost a complete API to work, with creating and deleting documents
I'm using java 6 annotation processing api. I have followed the following excellent tutorial
I'm trying to find a simple Java API for creating graph relationships. It should

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.