Lecture overview -- Keyboard shortcut: 'u'  Previous page: Program modification - the Fire Analogy -- Keyboard shortcut: 'p'  Next page: Classes in C# -- Keyboard shortcut: 'n'  Lecture notes - all slides and notes together  slide -- Keyboard shortcut: 't'  Textbook -- Keyboard shortcut: 'v'  Help page about these notes  Alphabetic index  Course home  Page 10 : 29
Object-oriented Programming in C#
Classes and Objects
Representation Independence

On this page we will illustrate the principle of representation independence. It is done by discussion of a class Point which violates the principle. The class Point has public data representation (rectangular x and y coordinates). We assume that we need to change the rectangular coordinates to so-called polar coordinates (radius and angle). The consequences of this modification of the program is studied via the exercise.

Representation independence: Clients of the class C should not be affected by changes of C's data representation

/user/normark/oop-csharp-1/sources/c-sharp/point/point-representation-independence/version2/Point.csA Point class with public instance variables - NOT Recommended . This program is explained

/user/normark/oop-csharp-1/sources/c-sharp/point/point-representation-independence/version2/Client.csA Client of Point. This program is explained

/user/normark/oop-csharp-1/sources/c-sharp/point/point-representation-independence/version2b/Point.csA version of class Point modified to use polar coordinates - NOT Recommended. This program is explained

Go to exercisePublic data representation
Encapsulated data should always be hidden and private within the class

Read more about representation independence in the text book version of this material.