C Primer Plus (5th Edition)

   

When you start out writing programs, each program might seem like an entirely separate project, designed and constructed from scratch. However, this is not a prudent way to create computer programs, and it's not the way most programs are created today.

There is a much better alternative reuse of pre-constructed and pre-tested programs or parts of programs.

A high degree of reuse means far less code to write and allows you to tap into well-designed, well-tested software components written by highly skilled experts.

Note

Even the simplest C# programs, including the first few you will encounter in this book, rely on software reuse under the hood.

The following example illustrates the value of reuse.

You want to build a simple radio. You can follow two paths to accomplish this task.

You can build every component you need from scratch (resistors, transistors, chips and so on). You will need a lot of knowledge, talent, money, and time to build each of these sophisticated components yourself. In fact, you might not finish the project for many years.

Alternatively, you could purchase the electronic components you need from the local electronics retail shop. For a relatively small cost, you utilize the expertise and big investments involved in manufacturing the components and, before you know it, you will have built a brand new radio.

Software reuse can take many shapes; the following are only two of many:

Reuse is at the core of .NET and C# programming, and we will frequently return to this topic throughout the book. In fact, this is an important part of the next section.


   

Категории