Skip to main content

All Questions

6 votes
4 answers
35k views

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 ...
madan's user avatar
  • 127
5 votes
2 answers
8k views

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 ...
Shad's user avatar
  • 61
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: ...
max's user avatar
  • 163
4 votes
2 answers
3k views

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 ...
devkaoru's user avatar
  • 149
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 = ...; ...
Martin Tarjányi's user avatar
2 votes
5 answers
1k views

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 ...
jarer's user avatar
  • 31
1 vote
1 answer
333 views

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 ...
sinθ's user avatar
  • 1,311
0 votes
3 answers
3k views

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 ...
GokcenG's user avatar
  • 109