-
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
Code:
private ArrayList<Option> options;
or
Code:
private Options options;
Kind regards
Dipke
-
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.
-
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
-
Re: ArrayList or class ?