All Questions
8 questions
3votes
4answers
780views
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 = ...; ...
4votes
3answers
1kviews
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: ...
2votes
5answers
1kviews
What should a constructor contain?
What should a constructor contain? In both cases, all three arguments are needed for the class to work. Which approach is better and why? 1) class Language { LanguageRepository ...
4votes
2answers
3kviews
Separating Read / Write Responsibilities of a DB
We're working on a reporting system which has a clear write and a read path. For example writes will only happen after consuming events from a queue and reads will only happen when serving requests ...
5votes
2answers
8kviews
Design pattern for processing a huge CSV file -- Java
I am learning design patterns in Java and also working on a problem where I need to handle huge number of requests streaming into my program from a huge CSV file on the disk. Each CSV line is one ...
6votes
4answers
35kviews
A DTO class having an ArrayList of its own type - is this considered a good design?
I came across a DTO class like the below one. class PersonDTO { private String firstName; private String middleName; private String lastName; private String dob; // some 50 fields ...
0votes
3answers
3kviews
Wrapping a map with instance or static method
I have a java.util.Map<String, Object> object which different types of values in it. I don't want to cast whereever I do a get operation over this. To do this, I created different classes ...
1vote
1answer
333views
Creating Set Subclasses or Allowing Outside Configuration
I have a TriggerCaller and a TriggerAction class. The Caller "calls" the do() method on the action, which is set with the TriggerCallers setAction() method. The rest of the program should deal with ...