Skip to main content

All Questions

1vote
1answer
234views

Refactoring instanceOf, moving logic to POJO when it has database interaction

I'm refactoring some old code, I have a lot of istanceOf in the business part: if (record instanceof RecordA) { RecordA recordA = (RecordA) record; ...
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 ...
0votes
6answers
247views

Adding client specific method to a listener interface is a good idea?

I'm using a listener pattern where a class A listens for events from various classes B, C, D with the help of a listener interface I Essentially the structure looks like: interface I { void ...
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 ...
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 ...
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 ...
0votes
3answers
368views

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 ...
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 ...
1vote
2answers
328views

Is this one method interface a good response to this interview question?

Today I received a rejection letter from a company where as part of the interview process they gave a a couple days to respond to the following question (paraphrased): Let’s say say you have ...
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. ...
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 ...
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 ...
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" ...
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 ...
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 ...

153050per page
close