The members of the class with public access form a public interface of the objects. Program can access the public interface analyzing the role of specific objects and in what way the object is used. The implementation of class is written by the programmer based on public interfaces in which public interface becomes independent from implementation. Later with the analysis we can establish that some other implementation enables better performance of the program. The object can be easily rearranged while the rest of the code doesn’t need modification.
IMPORTANT: Good approach in object oriented programming dictates that public interface is separated from his implementation.
class Vector {
       float ax, ay;
       void SetXY(float x, float y) { ax = x; ay = y; }
       float GiveX(){ return ax; }
       float GiveY(){ return ay; }
       void multiplywithscalar(float scalar);
Definition of functional member multiplywithscalar() is left out because it doesn’t change. Implementation of the class assumes that vector “remembers” in Descartes coordinates. Public interface doesn’t give any information about the coordinates but only enables that each vector establish projection on x and y axis which is possible independently on coordinate system in which the vector is memorized. Now we are able to change coordinate system into polar if that representation enables better features during execution. Functional members GiveX(), GiveY() and SetXY() are written as inserted in order to achieve faster execution of the program.

IMPORTANT: Inserted functional members are usually used for retrieving private data members in order to separate the implementation from public interface. As the time of program execution wouldn’t be long it’s useful to use inserted functional members.
Share on Google Plus