The C# programming / PDF
The C# programming / PDF
Table of Contents
1. From structured programming to object-oriented programming
2. Towards Object-oriented Programming 7
3. Phenomena and Concepts 13
4. Towards Object-oriented Programs 19
5. The C# Language and System 23
6. C# in relation to C 25
7. C# in relation to Java 53
8. C# in relation to Visual Basic 57
9. C# Tools and IDEs 59
10. Classes: An Initial Example 61
11. Classes 67
12. Creating and Deleting Objects 89
13. Reference Types 97
14. Value Types 103
15. Organization of C# Programs 117
16. Patterns and Techniques 123
17. Accessing Data in Objects 133
18. Properties 135
19. Indexers 147
20. Methods 151
21. Overloaded Operators 165
22. Delegates 173
23. Events 183
24. Patterns and Techniques 189
25. Specialization of Classes 195
26. Extension of Classes 203
27. Inheritance in General 209
28. Inheritance in C# 215
vi
29. Method Combination 241
30. Abstract Classes - Sealed Classes 245
31. Interfaces 253
32. Patterns and Techniques 271
33. Fundamental Questions about Exception Handling 301
34. Conventional Exception Handling 307
35. Object-oriented Exception Handling 311
36. Exceptions and Exception Handling in C# 313
37. Streams 333
38. Directories and Files 355
39. Serialization 359
40. Patterns and Techniques 369
41. Motivation for Generic Types 373
42. Generic Types 381
43. Generic Methods 401
44. Collections - History and Overview 407
45. Generic Collections in C# 409
46. Generic Dictionaries in C# 437
47. Non-generic Collections in C# 445
48. Patterns and Techniques 447
49. Correctness 453
50. Specification with preconditions and postconditions 457
51. Responsibilities and Contracts 463
52. Class Invariants
------------------------------
Sample of the pdf document
We will assume that the reader of this material has some knowledge of imperative programming, and that the
reader already has been exposed to the ideas of structured programming. More specifically, we will assume
that the reader has some background in C programming. In Chapter 6 (corresponding to the second lecture of the course) we summarize the relationships between C and C#.
1.1. Structured Programming
Lecture 1 - slide 2
We approach object-oriented programming by reviewing the dominating programming approach prior to
object-oriented programming. It is called structured programming. A brief background on structured
programming, imperative programming, and - more generally - different schools of programming is provided
in Focus box 1.1. I will recommend that you read the Wikipedia article about structured programming [wikistr- pro]. It captures, very nicely, the essence of the ideas.
Structured programming relies on use of high-level control structures instead of low-level jumping
Structured programming is also loosely coupled with top-down programming and program development by stepwise refinement Structured programming covers several, loosely coupled ideas. As summarized above, one of these is the use of control structures (such as if, switch/case, while and for) instead of gotos.
Use of relatively small procedures is another idea. A well-structured program should devote a single
procedure to the solution of a single problem. The splitting of problems in subproblems should be reflected
by breaking down a single procedure into a number of procedures. The idea of program development by
stepwise refinement [Wirth71] advocates that this is done in a top-down fashion. The items below summarize
the way it is done.
· Start by writing the main program
· Use selective and iterative control structures
· Postulate and call procedures P1, ...,Pn
· Implement P1, ... Pn, and in turn the procedures they make use of
· Eventually, the procedures become so simple that they can be implemented without introducing additional procedures
Only few programmers are radical with respect to top-down structured programming. In the practical world
it is probably much more typical to start somewhere in the middle, and then both work towards the top and
towards the bottom.
The C# programming / PDF
0 commentaires: