Re: [Vala] vala code generation too constrained?



On 01/11/2011 08:42 PM, Jim Nelson wrote:
I used overloaded methods a lot in my past work with Java and C++,
I don't miss them at all with Vala.

Personally I think it's a feature that Vala does not support method
and constructor overloading.

I like the "different method - different name" concept. It makes one
think of good names for methods that describe their intentions well,
and everybody knows which method will be called.

I recently read Robert C. Martin's book "Clean Code - A Handbook of
Agile Software Craftmanship" and it states:

  "When constructors are overloaded, use static factory methods with
  names that describe the arguments. For example,

    Complex fulcrumPoint = Complex.FromRealNumber(23.0);

  is generally better than

    Complex fulcrumPoint = new Complex(23.0);

  Consider enforcing their use by making the corresponding
  constructors private."

There we have Vala's named constructors.

In Java method overloading is known for causing ambiguities with
auto-boxed types and in C++ the method resolution rules for overloaded
methods are so complex that no human brain can remember them. In Vala
it would not be simple as well. Would "foo()" call the method with no
arguments or the method with argument default values? etc.


Best regards,

Frederik



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]