All Questions
19 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: ...
3votes
2answers
207views
Checking the user in almost all use cases
I have a web application that has Users that belong to Companies. A User can only belong to 1 Company at a time and they can manage their own company information. I'm using java spring and I'm ...
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 ...
2votes
1answer
274views
Is it OK to deprecate methods that need to be public due to the packaging model but are not to be used outside the codebase in Java?
I am currently working on a semi-large project that has several packages. There are 3 main packages, a "client" package, a "server" package and a "common" package. There are two jars, one for the ...
1vote
1answer
746views
Where and how to connect to external API in my service class?
In my service class I would like to connect to external API. Where and how should I do it? 1) Inject in constructor ExternalClass and assign to private property. Next in other property in constructor ...
4votes
2answers
194views
Should I write a wrapper within a manager object?
I have three classes that work together to do one function (from the perspective of the rest of my program). There is a little bit of set up between them, so, to make it easier for the rest of my ...
3votes
2answers
3kviews
Using MVC style, where is the best place to put SQL functionality?
I am wondering about best practices here. MVC (Model - View - Controller) patterns involve separating components of your program that model the data, manipulate those models, and display those ...
2votes
3answers
205views
Data duplication, can it be an unavoidable practice in this example?
Say I have different employees of type Employee stored in a list inside a class SubCase. public class SubCase{ protected ArrayList<Employee> employees; ... } SubCase represents a part ...
3votes
1answer
540views
Contract interface/class with inner classes/interfaces
Brief description of my project structure. I have some base classes like BaseView, BasePresenter ... . Also my project consists of modules, module represents one complete part of the application. ...
4votes
2answers
5kviews
How to delete an object when other things reference it (and not making the code full of inter-dependencies)
The situation: In my program, there are a list of cues. To call a cue at a certain time, there are objects called Triggers. Cues have many public methods that allow them, among other things, to be "...
4votes
3answers
4kviews
What is the preferred access modifier for instance variables of a data transfer object?
I'm creating a data transfer object and can't decide whether it would be better to just give public access to the instance variables or if there would be a purpose to using getters and setters to ...
3votes
2answers
2kviews
Lazy Processing of Streams
I have the following problem scenario: I have a text file and I have to read it and split it into lines. Some lines might need to be dropped (according to criteria that are not fixed). The lines that ...
3votes
3answers
2kviews
Parallel Class/Interface Hierarchy with the Facade Design Pattern?
About a third of my code is wrapped inside a Facade class. Note that this isn't a "God" class, but actually represents a single thing (called a Line). Naturally, it delegates responsibilities to the ...
1vote
1answer
182views
Better way to organize query methods in Android?
In my Android app I have: A SQLiteHelper class that extends SQLIteOpenHelper, and takes care of things like table-creation and upgrades. A SQLiteDatasource class that performs CRUD operations on the ...