Skip to main content

All Questions

Tagged with
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 ...
user3479586's user avatar
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 ...
radian's user avatar
  • 103
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 ...
Tommy Andersen's user avatar
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(...
Dioxin's user avatar
  • 953
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 ...
Falcon's user avatar
  • 3
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 ...
c2340878's user avatar
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 ...
Daniel Jour's user avatar
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 ?...
nikartix's user avatar
  • 259
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 ...
dmux's user avatar
  • 151
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" ...
Luca Fülbier's user avatar
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 ...
Mike's user avatar
  • 135
-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 ...
overexchange's user avatar
  • 2,305
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 ...
overexchange's user avatar
  • 2,305
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); } ...
Tavian Barnes's user avatar
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 ...
Hilikus's user avatar
  • 119

15 30 50 per page