Tagged Questions
3
votes
2answers
176 views
Tricky compareTo, inheritance, easy to extend - Java
Let's say we have 4 classes A, B, C, D where: A is a superclass of both B and C and C is a superclass of D. I suppose, in a diagram, it should look like this:
A
/ \
B C
\
D
...
4
votes
2answers
247 views
Why Java does not support private/protected inheritance like C++? [closed]
While inheriting a class in C++, user can specify the access specifier like,
class Base
{
public int mem1;
protected in mem2;
};
class Derived1 : **private** Base
{
// mem1 will be ...
2
votes
2answers
93 views
Template method within one class without subclasses or inheritance
I have an algorithm with mostly invariant parts that needs to be reused within one class so as to stay DRY.
Code duplication with repeating method structure
public void save(String key, int value) ...
3
votes
5answers
742 views
Why does Java allow to implement different interfaces, each containing a method with the same signature?
I recently found out that I can have two interfaces, one containing a method with the same signature as a method in the other interface. And I can have an interface or class that implements both of ...
4
votes
2answers
335 views
Naming methods that do the same thing but return different types
Let's assume that I'm extending a graphical file chooser class (JFileChooser).
This class has methods which display the file chooser dialog and return a status signature in the form of an int: ...
7
votes
9answers
923 views
What OO Design to use ( is there a Design Pattern )?
I have two objects that represent a 'Bar/Club' ( a place where you drink/socialise).
In one scenario I need the bar name, address, distance, slogon
In another scenario I need the bar name, address, ...
37
votes
11answers
3k views
Why is it good to split a program into multiple classes?
I'm still a student in high school (entering 10th grade), and I have yet to take an actual computer course in school. Everything I've done so far is through books. Those books have taught me concepts ...
6
votes
5answers
359 views
Java without implementation inheritance
In a recent video on Java, Joshua Bloch states at 4 minutes 20 seconds into the video:
And then there's inheritance, and that was a marketing necessity. You know, we can argue whether you really ...