All Questions
17 questions
2
votes
4
answers
3k
views
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 ...
-1
votes
2
answers
262
views
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 ...
7
votes
3
answers
10k
views
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 ...
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 ...
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 ...
1
vote
7
answers
4k
views
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 ...
10
votes
4
answers
3k
views
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 ...
38
votes
5
answers
9k
views
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 ...
3
votes
2
answers
3k
views
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 ...
2
votes
1
answer
274
views
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 ...
0
votes
2
answers
15k
views
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 ...
3
votes
3
answers
2k
views
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 ...
1
vote
2
answers
140
views
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 ...
59
votes
9
answers
49k
views
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;
}...
8
votes
3
answers
63k
views
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 ...