Hi David,
English being the precise language that it is, I guess I misunderstood the word "context".
I'm not chasing a rabbit here, I'm (was, until "data" was clarified for me) curious as to the apparent (in my eyes) difference from VFP as regards OOP. It still sounds different to me in the overall, but clearly I'm in the minority here and defer to the vast majority who sense otherwise.
Cheers,
Jim N
>Jim,
>
>>You are focussed on the "can be hidden...". I read "It packages data, and the methods that act on that data..." and I see that as very different (potentially) than VFP.
>
>The next sentence is:
>
>An object's data can be hidden to prevent unauthorized modification. The object surfaces a set of public methods to operate on this data. This concept is called encapsulation.
>
>A few paragraphs later in the section on Encapsulation:
>
>Encapsulation
>Encapsulation means that developers can contain and hide information about an object, such as internal data structures and code. It isolates the internal complexity of an object's operation from the rest of the application.
>
>For example, when you set the Caption property on a command button, you don't need to know how the string is stored. Visual Basic will help you do this by letting you declare properties and methods as private protected or public.
>
>Why would you want to protect class members? Let's assume that certain properties of a class represented an object's state. If you couldn't prevent those properties from being accessed directly from outside the class, how could you ever guarantee the state of that object? If you protect the property, you could then create a custom method that would be used to assign values to that property. The method could contain validation code to ensure that the value is set properly. Since the property value is assigned in just one place, the code becomes much easier to debug and maintain. In the example below, "me" refers to a specific instance of a class.
>
>The major difference I see from VFP is "me" instead of "this". I think you're chasing the wrong rabbit here.
Précédent
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement