CSC428 - Advanced Object-Oriented Idioms in C++


Course Description

Learning the syntax and semantics of a language is less than half the battle. Most of the power to be gained from a particular language derives from the idioms it supports (the ways in which it may be used.) This course aims to give students an overview of some of the less obvious, but more powerful idioms that the C++ programming language supports. The course will be very practically oriented (with three assignments constituting the entire assessment) and will therefore assume existing competence with basic C++ (up to and including multiple inheritance, and templates).

Topics covered include: wrapper classes, factory classes, generic arrays and maps, envelope/Letter classes, double dispatch, reference counting, dynamic scope, proxies, template constraints, template specialization, persistence, functors, continuations, receptors, deriving new stream types, generators, functional and declarative programming.

The course will run during second semester 1995, on Tuesdays, 10am - 12 noon, in lecture theatre S11.

Source code is available under the directory ~damian/public/Idioms/ (~damian/bruce/public/Idioms on the SGIs)


Recommended reading

Booch, G, "Object-oriented Analysis and Design with Applications, 2nd Ed.", Benjamin-Cummings

Lippman, S, "C++ Primer, 2nd Ed.", Addison Wesley

Stroustrup, B, "The C++ Programming Language, 2nd Ed.", Addison Wesley

Stroustrup, B, "The Design and Evolution of C++", Addison Wesley

Meyers, S, "Effective C++", Addison Wesley

Coplien, J., "Advanced C++: Programming Styles and Idioms", Addison Wesley

Teale, S., "C++ IOStreams Handbook", Addison-Wesley


Other resources

[most extracted from LEARN C/C++ TODAY (copyright (c) 1994 Vinit Carpenter)]

Yahoo is a good starting point.

Otherwise there's:

   Title:	C++ Annotations (ver 3.3.3)
   Filename:	cplusplus.html
   Author:	Frank Brokken & Karel Kubat 
   E-mail:	frank@icce.rug.nl, karel@icce.rug.nl
   URL:		http://www.icce.rug.nl/docs/cplusplus/cplusplus.html

    This web based tutorial is  intended  for  knowledgeable users of C who
    would  like  to make the transition to C++.  This document presents  an
    introduction to programming in C++.  It  is  a  guide  for  programming
    courses  taught at State University of Groningen This document is not a
    complete C/C++ handbook, but  rather  serves  as  an  great addition to
    other  documentation sources.  The reader should take note of the  fact
    that an extensive knowledge of the C programming  language  is  assumed
    and required.

    This document continues where topics of the C programming language end,
    such as pointers, memory allocation and compound types which makes it a
    very good programming guide.  I  highly  recommend this tutorial to any
    individual who is really interested in becoming extremely knowledgeable
    on C++ and a proficient programmer.  Here is a listing of the chapters.

		1. Introduction to C++
		2. A first impression of C++
		3. Classes
		4. Classes and memory allocation
		5. Static data and functions
		6. Inheritance 
		7. Polymorphism, late binding and virtuality
		8. Concrete examples of C++ 
		9. Templates



   Title:	COMP.LANG.C++ FAQ
   Filename:	FAQ
   Author: 	Marshall P. Cline, Ph.D. 
   E-mail: 	cline@parashift.com
   URL: 	http://www.csse.monash.edu.au/~damian/c++FAQ.html

    This is the complete FAQ for the Newsgroups COMP.LANG.C++ compiled by 
    Dr. Marshall Cline.


Syllabus

  1. Containers

    Lecture 1
    • Generic arrays
    • Maps

    Lecture 2
    • Self-linking lists
    • Registries

    Lecture 3
    • Wrapper classes
    • Envelope/Letter classes
    • Double dispatch

  2. Free Store Idioms

    Lecture 4
    • Reference counting
    • Dynamic scope

    Lecture 5
    • Allocation tracing
    • Access logging

  3. Proxies

    Lecture 6
    • Map proxy
    • Intercepting '\0' in strings
    • Smart members

  4. Template Idioms

    Lecture 7
    • Template constraints
    • Persistence

    Lecture 8
    • Template specialization
    • Properties

  5. Functors

    Lecture 9
    • The Fork class
    • Filters and FilterStores

    Lecture 10
    • The Transform class
    • Continuations

  6. Input/Output

    Lecture 11
    • Redirecting standard input/output
    • Receptors

    Lecture 12
    • Deriving new stream types (stringstream)
    • An alternative approach (ProcInterface)

  7. Access Control

    Lecture 13
    • Simulating named arguments

    Lecture 14
    • Read-only members
    • Semi-virtual inheritance
    • Preventing implicit conversions
    • Circumventing old-style "for" variable scope

  8. Other Paradigms

    Lecture 15
    • Generators

    Lecture 16
    • Functional programming

    Lecture 17
    • Declarative programming (embedded grammar parser)

  9. Revision

    Lecture 18
    • Questions on notice


Really Hard Example

Nothing in the course will be tougher than the following example C++ program. If you can understand what it does and how it does it, you will breeze through "Advanced Idioms".

    #/*__(__)(__)(___&_,____&__)/*/include/*/()>__(_)<___,____>*/<iostream.h>//::_()
    #/*_(*__)&__(),(____*)&__(___*_,_&__);_(1<<1}*/define/*/*/__(_)/*__*/template##_
    #/**____(___)*/define/*_+(1<<1));}_(__(__)){*/_(_)/* */class/**/_/*/___()__/*_*/
    #/*&___+&_____(&___)*1>>1*1<<1*/define/*/*/_______/*/_______/*/void//*/____(__):
    int __(___)[1<<1<<1];__()<_(___),_(____)>_(__(_)){___&__(__);____&__(_____);__(_
    )(___&_,____&__);__()<_(_),_(__)>friend/*_*/_______/*/*/_____(_&_____,__&______)
    ;};_(__);main(){}__()<_(_),_(__)>_______/*_(__)+_<<_*/_____(_&_____,__&______){(
    _______)__(_)<_,__>(_____,______);}__()/*__(*)_*/<_(___),_(____)>__(_)<___,____>
    ::__(_)(___&_,____&__):__(__)(_),__(_____)(__){__(__)>>/*/*/*__(___)>>*(1+__(___
    ));for(;*((1<<1)+__(___))+=1&*__(___)?(*__(___)>>=1,__(___)[1]):(__(___)[!+1]/=1
    <<1)&&1>>1>>1,*(1+__(___))<<=1,*(__(___)+1););__(_____)<<*(__(___)+(1<<1));}_(__
    (__)/*__(_&_(_&___)),*(&__[1>>1]/*___*__*/){public:__(__)(){_____(cin,cout);}}_;


Damian Conway / damian@bruce.csse.monash.edu.au