All Questions
17 questions
2votes
4answers
3kviews
I wrote a class with "init" method. Should I call it from other class methods? Or leave it to the object user? (Code Design)
I have a java class with an init method. It's different from the constructor. The constructor just initializes the variables/fields. The init method connects to a database and performs some ...
-1votes
2answers
262views
Do I really need TaskManager class? [duplicate]
Background: I'm coding an app, the core idea is simple - I can choose a 'Task' (consists of name, code to perform aka Runnable, progress) through GUI, start it, stop it, start all 'Task's and stop all ...
7votes
3answers
10kviews
Are there any drawbacks to using a nested class instead of declaring a new one?
I'm doing code review on a change my co-worker made to our Java application, and I've found something I'm not very familiar with - a nested class. From reviewing the code, it seems like the nested ...
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 ...
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 ...
1vote
7answers
4kviews
Repeated Instantiation of the Same Class in a Method
This is sort of a follow up question on Multiple Same Object Instantiation. And I think, is not really language specific, so this is applicable to Java and C#? Version A public MyClass { public ...
10votes
4answers
3kviews
What are the responsibilties of the main in object oriented programming?
I'm new to object oriented programming and I don't understand what's the purpose of the main. Yes, I read that it's the "entry point" of the program but what I don't understand is what should be in ...
38votes
5answers
9kviews
When should I extend a Java Swing class?
My current understanding of Inheritance implementation is that one should only extend a class if an IS-A relation is present. If the parent class can further have more specific child types with ...
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
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 ...
0votes
2answers
15kviews
How to update an existing excel file using java program? [closed]
I've made a file browser in java that opens and read already been made excel files. (using Apache poi 3.9 library) program read those files perfectly but i want to update some of those files. how can ...
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
2answers
140views
When to store values in constants/finals
This might seem like an odd question, but I'm worried that I'm putting too many things as constants/finals at the top of my java class. I've started to put every value that is in my program into a ...
59votes
9answers
49kviews
Should the methods of a class call its own getters and setters?
Where I work I see lots of classes that do things like this: public class ClassThatCallsItsOwnGettersAndSetters { private String field; public String getField() { return field; }...
8votes
3answers
63kviews
Multiple Same Object Instantiation
What exactly happens in Java when you instantiate the same object multiple times? For example: Test test = new Test(); then later on I will call it again, Test test = new Test(); again or inside a ...