I am doing a swing based application where I use JTable
. I used DefaultCellEditor
for one of the column which requires combo box selection. But DefaultCellEditor
has many methods which I don't require. So I wrote a custom CellEditor by extending AbstractCellEditor
where I have implemented only the required methods. My question is
(in general) if we have a class and if we don't require all the methods of that class is it fine to use it or is it good to write a custom class where we implement only those methods which we require? and
by using custom class will the performance (memory wise) of the application will be improved or it remains same as the class which has all the methods?
Any help will be appreciated.
Unless you have seriously good grounds for believing that nothing else in the application including the JDK itself uses DefaultCellEditor,
you are almost certainly wasting your time by making things actively worse.
You also need to consider that you might have saved maybe 100k of code in extreme cases, where typical JVMS use around a gigabyte to execute. So you may have saved 0.01% of code space. This is not a productive use of your time. The correct procedure is to test and measure where the time and space bottlenecks really are, after the fact. Programmers are notoriously poor at predicting these things.