Java constructor with large arguments or Java bean getter/setter approach
        Posted  
        
            by deelo55
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by deelo55
        
        
        
        Published on 2009-10-27T16:30:57Z
        Indexed on 
            2010/03/22
            20:41 UTC
        
        
        Read the original article
        Hit count: 380
        
java
|constructor
Hi, I can't decide which approach is better for creating objects with a large number of fields (10+) (all mandatory) the constructor approach of the getter/setter. Constructor at least you enforce that all the fields are set. Java Beans easier to see which variables are being set instead of a huge list. The builder pattern DOES NOT seem suitable here as all the fields are mandatory and the builder requires you put all mandatory parameters in the builder constructor.
Thanks, D
© Stack Overflow or respective owner