All Questions
85 questions
2
votes
3
answers
951
views
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 ...
1
vote
2
answers
127
views
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 ...
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....
0
votes
2
answers
192
views
Best way of creating different instance types(facotry method) with business logic?
Say I am trying instantiate an instance of a Table. Table here denotes a restaurant table used for eating. Say I have 3 different table types
enum TableTypes {
SMALL,
MED,
LARGE
}
I have ...
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 ...
0
votes
3
answers
662
views
Java Library - How to do Pure Dependency Injection When State is a Factor?
To set the stage, I am trying to do pure dependency injection for a Java Library I am creating to make it more testable. As it is a library, I want to do pure dependency injection without creating a ...
0
votes
1
answer
118
views
Interface design for container that holds different instances derived from a common type
I'm currently designing an interface for a container that is supposed to store references of different instances that derived from a common supertype. An analogy of it would be as following:
Suppose ...
3
votes
4
answers
780
views
Is it a bad practice to have an interface method to tell whether it can handle an object?
interface Resolver {
boolean canResolve(SomeInput input);
SomeOutput resolve(SomeInput input);
}
public static void main(String[] args) {
List<Resolver> resolvers = ...;
...
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 ...
4
votes
2
answers
3k
views
Factory pattern where some classes require additional paremeter(s)?
We have multiple publishers, that publish the data somewhere. For example, we have ElasticSearch publisher, AWS S3 publisher, or file publisher.
Now the interface looks like this
interface Publisher&...
6
votes
1
answer
437
views
Should operations on properties of list objects be encapsulated in a domain class that wraps the list?
I have a list of product price objects, List<ProductPrice>.
@Value
public class ProductPrice {
Long id;
LocalDate startDate;
LocalDate endDate;
BigDecimal value;
}
From ...
0
votes
2
answers
1k
views
Which design pattern to use to make a mix of in-sequence and parallel HTTP calls?
We have to make a bunch of HTTP calls from Java/Spring-Boot application which will be mix of in-sequence and parallel.
Level 1 : We make 3 parallel calls to Services 1 , 2 and 3
Level 2: After service ...
4
votes
3
answers
1k
views
Passing object or using the field
I would like to know what is a more appropriate way to code in Java. Is it generally better to pass entire objects in the method's parameters or just using the fields from the class?
Using the field:
...
7
votes
2
answers
453
views
DRY polymorphic object creation (always valid)
Assuming we have polymorphic entities such as the following, with constructors enforcing invariants (assume there could be lots of sub-classes). What would be an effective/elegant approach to ...
4
votes
2
answers
147
views
How do I trigger conditional post processing action without violating SRP?
I have a User Model as below, this Model class is in the shared library.
class User {
private long userId;
private String email;
private String userType;
private long departmentId;
...