Skip to main content

All Questions

-1votes
1answer
204views

Which pattern is suitable for this scenario?

I would like to refactor some code of a process that must perform a processing. The processing involves several steps, each of which can fail or go well. If successful, it must proceed to the next ...
jordan1982's user avatar
3votes
1answer
153views

Deciding on granularity of SOLID's SRP

I am currently working in a project where we are utilizing kafka as a Message Queue. We have two use cases here, one is to consume the messages in parallel, no ordering of any kind required. And one ...
Akshansh Jain's user avatar
2votes
3answers
951views

Is breaking encapsulation a necessary compromise for serialization?

I've been considering the way to solve this problem for a while, and I'm currently stuck between two options I both feel are suboptimal. Here's an abstract example of what I'm dealing with: I have a ...
pulpicated's user avatar
23votes
5answers
17kviews

Are "factory methods" anti-pattern now?

I consider Joshua Bloch's Effective Java the best book on the language that I read. However, I started to wonder about something One of the things he suggested was to prefer public static factory ...
demavi's user avatar
2votes
4answers
345views

Builder with non-defaultable required args

Suppose a class needs multiple properties of the same type. I don't want a big constructor where the user can mess up the order of args (remember, they are of the same type, no compile-time errors) ...
Sergey Zolotarev's user avatar
5votes
6answers
2kviews

Is it a good idea to return a Builder from a Factory?

I would want to have a builder for creating a complex object, for example Employee. I would want to be able to create my objects in two ways: Case 1. Get Employee with default values Case 2. Get ...
CuriousGuy's user avatar
6votes
7answers
7kviews

How to avoid repeating "a==b" when comparing "condition a" and then "condition b" and then...?

For example, I have an object: public class Obj{ public int a; public float b; public String c; } I need to find best "Obj": largest a and then largest b and then longest c: int ...
wcminipgasker2023's user avatar
4votes
4answers
1kviews

How to do "Separation of concerns"

I understood(edit: I assume) the importance of seperation of concerns and benifits in an application, But struggling to identify what are considered to be a concern (developer, feature, consumer or ...
Karthi Fair Hawn's user avatar
5votes
1answer
307views

What do you call an enum that translates its own values?

I see this pattern a lot, especially with countries, or more generally regions. An enum is defined with additional fields and with methods that translate to and from these values. Example: import ...
user2740's user avatar
3votes
4answers
1kviews

Representing vectors as arrays of points vs. as data structures

I'm writing a program in Java where I need to represent the position, scale, and other 3-dimensional properties of objects in a world using vectors. I can use either of these two approaches: ...
Bunabyte's user avatar
3votes
9answers
4kviews

Is it an anti-pattern to use interface for entity?

I read an article about that using an interface for an entity is an anti-pattern for these reasons: Your interface signature is identical to your class. There’s only one implementation of your ...
Mercury's user avatar
179votes
6answers
303kviews

What is the point of using DTO (Data Transfer Objects)?

What is the point of using DTO and is it an out dated concept? I use POJOs in the view layer to transfer and persist data. Can these POJOs be considered as an alternative to DTOs?
Vinoth Kumar C M's user avatar
28votes
9answers
7kviews

Coupling: Theory vs Reality

Coupling is defined as the knowledge one object has about another one, which describes how dependent they are. The more dependent, the worse, since changes in one would impact in the second. High ...
Asier Naiz's user avatar
37votes
9answers
18kviews

Why do we need a Builder class when implementing a Builder pattern?

I have seen many implementations of the Builder pattern (mainly in Java). All of them have an entity class (let's say a Person class), and a builder class PersonBuilder. The builder "stacks" a variety ...
Boyan Kushlev's user avatar
1vote
2answers
127views

How do I reduce number of FieldValidator derivations?

I am trying to write RSQL Parser which checks if the RSQL is logically correct. while the RSQL Java library checks whether the RSQL expression is grammatically correct, it doesn't check if the ...
Govinda Sakhare's user avatar

153050per page
close