Questions tagged [java]
Java is a high-level, platform-independent, object-oriented programming language originally developed by Sun Microsystems. Java is currently owned by Oracle, which purchased Sun in 2010.
5,006 questions
2
votes
3
answers
123
views
Domain data classes with fluid property lists
Is it fine for your data models to have a sort of "open-ended" list of properties?
For example, you may have some Employee:
// getters, setters, annotations are omitted
public class Employee ...
0
votes
0
answers
89
views
+50
How should ViewModels and Services communicate in a JavaFX + Spring Boot MVVM application?
I'm building a JavaFX + Spring Boot application using the MVVM pattern.
Problem
I have two ViewModels:
SharedLoginViewModel: Manages the workflow state (e.g., login process, step transitions).
...
18
votes
5
answers
4k
views
Why should I never ever ever use Java serialization?
I've heard that I should never use Java serialization (Serializable/ObjectInputStream/ObjectOutputStream) because of security. What's the problem?
2
votes
3
answers
310
views
Naming convention for boolean returning methods
There's a convention for boolean property accessors to name them like isX().
Does it apply to all boolean returning methods that are not invoked for their useful side effects, like this one?
Also, ...
3
votes
2
answers
223
views
Why do I need an authorisation server if my micro services can validate JWTs directly?
I'm working on a Spring-based micro service project and considering different approaches for handling authentication and authorisation. Instead of setting up a dedicated authorisation server, I’m ...
-1
votes
1
answer
203
views
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 ...
8
votes
7
answers
5k
views
Must getters return values as is?
We have entities with numeric properties, they are of boxed types (e.g. Integer). Typically, each of those properties has a pair of getters: getInt(), which returns zero on null values, and ...
1
vote
2
answers
96
views
I'm confused how to structure my pom.xml when both Parent and Child modules are being developed simultaneously
Let's say I have the following maven projects.
UtilsLibrary -- A maven project containing utils.
AppA -- A maven project that depends on UtilsLibrary.
AppB -- A maven project that depends on ...
1
vote
4
answers
180
views
Ensuring type safety, honoring supertype contract
Due to type erasure, I can't do instanceof T in Java. With that in mind, how do (should) I write, for example, a generic TreeNode (or, more precisely, DefaultMutableTreeNode)? setUserObject() accepts ...
5
votes
5
answers
910
views
Handling class specific behavior: polymorphism vs instanceof
I'm designing a system with different types of components, and I'm trying to decide whether to use polymorphism or instanceof checks for handling type-specific behavior.
I see two possible approaches:
...
0
votes
2
answers
325
views
Which is better: a chain of OR statements or IF in a loop? (Java)
Which code style is preferred in Java?
final boolean result = isCausedBy(e, ExceptionType1.class)
|| isCausedBy(e, ExceptionType2.class)
|| isCausedBy(e, ExceptionType3.class)
|...
5
votes
4
answers
302
views
Ugly nested parameterizations
Suppose there's a long IO operation that may result in some return value — but doesn't have to. Completion with no return value is different from the operation being pending.
Do I have better options ...
3
votes
1
answer
153
views
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 ...
4
votes
4
answers
393
views
Documenting properties
Suppose I have a property with an associated getter and setter (the property is not exposed directly)
Where should I describe the property?
The field javadoc
The getter javadoc
The setter javadoc
...
3
votes
4
answers
2k
views
Avoiding instanceofs with GUI composites
I have a stack of custom Row widgets. Each of them is a label with some editComponent (often a JTextComponent). Rows are aware of their previous and next siblings (if a Row has no such sibling, the ...