All Questions
19 questions
0
votes
4
answers
185
views
When to pass a concrete object, vs a way to obtain the object
Say there is some view that displays user details like name, age, email, etc. That view could maybe be constructed with the following pseudocode:
UserView(User user);
And that view would be able to ...
3
votes
1
answer
6k
views
Using generics on interfaces when implementation is not generic
Is it acceptable practice to put generics on an interface when the implementation will not be generic? Lets say that my project will have many classes that read data from the database. I may make a ...
0
votes
2
answers
580
views
Hiding implementation framework usage in an API
I am currenctly trying to create an API for a UI framework, for a new application. This UI framework is internally implemented using an existing framework, let us say JavaFX. I want to hide the ...
11
votes
1
answer
3k
views
Why doesn't CharSequence define contains(CharSequence)?
This applies to to both Java SE & Android, as the contracts are identical.
CharSequence documentation for Java SE
CharSequence documentation for Android
CharSequence does not define a contains(...
0
votes
1
answer
1k
views
Interface design of Java library with interdependent yet decoupled packages
I plan to write a library in Java, consisting of packages A, B, C and so on. Every package encapsulates a part of the big picture. B relies on A, C on B and so on. For this purpose every package ...
3
votes
2
answers
209
views
Is it a good practice if using Object when a method can accept more than one type of object?
public class TaskA implements Runnable {
....
}
public class TaskB implements Runnable {
....
}
I have two runnable class as TaskA, TaskB. I want to have a TaskManager to run these two tasks and have ...
6
votes
4
answers
1k
views
Evolving an interface that is not supposed to be implemented by the client
I'm about to write a Java library. Basically, this library provides something like this to its user:
interface Foo {
void doA();
boolean aWorked();
void doB(int value);
}
The user is not ...
9
votes
3
answers
3k
views
Is it OK for interfaces to depend on concrete classes?
I am creating interface in Java for custom error handler.
Want to pass an argument error object but I need it to be child of Exception class.
Is it okay to use my defined class name in an interface ?...
3
votes
1
answer
184
views
Leo Brodie's "Interface Component"
On page 85 of Leo Brodie's book, Thinking Forth, he describes a component which he calls the "Interface Component." He describes its differences from, and benefits over a standard interface ...
0
votes
0
answers
599
views
Using java interfaces to narrow the classes public interface
There is a lot of content on the web discussing if it is worth defining an interface if only one class implements it. The answers are mostly either "Yes, because you probably need to mock it anyways" ...
2
votes
1
answer
617
views
Define an object with the interface as a type instead of class name [duplicate]
I try to practice with the design patterns and explore one of the possible implementations of the Observer Design Pattern in Java. I paid attention, that in this example the object is defined with the ...
-4
votes
2
answers
192
views
Advantages of these recommendations in ooprogramming using Java
Below are the recommendation from section 5.1 of this essay.
While Java is not a pure object-oriented language, it is possible to program in a pure object-oriented style by obeying the following ...
1
vote
3
answers
4k
views
Why List<E> interface is additionally introduced in collection hierarchy? [duplicate]
Below is the diagram, where, if we just consider the implementations of List,
AbstractList maintains the core behavior of list. To introduce the new implementation class MyList(say) one can inherit ...
16
votes
1
answer
3k
views
Is it good practice to implement two Java 8 default methods in terms of each other?
I'm designing an interface with two related methods, similar to this:
public interface ThingComputer {
default Thing computeFirstThing() {
return computeAllThings().get(0);
}
...
1
vote
2
answers
181
views
Cleanest choice for symmetric operations
I have a need to do some processing from a format A to a format B and from B to A. The job in one direction is very similar to its counterpart. Both formats are represented with an interface Msg.
In ...