Arrangement

 < Day Day Up > 



The book is arranged into four parts: Part I: The C++ Student Survival Guide, Part II: Language Fundamentals, Part III: Implementing Polymorphic Behavior, and Part IV: Intermediate Concepts. Each part and its accompanying chapters are described in greater detail below.

Part I: The C++ Student Survival Guide

Part I: The C++ Student Survival Guide consists of four chapters designed to help you get a jump on your programming projects. The survival guide is meant to be referenced throughout your learning experience. The key features and discussion points of part I include:

  • A discussion of the “flow”,

  • A project approach strategy to be used to maintain a sense of progress when working on programming projects,

  • A complete treatment on how to create C++ projects with two popular integrated development environments (IDEs) on Macintosh, Windows, and UNIX platforms,

  • A step-by-step project walkthrough that applies the project approach strategy and development cycle to produce a complete working project.

Chapter 1: An Approach To The Art Of Programming

Chapter 1 begins with a discussion of the challenges you will face as you study C++ and object-oriented programming. It presents a project approach strategy specifically designed to help you maintain a sense of forward momentum when tackling your first programming projects. The chapter also presents a development methodology, a philosophical discussion of the concept of the “flow”, and practical advice on how to manage a programming project’s physical and conceptual complexity. I will show you how to use three important preprocessor directives: #ifndef, #define, and #endif to create separate header files. You may or may not be familiar with all the terms used in the chapter, especially those related to preprocessor directives and identifier naming, however, you are encouraged to return to the chapter as required. It serves to offer you a glimpse of things to come.

Chapter 2: Small Victories: Creating Projects With IDEs

Chapter 2 shows you step-by-step how to create C++ projects using two popular integrated development environments: Metrowerks CodeWarrior on the Macintosh, and Microsoft Visual C++ for the Windows platform. The focus of the chapter is the concept of the project and the steps required to create projects regardless of the IDE employed. If you prefer to use UNIX development tools this chapter also shows you how to use the make utility and how to create a makefile that can be used to compile, link, and manage multi-file projects.

Chapter 3: Project Walkthrough: An Extended Example

Chapter 3 takes you step-by-step through a complete programming project from specification to final implementation. Along the way you are shown how to apply the project approach strategy and the development cycle to arrive at an acceptable project solution. The #ifndef, #define, and #endif preprocessor directives are used to create safe header files that separate function interface declarations from function implementation code. If you are a novice student I do not expect you to fully comprehend all the material or programming techniques presented in this chapter, rather, the material serves as an excellent reference to which you will return periodically as you use bits and pieces of this knowledge in your programming projects.

Chapter 4: Computers, Programs, and Algorithms

Chapter 4 presents background information on computer hardware organization, memory systems, and algorithms. The emphasis is on understanding exactly what a program is from a computer and human perspective. I discuss the four phases of the program execution cycle, how program instructions are differentiated from ordinary data, and how memory is organized on common computer systems. I also talk about what makes a good and bad algorithm.

Part II: C++ Language Fundamentals

Part II presents a treatment of the core C++ programming language features and comprises chapters 5 through 13. This is a critical part of the book because it prepares you for further study of intermediate and advanced C++ and object-oriented concepts. The key features and discussion points of part II include:

  • The unique ordering of the material. For instance, pointers are covered early so you will understand their use in other language constructs,

  • Pointers are presented as a dialog between a superhero named C++ Man and a confused student named Perplexed One,

  • Emphasis on multi-file projects,

  • Lots of targeted code examples to reinforce key lecture points,

  • Successive chapters build upon knowledge gained from the previous chapter,

  • In-depth coverage of tricky concepts normally glossed over or avoided in ordinary C++ texts.

Chapter 5: Simple Programs

Chapter 5 shows you how to write simple C++ programs using fundamental data types and simple expressions. I give examples of how to use all the C++ operators, how to create local and multi-file variables and constants, and show you how you can limit a variable’s scope to one file. You will learn how to write two versions of the main() function and how to call functions upon program exit.

Chapter 6: Controlling The Flow Of Program Execution

Chapter 6 moves beyond simple programs and shows you how to control the flow of program execution by using if, if-else, switch, for, while, and do-while statements. Many source code examples and diagrams are used to illustrate how control flow statements are written. The chapter includes a discussion of statements, null statements, and compound statements. I also show you how to write nested if, for, and while statements, and how to write loops that will repeat until explicitly exited.

Chapter 7: Pointers And References

Chapter 7 uses a short story to simplify the complex topic of pointers and references. Perplexed One is a student who falls asleep in class and is awakened by the arrival of C++ Man. C++ Man then helps Perplexed One by answering questions and giving examples of how to declare and use pointers.

Chapter 8: Arrays

Chapter 8 builds upon chapter 7 and shows the relationship between pointers and arrays. The chapter continues by showing you how to build single and multi-dimensional static and dynamic arrays. Lots of code examples and diagrams help you visualize how arrays are declared, initialized, and used in programs.

Chapter 9: Functions

Chapter 9 builds upon chapter 8 and shows you how to write complex functions that can pass arguments by value and by reference. The emphasis is on writing highly cohesive functions that are minimally coupled to other program elements. Header files are used to separate function declaration (interface) from definition (implementation). To support the creation of header files I review and discuss the three important preprocessor directives: #ifndef, #define, and #endif. Other topics covered include: function variable scoping, static function variables, passing arrays to functions, passing multi-dimensional arrays to functions, returning pointers from functions, how to avoid dangling references, function overloading, recursion, function pointers, and call back functions.

Chapter 10: Toward Problem Abstraction: Creating New Data Types

Chapter 10 shows you how to create type synonyms and new data types using type definitions, enumerated types, structures, and classes. The emphasis is on problem abstraction and how it is used to map a real world problem to a set of supporting data structures that can be used in a program. Structures are compared to classes and the notion of object-oriented programming is introduced. The class declaration is discussed as it relates to the structure declaration and how the notions of procedural and object-oriented programming differ from each other.

Chapter 11: Dissecting Classes

Chapter 11 continues the discussion of classes and how they work. It introduces the UML class diagram and uses UML class diagrams to illustrate static class relationships. The special member functions are thoroughly discussed. These include the constructor, destructor, copy constructor, and copy assignment operator. A brief introduction to the orthodox canonical class form is given in preparation for a deeper treatment of the subject in chapter 17. Other topics include data encapsulation, member functions and attributes, access specifiers, member function overloading, and how to separate class interface from implementation.

Chapter 12: Compositional Design

Chapter 12 builds upon chapter 11 and shows you how to build complex class types using simple and complex aggregation. The UML class diagram is extended to model simple and composite aggregate class relationships. The UML sequence diagram is also introduced to illustrate interobject message passing. Other topics discussed include: managing physical complexity, the use of pointers and references to build simple and complex aggregate classes, and how to properly use constructors and destructors in aggregate classes. The chapter concludes with a complex aggregation example.

Chapter 13: Extending Class Functionality Through Inheritance

Chapter 13 introduces the topic of inheritance and shows you how to extend class behavior through subclassing and subtyping. UML is used to illustrate simple and complex inheritance hierarchies. The compositional design techniques discussed in chapter 12 are combined with inheritance design concepts to provide you with a powerful arsenal of object-oriented design tools. The access specifiers public, protected, and private are discussed in the context of inheritance. Other topics covered include: virtual functions, function hiding, function overloading, pure virtual functions, abstract classes, abstract base classes, multiple inheritance, and virtual inheritance. The chapter includes a complex navy fleet simulation example that illustrates the use of inheritance and compositional design.

Part III: Implementing Polymorphic Behavior

Part III gives special coverage to the three types of polymorphic behavior: ad hoc (operator overloading), static (templates), and dynamic (base class pointers to derived class objects). Success as a C++ programmer demands a thorough understanding of these concepts. Key features and discussion points of part III include:

  • In-depth treatment of ad-hoc, static, and dynamic polymorphism and how each type of polymorphic behavior is achieved using the C++ language,

  • An example of how to overload almost every operator in the C++ language,

  • How to overload the iostream operators to tailor them to your class needs,

  • How to think about and apply the notion of polymorphic behavior in your application designs,

  • How to write generic code using templates,

  • How to use multiple place holders in template classes and functions,

  • How to use the special template definition syntax to explicitly specify template parameter types,

  • How to design with dynamic polymorphic behavior in mind.

Chapter 14: Ad Hoc Polymorphism: Operator Overloading

Chapter 14 is devoted to operator overloading. It builds upon the concepts of function overloading and shows you how to overload nearly every operator in the C++ language complete with examples of their use. A complete table of overloadable operators is included along with a discussion of how to overload the iostream operators to tailor them to your class needs.

Chapter 15: Static Polymorphism: Templates

Chapter 15 shows you how to write generic code using templates. It shows you how to replace overloaded functions with template functions and how to use template functions in your programs. The chapter also shows you how to use the special template definition syntax to explicitly specify template parameter types. A brief overview of the C++ standard template library (STL) is offered along with a discussion of STL containers, iterators, and algorithms.

Chapter 16: Dynamic Polymorphism: Object-Oriented Programming

Chapter 16 reinforces and builds upon concepts introduced in chapter 13. The focus is on the C++ language constructs required to write truly object-oriented programs. Topics discussed in depth include: employing pure virtual functions to create abstract base classes, how to use abstract base classes to specify the interface to derived classes, and what behavior to expect when using dynamic polymorphic programming techniques. The engine component aggregate class created in chapter 12 is revisited and redesigned to employ dynamic polymorphic behavior.

Part IV: Intermediate Concepts

Part IV consists of four chapters and builds upon the concepts and material presented in the preceding three parts. Key features and discussion points of part IV include:

  • How to write well-behaved, context-minded classes using the orthodox canonical class form,

  • How to use legacy C code libraries in your C++ applications,

  • How to use the Java Native Interface (JNI) to write C++ functions that can be called from Java applications,

  • How to use assembly language in C++ programs,

  • Coverage of three important object-oriented design concepts to include the Liskov substitution principle and Meyer design by contract programming, the open-closed principle, and the dependency inversion principle,

  • How to use a UML design tool to assist in the design and implementation of complex applications,

  • How to use a UML tool to reverse engineer existing C++ code.

Chapter 17: Well-Behaved Objects: The Orthodox Canonical Class Form

Chapter 17 presents an in-depth discussion of the orthodox canonical class form (OCCF) to write well-behaved, context-minded classes. Keeping the OCCF in mind when you design and write classes forces you to consider how those classes will be used in an application. The class’s possible uses or usage contexts will guide you in your choice of which operators to overload to insure your class objects exhibit predictable and acceptable behavior.

Chapter 18: Mixed Language Programming

Chapter 18 shows you how to use C++ with C, assembly, and Java. Topics covered include: using the extern keyword to prevent C++ name mangling, the Java Native Interface (JNI) and how to write C++ functions that can be called from Java programs, how to use inline assembly code in C++ programs using the asm keyword, and how to link to object modules created in assembly language.

Chapter 19: Three Design Principles

Chapter 19 presents and discusses three important object-oriented design principles: the Liskov substitution principle, the open-closed principle, and the dependency inversion principle. Bertrand Meyer’s design by contract programming is discussed in relation to the Liskov substitution principle.

Chapter 20: Using A UML Modeling Tool

Chapter 20 discusses the importance of using a UML design tool to assist in the application design process. The featured UML tool is Embarcadero Technologies’s Describe™. The chapter focuses on only a few of Describe’s many features: UML use-case, class, and sequence diagram creation, how to link diagram objects to other diagrams, how to generate code from class diagrams, how to reverse engineer existing C++ code, and how to generate comprehensive web-based project reports.



 < Day Day Up > 



C++ for Artists. The Art, Philosophy, and Science of Object-Oriented Programming
C++ For Artists: The Art, Philosophy, And Science Of Object-Oriented Programming
ISBN: 1932504028
EAN: 2147483647
Year: 2003
Pages: 340
Authors: Rick Miller

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