Windows Programming Made Easy: Using Object Technology, COM, and the Windows Eiffel Library
Authors: Glenn Maughan, Raphael Simon
Venue:  (2000)

From the Book:PREFACE: PrefaceBuilding Windows SoftwareThe construction of Windows software is an immensely satisfying activity. It is satisfying to write software that is easy to use and that meets the needs of its users. Microsoft Windows software gives you the benefit of a standard graphical interface composed of prebuilt user interface components which can be combined to construct a myriad of software applications.Building Windows software is also challenging. Very challenging! The number and variety of components that you can use is daunting. The latest application programming interface (API) for Windows 32-bit applications consists of hundreds of interface components and thousands of functions used to create and manipulate each of them. Assembling an application from these components requires careful design, and usually a great deal of experience, before it will meet its requirements and attain one of the ultimate software goals: being user-friendly.Windows software has traditionally been constructed using the C programming language in conjunction with the standard Windows API library. More recently, applications have been built using C++ and a class library, such as the Microsoft Foundation Classes (MFC) or the Borland Object Windows Library (OWL), built on top of the Windows API. C has long been praised for its low-level power and expressiveness. It is said to be suitable for Windows programming because the Windows API itself is implemented in C and therefore provides the closest possible programming link between the application and the Windows libraries. However, C has also been criticized for its low-level power and expressivenessCissometimes too close to the bone. The language can beguile a programmer into concentrating on internal structure, physical layout, and mechanical capabilities, rather than on business requirements. For instance, more time is typically spent managing program execution flow, organizing how the data structures are laid out in memory, how the data structures are accessed, and occasionally even how the executable is constructed. Little time is left to concentrate on what the program is supposed to do and what it is supposed to provide for its users. When you combine the complexities of the Windows API with the complexity of using C or C++ as an implementation language, it adds up to one very complex and error-prone software development process.An Alternative ApproachA number of alternative approaches exist. One of the most popular is to generate the Windows source code semiautomatically using fourth generation languages (4GLs), or so-called visual programming languages. Examples include Microsoft's Visual Basic, IBM's VisualAge, and Borland's Delphi. Each is a development environment that provides a fast way to interactively create Windows applications. In practice, this approach is very productive. However, these environments (and others like them) tend to restrict the range of Windows programming facilities to which the programmer has access. When a really tricky problem arises, these types of tools can thwart the implementation of a good solution.The tools and environments also tend to be based on older style programming languages, such as BASIC and Pascal. Even though such languages have their merits, they tend to be based on outdated software development principles and often have not incorporated newer techniques, such as object-orientation, as thoroughly or effectively as would be hoped. Both VisualBasic and Delphi have attempted to incorporate object-oriented principles into newer versions of the language. However, concepts such as inheritance, parameterized types, and polymorphism have been only partially integrated, or not integrated at all; in some cases, the language has become more complex, rather than simpler, as a result.For software to be successful in today's market, it must be engineered, as opposed to just constructed. Well-engineered software has a better chance of exhibiting quality. The attributes of software quality include correctness, robustness, and extensibility. That is, the system meets the user requirements, does not crash or fail unexpectedly (possibly causing disastrous results, like the loss of expensive spacecraft), and can be easily adapted to meet new and changing user requirements. Producing quality software using traditional software development techniques can be very difficult and sometimes, especially when it comes to the maintenance of that software, even impossible. Object-orientation is a leap (not a step) in the right direction. The techniques and structures available in an object-oriented language allow a programmer to concentrate more on what needs to be programmed. That is, what abstractions are needed, what functionality the abstractions need to provide, and what data structures are needed to support the abstractions. In a pure object-oriented environment, how these abstractions and data structures are implemented can be effectively hidden from the programmer.An object-oriented approach requires at least three components: an object-oriented language that provides proper support for object-oriented concepts, an object-oriented encapsulation of the Windows API library, and a set of base, or kernel, classes that provide a solid collection of data structures and abstractions needed to build software. The language used in this book is Eiffel. Eiffel is a pure object-oriented language designed from the ground up to support the production of quality software. The API encapsulation library is the Windows Eiffel Library (WEL), produced by Interactive Software Engineering (ISE), that provides a well-designed encapsulation of the Win32 API. The base library is the EiffelBase library, also produced by ISE and available in the public domain, that provides all the data structure and support classes needed for most applications.These three tools provide a surprisingly powerful way of engineering quality Windows software. This is exactly the alternative that we are looking for! We get all the benefits of a pure object-oriented language, the benefits of a well-designed encapsulation of the Windows API library, and collectively, an environment for building quality, well-engineered Windows software.Finally, the language, compiler, libraries, and other development tools should be accessible to the developer from within a productive and integrated development environment. The examples in this book were developed using ISE's EiffelBench.We mentioned earlier not to rule out the tools that provide an automated approach to Windows code generation. An object-oriented approach, using the tools listed above, is not the golden "this-is-so-easy-now" solution. With an object-oriented approach, Windows programming is easier and less error-prone, but it is still challenging. Using visual tools in conjunction with an object-oriented method can improve the overall quality of applications and speed the development of components.Intended AudienceThis book is aimed at intermediate programmers. You should have a reasonable level of competence in general programming, programming algorithms, and a little mathematics (for graphics programming). You should also be competent in object-oriented programming. However, the Eiffel language is sufficiently easy to read and understand that this requirement is not a strict prerequisite.The book concentrates on the WEL. In fact, it provides a complete programmer's reference for this library. Examples in the book also rely heavily on the EiffelBase library for its data structures and other abstractions. You will need to have access to an Eiffel compiler, the ISE WEL library, and either the EiffelBase library or an equivalent substitute. A number of free (and trial) implementations of Eiffel are available, and a trial version of the ISE Eiffel compiler and its associated libraries is included on the CD that comes with this book, so you can get started immediately.The book presents an easy way to write Windows software that addresses quality attributes including correctness, robustness, and extendibility. If you write Windows software using another programming language, then this book will still give you valuable insight and advice to help construct quality Windows software. The book may even help to convince you to use Eiffel on your next development project.Organization of the BookThere are two goals in the organization of this book. The first is to present an easy way to construct Windows software using Eiffel and the Windows Eiffel Library. The second goal is to provide a complete reference for WEL. To meet both of these goals, we have organized the book using the following structure. Each chapter introduces one particular area of interestfor instance windows, composite windows, or controls. The introduction is followed by a discussion on the theory underlying the topic, including answers to the relevant what, why, and how questions: What does this type of Windows component provide for me? Why would I use it in one of my applications? And finally, how do I use it? The reference material for the library component is then presented with numerous programming examples illustrating particular features and behavior of the component.In order to provide a complete view of the WEL, a medium-sized application is constructed incrementally throughout the book. This application is introduced in detail in the section "Directory Tree Analyzer" in Chapter 2, "Applications." Many chapters include a section titled "Implementing the Example ," in which the chapter's components and concepts are demonstrated using the sample application. For example, the use of composite windows in the sample application is discussed in the section "Implementing Composite Windows" in Chapter 5, "Composite Window."This book has taken longer than expected to write. Almost three years, in fact. It would never have been completed without youthe proud owner of your own copy! Your frequent questions via e-mail and via the newsgroup comp.lang.eiffel have reignited our motivation to finish every time. Thank you.We would also like to thank a number of individuals who have helped throughout the project. In particular, Bertrand Meyer and Christine Mingins for encouraging us to write the book in the first place; Daryl Foy, Per Grape, Jim McKim, Robin van Ommeren, Arnaud Pichery, Margot Postema, and Kim Walden for helping to review and class test early material; and our editor, Paul Petralia, of Prentice-Hall, for getting everything done so quickly.Finally, we would like to thank our families and friends for their patience, encouragement, fun, and laughter.