All Questions
24 questions
1
vote
1
answer
234
views
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;
...
2
votes
1
answer
204
views
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 ...
0
votes
6
answers
247
views
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 ...
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 ...
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 ...
2
votes
5
answers
1k
views
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 ...
1
vote
2
answers
328
views
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 ...
3
votes
1
answer
540
views
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.
...
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 ...
3
votes
3
answers
2k
views
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" ...
4
votes
3
answers
6k
views
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 ...
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 ...
8
votes
2
answers
864
views
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 ...
-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 ...
11
votes
5
answers
3k
views
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 ...