Chapter 1: Defining Types


Overview

C# is an object-oriented programming language, and one of the principles which guide its design is type safety. During object-oriented analysis and design, we identify the most important objects in our system, and consider how they will relate to each other. When we program in C#, classes are the main mechanism we use to define the behavior of the objects that will exist in our program at run time. However, C# offers us a great many ways to package up the code that defines our application – and not just in classes.

Whenever we code in C#, though, what we write are always types, and these types represent a combination of behavior and data storage requirements. When the program runs, it creates instances of types (which allocate the data storage required), and makes available the features of the types. Within the .NET environment, type-safe code only accesses the memory locations it is authorized to access and types interact only in well-defined, permitted ways. This is important for producing secure, stable applications that ensure even badly written code can't do too much damage, and plays by the rules.

This book aims to help C# developers gain a deeper and more confident understanding of how to build well designed classes that will behave correctly and consistently within the .NET Framework. Through exploration and examples, we will give you an awareness of the consequences of decisions made during the design and development phases, and will point out any not-so-obvious similarities with or differences from other object-oriented languages like C++ and Java.

We'll begin this book by looking at what exactly a type is. In this chapter, we'll examine .NET's type system, and the kinds of type available to us as developers.




C# Class Design Handbook(c) Coding Effective Classes
C# Class Design Handbook: Coding Effective Classes
ISBN: 1590592573
EAN: 2147483647
Year: N/A
Pages: 90

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net