All Questions
11 questions
0
votes
1
answer
1k
views
Interfaces vs abstract classes for immutable DTOs
At my org we extensively use @Value.Immutable annotation to generate Immutable classes (usually with builders) for our internal data transfer objects (DTOs). In our codebase I've seen both interfaces ...
9
votes
4
answers
3k
views
OOP Design considering no modifications to existing design
The question is:
interface Animal {
void eat();
}
class Lion implements Animal{
public void eat(){
//do somethng
}
}
class Test {
public static void main(String[] args) {
...
1
vote
5
answers
8k
views
When should i use an abstract class vs an interface? [duplicate]
I'm fairly new to programming. At school I am currently learning to program with Java. I want to build an application where i can store my collection of books, records, boardgames and such. Started ...
3
votes
1
answer
4k
views
Should an abstract class implement an interface, as opposed to defining its own abstract methods?
I'm defining a class structure for persisting to our cassandra database, and I'm unsure about using a combination of an abstract class and an interface. I have two concrete classes, one for persisting ...
4
votes
2
answers
111
views
How are settings structured when they can be configured in diffferent ways?
Suppose of this question the following:
I'm in full control of this project
I'm writing a media player
Obviously, a media player will allow a user to adjust the volume, so I might have a class that ...
0
votes
3
answers
368
views
Send records using async or sync way
I have bunch of keys and values that I want to send to our messaging queue by packing them in one byte array. I will make one byte array of all the keys and values which should always be less than 50K ...
-1
votes
3
answers
2k
views
Can I say Interface is a set of general behavior? [duplicate]
I'm new to OOP. Can I say Interface is a set of general behavior that may be have and act uniquely by a set of objects that have in common? And Abstract class has similarity with Interface but it have ...
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 ...
15
votes
3
answers
11k
views
Should I implement an interface directly or have the superclass do it?
Is there a difference between
public class A extends AbstractB implements C
{...}
versus...
public class A extends AbstractB
{...}
abstract class AbstractB implements C
{...}
I understand that in ...
13
votes
4
answers
2k
views
Is there a different usage rationale for abstract classes/interfaces in C++ and Java
According to Herb Sutter one should prefer abstract interfaces (all pure virtual functions) to abstract classes in C++ to decouple the implementation as far as possible. While I personally find this ...
0
votes
2
answers
5k
views
What other reasons are there to write interfaces rather than abstract classes? [duplicate]
Possible Duplicate:
When to use abstract classes instead of interfaces and extension methods in C#?
When I read and looked at codes using Abstract classes, I was able to justify it because it ...