Skip to main content

All Questions

Tagged with
-1 votes
2 answers
206 views

Java Constructor Syntax and Design [closed]

With regards to object-oriented Java constructor syntax and design, specifically parameterized or specific constructors, it is the accepted process, as describe in books, to build a parameterized ...
Minimalist's user avatar
4 votes
2 answers
2k views

How do we freeze an object while constructing an object using JavaBeans pattern?

Going through Effective Java, Joshua Bloch states that the drawback of using JavaBeans pattern is that an object may be in an inconsistent state partway through the construction and with JavaBeans ...
Karan Khanna's user avatar
4 votes
2 answers
631 views

Where should I put the common code of the constructors?

I have a situation where in a class I have 2 constructors and they have very similar code. The only difference is the the call to the constructor of the super class. Where should I put this common ...
Karan Khanna's user avatar
27 votes
4 answers
10k views

Legitimate "real work" in a constructor?

I am working on a design, but keep hitting a roadblock. I have a particular class (ModelDef) that is essentially the owner of a complex node tree built by parsing an XML schema (think DOM). I want to ...
Gurtz's user avatar
  • 389
13 votes
3 answers
4k views

How does one keep argument counts low and still keep third party dependencies separate?

I use a third party library. They pass me a POJO that, for our intents and purposes, is probably implemented like this: public class OurData { private String foo; private String bar; private ...
durron597's user avatar
  • 7,610