All Questions
Tagged with initialization java
4 questions
6
votes
4
answers
1k
views
How to avoid init methods when 2 objects need the reference of each other?
According to https://softwareengineering.stackexchange.com/a/334994/432039, I know init is a code smell and should be avoided, and one of the solutions is to use a builder to hold the state first ...
3
votes
4
answers
279
views
Advice for bugfixing object oriented code: why is data not set?
When debugging object oriented (Java) code, sometimes some field of some object is null while it should not be. I often spend what I feel is way too much time trying to figure out where it should have ...
3
votes
2
answers
306
views
For what reasons Java and C# initialize static data on demand?
I am reading "The Go Programming Language" right now and I have read package initialization chapter which tells (or I read it wrong) that Go uses eagerly initialization.
So in time we saw say C++ ...
2
votes
2
answers
14k
views
Initialize in Field, Constructor, or Argument
If I know what a field will be initialized to, should I initialize it in the field, constructor, or receive it as a parameter? I am asking about best practices. All three options effectively provide ...