From: Florian Frank Date: 2005-02-22T07:51:54+09:00 Subject: Re: Constructor overloading??? On 21.02.2005, at 23:15, Sam Roberts wrote: > Trying to program in one language like it is another language is > special. And using lots of constructors in Java loses a lot of its attraction, if you're approaching two-digit numbers. One of the reasons, why Bloch gives the advice to use static factory methods instead of constructors in his book "Effective Java", is that you can give names to them. It's quite difficult to remember more than half a dozen type signatures and their permutations. It's nicer in Ruby, too: class Rectangle def initialize(a = 0, b = 0) @a, @b = a, b @color = :white end attr_reader :a, :b attr_writer :color def self.with_color(a, b, color) obj = new(a, b) obj.color = color obj end def self.[](a, b) new(a, b) end end r = Rectangle.new # => # s = Rectangle[3, 4] # => # t = Rectangle.with_color(3, 4, :red) # => # -- Florian Frank