Results 1 to 4 of 4
Thread: ArrayList or class ?
- 10-30-2012, 06:50 PM #1
Member
- Join Date
- Aug 2010
- Location
- Leuven, Belgium
- Posts
- 79
- Rep Power
- 0
ArrayList or class ?
Hi,
I have a class with options for a device.
This class contains the name and some info.
I want to include these opions in a device.
Is it beter to include an ArrayList<Option> in the device class or to create a class that contains this arrayList and to include this class into the device class
orJava Code:private ArrayList<Option> options;
Kind regardsJava Code:private Options options;
Dipke
- 10-30-2012, 06:59 PM #2
Re: ArrayList or class ?
It depends on your use-case. If you plan on having operations that manipulate the collect (like sorting, or custom things) and you want this functionality to follow the collection around (like a data structure, think trees or maps or the like), then make a class. If the only thing you ever do is just hold the collection, and maybe send it somewhere (like for printing, or saving or whatever), then just keeping an ArrayList<type> is fine.
So, it really depends on your requirements. Adding abstraction for the sake of abstraction is bad. Abstract things if and only if it makes more sense and improves the readability, maintainability, or functionality of the system.
- 10-30-2012, 07:29 PM #3
Member
- Join Date
- Aug 2010
- Location
- Leuven, Belgium
- Posts
- 79
- Rep Power
- 0
Re: ArrayList or class ?
Hi,
In fact there are some manupilations like adding with equal check but there is no need for using this elsewhere.
So i will use an ArrayList.
Thanks for the answer
Kind regards
Dipke
- 10-30-2012, 07:31 PM #4
Similar Threads
-
Access ArrayList from another class!!!
By hassaanid2012 in forum New To JavaReplies: 7Last Post: 04-15-2012, 03:00 PM -
Getting a second, third, fourth arraylist from a class
By Paul_White in forum New To JavaReplies: 3Last Post: 12-02-2011, 04:10 AM -
Get an ArrayList from another class
By ScienceLife in forum New To JavaReplies: 5Last Post: 04-09-2011, 10:13 AM -
Java Arraylist (.get from other class)
By Kingarmy in forum New To JavaReplies: 1Last Post: 12-28-2010, 08:00 PM -
Help passing arraylist to another class
By adlb1300 in forum New To JavaReplies: 3Last Post: 11-06-2007, 08:02 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks