Lecture overview -- Keyboard shortcut: 'u'  Previous page: Accessing Data in Objects [Section] -- Keyboard shortcut: 'p'  Next page: Overview of data access 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 2 : 29
Object-oriented Programming in C#
Data Access, Properties, and Methods
Indirect data access

Avoiding direct access to data is one of the main themes of object-oriented programming. We first introduce the idea. After that we will study properties, which - in C# - help us a lot to access data indirectly.

Data encapsulated in a class is not accessed directly from other classes

Rather, data is accessed indirectly via operations

  • Why indirect data access?

    • Protects and shields the data

      • Possible to check certain conditions each time the data is accessed

      • Possible to carry out certain actions each time the data is accessed

    • Makes it easier - in the future - to change the data representation

      • Via "compensations" programmed in the accessing operations

    • Makes it possible to avoid the allocation of storage for some data

      • Calculating instead of storing