A Brief History of Windows Programming


To appreciate the benefits that C# and the .NET Framework bring to Windows programming, it is necessary for you to understand a bit of its history. When Windows was first created, programs interacted directly with the Windows API (Application Programming Interface), which is an extensive set of methods defined by Windows that programs call to access the various functions provided by Windows. API-based programs are very long and complicated. For example, even a skeletal API-based program requires about 50 lines of code. API-based programs that perform any useful function have at least several hundred lines of code, and real applications have thousands of lines of code. Thus, in the early days, Windows programs were difficult to write and maintain.

In response to this problem, class libraries were created that encapsulated the functionality of the API. The most important of these is MFC (Microsoft Foundation Classes). Many readers of this book will be familiar with MFC. MFC is written in C++, and MFC-based programs are also written in C++. Because MFC brought object-oriented benefits, the process of creating a Windows program was simplified. However, MFC programs were still fairly complicated affairs involving separate header files, code files, and resource files. Furthermore, MFC was only a “thin wrapper” around the API, so many Windows-based activities still required a significant number of explicit program statements.

C# and the .NET Framework’s Forms library offer a fully object-oriented way to approach Windows programming. Instead of providing just a wrapper around the API, the Forms library defines a streamlined, integrated, logically consistent way of managing the development of a Windows application. This level of integration is made possible by the unique features of the C# language, such as delegates and events. Furthermore, because of C#’s use of garbage collection, the especially troubling problem of “memory leaks” has been nearly eliminated.

If you have already programmed for Windows using either the API or MFC, you will find C#’s approach remarkably refreshing. For the first time since Windows was created, it is nearly as easy to create a Windows application as it is to create a console application.




C# 2.0(c) The Complete Reference
C# 2.0: The Complete Reference (Complete Reference Series)
ISBN: 0072262095
EAN: 2147483647
Year: 2006
Pages: 300

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