|
Posted by Tony Marston on 11/29/06 10:49
"Michael Fesser" <netizen@gmx.de> wrote in message
news:loapm2tvbcm1d41a5r42tlf5b5rmqpg27j@4ax.com...
> .oO(Tony Marston)
>
>>I disagree. it is *not* necessary for the simple reason that the code will
>>perform exactly the same function whether methods and properties are
>>marked
>>as public/private/protected or not.
>
> Then why do we use OOP and high-level languages like PHP at all? Pure
> hand-written assembler code will perform exactly the same function.
You can write OO code that uses pubic/private/protected and it will perform
exactly the same function as code which does not use
public/private/protected, therefore the use of public/private/protected does
not add any value. It is therefore optional and not mandatory.
>>> It prevents developers from doing things that shouldn't be done, for
>>> example calling an internal method out of context. I don't want all my
>>> methods being publicly available, simply in order to avoid errors and
>>> unpredictable results.
>>
>>That is a matter for programmer discipline, it is not a matter of
>>additional
>>functionality. The code will do exactly the same with or without it.
>
> The code written in a language like Delphi for example will also do
> exactly the same with all type checks, range checks, overflow checks
> etc. turned off. But does it make sense to do that and just rely on
> "programmer discipline"? No, it doesn't, because it will lead to
> erroneous code on the long run.
You are missing the point. If a piece of code does exactly the same thing
whether a feature is turned ON or OFF then that feature is optional.
> Compilers are able to automatically check a lot of things and warn the
> developer if he made a mistake. Such checks and restrictions don't add
> any functionality, but are necessary in order to write reliable code.
I disagree. I do not need a statically typed language to write software. I
can do just as well with a dynamically typed laguage. So can all the
millions of other programmers who use dynamically typed languages.
> The same goes for visibility declarations. I don't rely on discipline or
> a comment like "please don't call this method". If a method is not meant
> to be called directly then it's declared as such - problem solved.
>
> Micha
Whether a method or variable is marked visible or not does not make the
software run any differently, therefore it is optional, not mandatory.
Navigation:
[Reply to this message]
|