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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T15:30:53+00:00 2026-06-16T15:30:53+00:00

I am just practising Java OOPs concepts by building a dummy project of Library

  • 0

I am just practising Java OOPs concepts by building a dummy project of Library management system.

Initially I had classes for Book, Customer, Administrator (with Customer, Administrator extending abstract user class)
I then created list classes BookCollection, CustomerCollection which hold the list of instances of above classes in ArrayList (for a while am not dealing with databases) and perform add, delete, sort methods on corresponding ArrayList (just one inline question: will it be a good design practice if I replace ArrayList related code with database operation once I start dealing with database, with each xyzCollection dealing with xyzTable in database)

The main problem:
Since I thought earlier that I will have to maintain only list of books, customers across app, I made ArrayLists static. Also, I wrote enough of static methods: addXyz, deleteXyz, searchXyz, sortXyz methods However now I realize that for search of Customers or Books I may have (or rather should) to return list of them matching the name, that means I have to return another ArrayList, which should be an instance of xyzCollection, however I cant use ArrayList in these xyzCollection as it is staic shared among all instances.

Initially it was appearing I will need shared ArrayList, but am now doubting my initial decision.
What should be correct?:

  • Should I make ArrayList and corresponding methods non static and make any corresponding code changes at calls
  • Or should I return ArrayList instead of XyzCollection

What will be better in terms of code design? Or I have made definite mistake in making them all static?

  • 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-06-16T15:30:54+00:00Added an answer on June 16, 2026 at 3:30 pm

    I assume that you are creating collection books/customers after fetching data from DB. As you say its a library management system which means multiple users can use it simultaneously. And each request will be independent of other (like a typical distributed system).

    So would suggest you to use normal class instead of static. You can use static for managing utilities like connection to db but not as placeholder like list of books/customers.

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

Sidebar

Related Questions

hey there, just practising and I had a question. I have a program (source
I have just started practicing OOP in php through the book Concepts, Techniques and
I just started practicing TDD in my projects. I'm developing a project now using
I'm studing on a project. It's a bank simulation and just for practicing OOP
From the below code: why paragraph tag not showing green? Iam just practising CSS,
I'm just practicing some MIT java assignments. But, I'm not sure how to find
I'm practising with C, writing simple programs. The little program below should just get
i m practising C++. i just add c++ files in XCode and write some
gcc I am just getting back into c programming and I am just practicing
I just got into python very recently and now I'm practicing by (what I

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.