Skip to main content

All Questions

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....
Paul Marcelin Bejan's user avatar
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 ...
Johnyb's user avatar
  • 407
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 ...
Tom Taylor's user avatar
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 ...
Kee's user avatar
  • 13
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 ...
Diggi55's user avatar
  • 151
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 ...
Youans's user avatar
  • 481
7 votes
4 answers
2k views

Why aren't OOP design patterns included in the standard libraries?

I have a question similar to this other question Why aren't design patterns added to the languages constructs? Why isn't there java.util.Singleton and then we inherit it? The boilerplate code ...
Niklas Rosencrantz's user avatar
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 ...
user2330678's user avatar
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 ...
Jordan's user avatar
  • 63
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 ...
Wojtek Wencel's user avatar
4 votes
4 answers
4k views

Is Template design pattern a bad practice due to inheritance?

I have been using Template Design pattern in my code for implementing CRUD procedures for different resources. There are some steps which are same for many resources and some which need some addition/...
Siddharth Trikha's user avatar
-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 ...
Johnyb's user avatar
  • 407
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 ...
AnOldSoul's user avatar
  • 173
25 votes
7 answers
14k views

Difference between Pattern and Principle

What is the difference between Object Oriented Design Patterns and Principles? Are they different things? As far as I understood both of them try to achieve some common goal (e,g. flexibility). So can ...
Chandi Gorom's user avatar
25 votes
5 answers
69k views

Best way to load application settings

A simple way to keep the settings of a Java application is represented by a text file with ".properties" extension containing the identifier of each setting associated with a specific value (this ...
enzom83's user avatar
  • 513

15 30 50 per page
1
2 3 4 5
7