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
2votes
3answers
118views
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 ...
0votes
0answers
86views
+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). ...
18votes
5answers
4kviews
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?
2votes
3answers
308views
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, ...
3votes
2answers
223views
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 ...
-1votes
1answer
203views
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 ...
8votes
7answers
5kviews
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 ...
1vote
2answers
95views
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 ...
1vote
4answers
180views
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 ...
5votes
5answers
909views
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: ...
0votes
2answers
325views
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) |...
5votes
4answers
302views
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 ...
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 ...
4votes
4answers
393views
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 ...
3votes
4answers
2kviews
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 ...