All Questions
98 questions
16
votes
7
answers
44k
views
What is the better way to escape from too many if/else-if from the following code snippet?
I am trying to write a servlet which does task based on the "action" value passed it to as input.
Here is the sample of which
public class SampleClass extends HttpServlet {
public static void ...
6
votes
2
answers
3k
views
Trouble with circular dependency in state machine design
I am trying to develop the structure for a basic state machine that can also take in input and produce output. I've hit a bit of a mental block in trying to figure out how to model the relationship ...
0
votes
0
answers
98
views
By creating an architecture, it is better to have many classes that handles different scenarios, or a single one that handles all? [duplicate]
During my limited professional experience, I have been involved in microservices projects with a common structure:
The Controller takes a request and validates it using the jakarta.validation....
2
votes
1
answer
274
views
Is it OK to deprecate methods that need to be public due to the packaging model but are not to be used outside the codebase in Java?
I am currently working on a semi-large project that has several packages. There are 3 main packages, a "client" package, a "server" package and a "common" package. There are two jars, one for the ...
7
votes
5
answers
3k
views
Design pattern for 2 methods one has 70% arguments of other one
I am trying to do a design for notification part in the system I have 2 parts inApp notification and email notification so I used strategy pattern where I have interface NotificationSender with one ...
0
votes
1
answer
1k
views
Pattern to convert different types of similar unchangeable objects to the same object
I have an existing system that inserts books into a library database, and I want to generalize it to include other media.
The other media is similar, but not exactly the same, and all media are third ...
5
votes
1
answer
1k
views
Why do we implement the Command design pattern like this?
I trying to learn the Command design pattern, I already know how it works and where it is used, but I'm a little bit confused about the implementation.
So I know we need to set the context by ...
-1
votes
2
answers
336
views
Implementation of method differs only in one line
I have 2 implementation of the interface:
public interface MyInterface{
void getCollectedData(MyData mydata);
}
public class MyImpl implements MyInterface{
public void getCollectedData(MyData ...
1
vote
4
answers
779
views
Best way to display domain object summary information efficiently and in an OO way from a large inheritance tree?
I've provided only simplified code as it's more of an abstract design question.
So I have many, many nested business/domain event objects, e.g.
public class Event
{
//bunch of properties and ...
1
vote
2
answers
385
views
Are experienced developers and software architects able to describe an entire software application in terms of design patterns?
Do experienced developers and software architects see entire application in terms of design patterns?
In other words experienced developers and software architects able to describe an entire software ...
8
votes
5
answers
4k
views
Interface implementation where one method body remains empty
I have producers that take data A, produce data B and send it
public interface Producer<T>{
void produce(T data);
void flush();
}
public class DataBaseProducer ...
2
votes
1
answer
334
views
Composition or Inheritance for classes with almost similar implementations but different input and outputs for methods?
I have the following classes, which have quite similar method implementations. Only the classes' method inputs and outputs seem to be of different types. When I put it like this, it sounds like a case ...
4
votes
3
answers
4k
views
What about Utility-Classes, but without hard dependencies?
The average utility class: A stateless class that provides some functionality by exposing static methods. Its default constructor is private to avoid instantiation. When ever the average utility class ...
1
vote
2
answers
122
views
Designing UI module for an application
I have an UI module that will expose only one class - UserInterface. The class will be responsible for collecting user input and providing output (command line UI style). From logical way of thinking, ...
0
votes
1
answer
2k
views
Injecting DAO dependencies into Service Class in Core Java
We don't have any frameworj like Spring where we can inject dependencies using annotations or xml file.
We have handler classes, service classes and dao classes.
Handler classes access service which ...