Why are there Properties in D?

Robin robbepop at web.de
Fri Feb 14 01:32:38 PST 2014


Hiho,

I am learning D since some time and I must say all in all it is
truely a better C++! I especially like the statement of Walter
Bright that nowadays it is more important that the programmer can
easily read programming text and do not have to "interpret" every
single line by looking into several definitions and declarations
in order to fully understand what a piece of program text really
means as programmers normally spend much more time debugging a
code than writing one and thus it isn't that important to keep
program code short - more important is clean and unambiguous code.

But what about Properties - the feature where functions can be
called as if they were member variables ...
Isn't this a step backwards if you think about the sentence above?

With Properties used in a code a programmer again has to look up
the definition of all calls and assignments of variables just in
case they could be Properties and not just member variables.

So I am asking why should one use Properties? The only advantage
is that one can leave out the nasty "()" but the disadvantage is
that especially new people who are working out a code of another
person or people who have to inspect older code may have a harder
time understanding what really happens especially if Properties
are "overused".

In my opinion this leads to less clear code.

But maybe I am overlooking something and things aren't that worse
so it would be nice if someone could tell me about other
advantages of Properties. =)

Robbepop


More information about the Digitalmars-d mailing list