Linked Questions

45 votes
10 answers

Why use an interface when the class can directly implement the functions? [duplicate]

Possible Duplicate: Why are interfaces useful? Like most faculty, my java faculty introduced interface without explaining or even mentioning its practical use. Now I imagine interfaces have a ...
SoWhat's user avatar
  • 561
2 votes
3 answers

Why should I use interfaces if the implementation will mostly stay the same? [duplicate]

Possible Duplicate: Why are interfaces useful? In our company we have a service oriented architecture in our application. We use interfaces for every crap class. Its a huge overhead. The ...
msfanboy's user avatar
  • 191
0 votes
4 answers

When to make a method part of an interface or a concrete implementation? [duplicate]

I create an interface for database access to a MySQL database. Currently, this is the only way to access day, but to make it easier to test and in the event that the data access might change, I used ...
xaisoft's user avatar
  • 445
2 votes
1 answer

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
0 votes
2 answers

Is using interfaces on internal code a good idea? [duplicate]

I'm working on a set of automated tests that we use internally at work. Lately, we've been designing classes that implement interfaces in addition to inheritance. As I understand it, interfaces in ...
joshin4colours's user avatar
42 votes
6 answers

Understanding "programming to an interface"

I have come across the term "programming to an interface instead of an implementation" a lot, and I think I kind of understand what it means. But I want to make sure I understand it's benefits and it'...
Aviv Cohn's user avatar
  • 21.4k
36 votes
6 answers

What's the point of implementing a Stack using two queues?

I have the following homework question: Implement the stack methods push(x) and pop() using two queues. This seems odd to me because: A Stack is a (LIFO) queue I don't see why you would need two ...
Carcigenicate's user avatar
3 votes
2 answers

Why we use interface since we need to implement the method in our derived class [closed]

I have read the replies from those post(Why are interfaces useful?) and (Why use an interface when the class can directly implement the functions?), which is the similar question as my this post. But ...
FullStackDeveloper's user avatar
1 vote
6 answers

Interfaces: profit of using

First of all, my ubiquitous language is PHP, and I'm thinking about learning Java. So let me split my question on two closely related parts. Here goes the first part. Say I have a domain-model ...
Vadim Samokhin's user avatar
0 votes
2 answers

Use case for interface

While going through some lecture video on interface. I noticed If we don't know about implementation, just requirement specification then go for interface. What can be the scenario? Though I've ...
Surya Bhusal's user avatar
3 votes
3 answers

Fruit obj=new Orange(); and Orange obj=new Orange(); if both works identically in my code, which is the less coupling one?

Suppose I have 2 classes (which don't show methods to look simpler): public interface Fruit{ } public class Orange implements Fruit{ } , and assume I can use 2 ways to initialize Orange without ...
aacceeggiikk's user avatar