Skip to main content

All Questions

152votes
6answers
118kviews

What is the point of having every service class have an interface? [duplicate]

At the company I work at, every service class has a corresponding interface. Is this necessary? Notes: Most of these interfaces are only used by a single class We are not creating any sort of ...
Bob Roberts's user avatar
13votes
5answers
10kviews

Modified Strategy Design Pattern

I've started looking into Design Patterns recently, and one thing I'm coding would suit the Strategy pattern perfectly, except for one small difference. Essentially, some (but not all) of my ...
Megan Walker's user avatar
11votes
9answers
5kviews

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, ...
Blundell's user avatar
11votes
5answers
3kviews

Separate interface for mutation methods

I've been working on refactoring some code, and I think I may have taken the first step down the rabbit hole. I'm writing the example in Java, but I suppose it could be agnostic. I have an interface ...
Zymus's user avatar
  • 2,533
9votes
4answers
5kviews

How to force "program to an interface" without using a java Interface in java 1.6

In java 1.8 they have wonderful new "default interface methods". In 1.6 how close can we come? The goal: use code to keep clients from being able to tell that a class is not a java interface. If we ...
candied_orange's user avatar
8votes
2answers
864views

Optional features: default method or separated interface

Dedicated interfaces seems to be a good way to expose the optional features in a domain-specific type hierarchy. However, they impede the use of decorator and composite patterns, which is also common ...
billc.cn's user avatar
4votes
3answers
6kviews

Communicating to an Object from another without coupling in java?

So I have a Person object, and a GumballMachine object. The behavior I'm searching for is, in the intent to avoid unnecessary coupling, have the method insertCoin() called from within the Person ...
user avatar
3votes
4answers
6kviews

Implements > extends, but what about variables?

It's preferable to write programs that depend on interfaces rather than on superclasses, but what if you want a class to have certain variables? Sometimes you want a class to implement a certain ...
Dylan Meeus's user avatar
3votes
3answers
2kviews

Preemptive interfaces in Java - good, bad or "a matter of taste"

I frequently come across projects that strictly define an interface for each and every class. 90% of those interfaces feature only a single implementation. Proponents of these "preemptive interfacs" ...
Fritz Duchardt's user avatar
3votes
5answers
2kviews

Explanation of the definition of interface inheritance as described in GoF book

I am reading the first chapter of the Gof book. Section 1.6 discusses about class vs interface inheritance: Class versus Interface Inheritance It's important to understand the difference between an ...
Geek's user avatar
  • 5,217
3votes
1answer
4kviews

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 ...
Eoin's user avatar
  • 141
3votes
1answer
184views

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
3votes
1answer
540views

Contract interface/class with inner classes/interfaces

Brief description of my project structure. I have some base classes like BaseView, BasePresenter ... . Also my project consists of modules, module represents one complete part of the application. ...
CROSP's user avatar
  • 1,558
2votes
1answer
204views

Is it allowed to include the composition in the compositor in the Strategy Pattern

I have a range of different animals in my zoo such as turtles, birds etc. As they all share a common trait such as either swimming, flying etc., I thought a strategy pattern would be appropriate to ...
Tyler D's user avatar
2votes
5answers
1kviews

Facade pattern or just expose child objects?

Wondering about pros and cons around a facade pattern implementation (or perhaps there is a better pattern I should consider), versus simply exposing a dependent object to a caller. Consider the ...
gdbj's user avatar
  • 123

153050per page
close