Malarn Remember me on this computer. Handling Complexity with Idioms. A General Collection Class. Destructor Interaction and Virtual Destructors.
|Genre:||Health and Food|
|Published (Last):||6 April 2004|
|PDF File Size:||18.13 Mb|
|ePub File Size:||16.67 Mb|
|Price:||Free* [*Free Regsitration Required]|
To understand how programmers achieve proficiency, we need to understand not only how people learn a new language such as a programming language , but also how a language is used to solve software problems effectively.
Before the arrival of our first child, my wife and I were admonished by a friend that no book, and no training, could completely prepare us for the art of parenting.
We must of course learn minimal, essential skills. But the interesting, challenging, and rewarding aspects of raising a child go beyond this basic knowledge.
The same is true of programming languages. Most of what guides the structure of our programs, and therefore of the systems we build, is the styles and idioms we adopt to express design concepts.
Style distinguishes excellence from accomplishment. An effective parenting style, or programming style, comes from personal experience or by building on the experience of others.
A software engineer who knows how to match a programming language to the needs of an application, writes excellent programs. To achieve this level of expertise, we need to go beyond rules and rote, into convention and style, and ultimately into abstractions of concept and structure. It is in that sense that this book is "advanced. A model for problem decomposition and system composition is a paradigm, a pattern for dividing the world into manageable parts.
Object-oriented advocates do everything polymorphically. In fact, a variety of approaches is usually necessary to express the solution to a software problem efficiently and elegantly. Learning a programming language is much like learning a natural language. Knowledge of basic syntax lets a programmer write simple procedures and build them into nontrivial programs, just as someone with a vocabulary of a few hundred German words can write a story far richer than see-Dick-run.
But mastery of language is quite another issue. That such stories are nontrivial does not make them elegant or demonstrate fluency. Learning language syntax and basic semantics is like taking a hour course in German: It prepares you for the task of ordering a bratwurst, but not for going to Germany to make a living, and certainly not for getting a job as a German language journalist or poet.
The difference is in learning the idioms of the language. In programming, as in natural language, important idioms underly the suitability and expressiveness of linguistic constructs even in everyday situations. Programming idioms are reusable "expressions" of programming semantics, in the same sense that classes are reusable units of design and code. Simple idioms like the while loop above are notational conveniences, but seldom are central to program design.
This book focuses on idioms that influence how the language is used in the overall structure and implementation of a design. Such idioms take insight and time to refine, more so than the simple notational idioms. The idioms usually involve some intricacy and complexity, details that can be written once and stashed away. Once established, programming language idioms can be used with convenience and power. Each chapter of this book is organized around a family of such idioms. The idioms progressively build on each other in successive chapters.
It provides some motivation as to why idioms came about, and varying degrees to which different idioms can be thought of as part of the language or as outside the language. Though much of the material is basic, the chapter establishes idioms and vocabulary that recur in later chapters. It introduces compiler type systems, and their relationship to user-defined types and classes, from a design perspective. It also presents idioms that make const more useful.
Chapter 3 introduces idioms that make classes "complete" types. This chapter provides a framework for that customization. I call the idioms described in this chapter canonical forms, meaning that they define principles and standards to make the underlying mechanics of objects work. In addition to the most commonly used canonical form, idioms are presented to apply reference counting to new and existing classes.
Lastly, the chapter looks at how to separate the creation of an object from its initialization. The need to separate them arises in the design of device drivers and in systems with mutually dependent resources. Chapter 4 introduces inheritance; Chapter 5 adds polymorphism to inheritance to introduce object-oriented programming.
While it is true that inheritance is used mostly to support the object paradigm, it has a distinctly separate application for software reuse. Introducing inheritance apart from polymorphism helps the reader separate the two concepts and avoids the confusion that often arises from trying to internalize two foreign concepts at once. It examines what classes mean at the level of an application, high above the level of syntax. Appreciating the relationships between the design abstractions of an application, and between the classes and objects of its implementation, leads to systems that are robust and easily evolved.
Another key to evolution is broadening designs beyond a specific application, to cover applications for a whole domain; guiding principles for domain analysis are an important part of this chapter. Chapter 7 explores reuse of code and designs. Four distinct code mechanisms are explored, with particular attention devoted to the benefits and pitfalls of "inheritance fever.
Exemplars are presented as special objects that solve some common development problems, such as the "virtual constructor" problem. But exemplars also lay the groundwork for more powerful design techniques supporting class independence and independent development. One might claim that those who want to program in Smalltalk should program in Smalltalk.
Those who want Smalltalk in all of its glory should indeed use Smalltalk. However, the fact that the styles presented in this chapter are exotic does not mean that the need for them is rare or esoteric.
This chapter regularizes such idioms so they do not have to be created from scratch each time they are needed. Chapter 9 also presents idioms supporting incremental run-time update. Implementations of this idiom are necessarily dependent on many details of the target platform. The gist of this material is to familiarize the reader with the level of technology at which incremental loading issues must be worked.
The example presented is typical and, as such techniques go, it is neither obtuse nor trivial. The code presented for incremental loading needs major reworking for platforms other than Sun work stations, and it may be found altogether unsuitable to some environments.
Chapter 10 covers dynamic multiple inheritance. While static multiple inheritance as described in Chapter 5 has value, dynamic multiple inheritance avoids problems of a combinatorial explosion of class combinations.
This approach has been found valuable in many real-life programs including editors, CAD systems, and database managers. The last chapter discusses objects from a high-level, system view. The chapter puts a number of important system issues in perspective, including scheduling, exception handling, and distributed processing. Some guidelines for modularization and reuse are also discussed, tying together the concepts of Chapters 6 and 7.
Included in this discussion are considerations for library structure and maintenance. Many readers will have already learned these basics or can find them in introductory texts. This material is included here for two reasons. First, it serves as a ready reference for those occasions when you need clarification of an obscure construct without having to go to a separate text. The examples in this book are based on Release 3.
Some code makes use of general purpose class libraries for maps, sets, lists, and others. Efficient versions of such libraries are available from many vendors, and adequately functional versions can be created from scratch for pedagogical purposes.
The skeletons, and sometimes complete bodies, of many general-purpose classes can be gleaned from examples in the book. Key class names are listed in the Index. Acknowledgments This book owes much to many friends. I appreciate his initiative and support in starting this effort.
The book reflects the guidance of Keith Wollman, my resourceful and accommodating editor, and Helen Wythe, the production supervisor. Lorraine Mingacci collaborated significantly with me on Chapter 6 and discussions with her about the rest of the book have been of immense value. The book owes much to a core team of thorough and relentless reviewers and contributors of ideas: Tim Born, Margaret A. Alexis Layton, Jim Adcock, and Mike Ackroyd offered suggestions and insights to keep the book focused and balanced, and I am deeply grateful for their contributions.
Brett L. Schuchert and Steve Vinoski took painstaking effort to report the bugs that made it into early printings; their efforts have greatly improved the quality of subsequent printings. Many thanks to Judy Marxhausen for advice on special topics.
Much credit go Using small, but rich examples, he shows how these abstractions can be combined to use the language effectively.
Advanced C++ Programming Styles and Idioms
HPB condition ratings New: Item is brand new, unused and unmarked, in flawless condition. May show remainder marks. Older books may show minor flaws. Very Good VG : Shows some signs of wear and is no longer fresh.
ISBN 13: 9780201548556