No, it doesn't. _I_ am free because...
In the company where i was previously employed[...]
...I'm talking about VB, not about your company.
As I said in a previous post, in most cases I also use a property because
there's a reason to do so.
Okay i understand you don`t want to conform to MSF and OOP or just are in
the lucky position that you now in forehand how your project
wil evolve in the future , i and most people who code to get the shelves
filled and the heater running are not in that luxury position .
If a class and the classes that use it are always compiled together, than
properties don't buy you any advantage. If they are compiled separately,
then using properties instead of fields looks like a better idea. writing
properties makes sense at the locations where your component interfaces with
other components.
However for the sake of following guidelines
http://msdn.microsoft.com/en-us/library/ta31s3bc(VS.71).aspx
wich wil give you so much more advantages i just use properties whenever i
need a public or friend field
Anyway, you are free to choose whatever you like there is no property police
watching over your shoulder and slapping you on the fingers if you don`t
follow these guidelines .
But in my version of VS i get the below warning if i just declare a public
field so i guess someone there in Redmond doesn`t want me to declare public
fields
CA1051 : Microsoft.Design : Because field 'Form1.bla' is visible outside of
its declaring type, change its accessibility to private and add a property,
with the same accessibility as the field has currently, to provide access to
it. C:\Studio\NeProS\Diversen\ADQuery\Test\Form1.vb 5 Test
so just for completeness i digged a bit deeper and found this interesting
posting in a simular thread
###############
Michael Fanning - MS
Development Lead for Visual Studio static code analysis
There are many good reasons to avoid externally visible fields. They cannot
be used to satisfy interface contracts. It is difficult to determine when
they are accessed in debugging scenarios. You cannot apply declarative
security to them. Etc. Converting a field to a property is a breaking
change. Therefore, the general guideline (which is quite firm) is that all
fields should be private and accessed through trivial property accessors
where possible (so that the code is inlined and very performant). One of the
summary arguments supporting this is that there are many pitfalls avoided by
doing so and no substantive negative outcomes by making the change.
In your case, do you truly need these items to be protected? You could make
them internal, for example. Or, you could use the new Whidbey mechanism
whereby a property's getter is public, and the setter is protected. The
backing field would be private.
Or, finally, if you never intend your assemblies to be reused by third-party
developers, you could simply disregard this rule. The guidelines in question
here have to do with potential problems that arise when an arbitrary set of
developers reuse your public API. If that isn't the case here and there's no
tangible vlaue from taking the change, you shouldn't feel req'd to make it.
###############
Regards
Michel Posseth
Armin Zingler said:
Michel said:
My answer as the author of such a product would be , "I have no idea
what the future will bring , but bether be prepared for for the
future as limiting myself on forehand "
I do not take imaginary things into account that are not even planned.
That's a general attitude. If I made exceptions here and there, I wouldn't
know where to stop. This makes (my) life much easier because I just have
to
focus on what has to be done (which already takes things planned for the
future into account) without burdening my thoughts with things that
might happen - or maybe not. I am not able to work that way. In the end
it's easier even if you have to make braking changes in the future, but
then I can learn from it and wonder if my planning has been done
thoroughly
enough. Untill now, this attitude served me well.
No, it doesn't. _I_ am free because...
In the company where i was previously employed[...]
...I'm talking about VB, not about your company.
As I said in a previous post, in most cases I also use a property because
there's a reason to do so.
Armin