Skip to main content

All Questions

276 votes
14 answers
125k views

Should we avoid object creation in Java?

I was told by a colleague that in Java object creation is the most expensive operation you could perform. So I can only conclude to create as few objects as possible. This seems somewhat to defeat ...
Slamice's user avatar
  • 2,657
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; }...
Daniel Kaplan's user avatar
56 votes
3 answers
74k views

Which is a better practice - helper methods as instance or static?

This question is subjective but I was just curious how most programmers approach this. The sample below is in pseudo-C# but this should apply to Java, C++, and other OOP languages as well. Anyway, ...
Ilian's user avatar
  • 663
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 ...
Lawrence Gimenez's user avatar
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 ...
sinθ's user avatar
  • 1,311