"
There are two ways of constructing a software design; one way is to make it so simple
that there are obviously no deficiencies, and the other way is to make it so complicated
that there are no obvious deficiencies. The first method is far more difficult.
"
- C.A.R.Hoare
I'm reviewing all this code, and will be:
Removing out-of-date code examples
Moving and renaming folders to make them easier to use
Adding new code
Preface:
I've written all the code provided here, except where explicitly attributed to another author. Most of the code
was written to:
Illustrate design ideas for my classes
Implement a few of the harder projects to show ways that can be done
Make tools for managing my own code
Demonstrate language features and quirks
Of course, the flow of ideas is two-way. I also adopt good ideas and techniques used by my TAs and students.
Since I write a lot of code, as well as teach large classes, and advise research projects, I cannot always test my
code as thoroughly as I would like. For that reason, I cannot warrant this code for any specific use.
You are free to use my code in any way you think fit, but the responsibility for its correct operation in your
programs and environment is yours. Feel free to offer constructive criticism of any of the code you find here.
Note about Visual Studio:
Most of the code linked on pages of this site has been developed with Visual Studio. I am now using Visual Studio 2017
so you will need this latest version to build a lot of the code here.
You can download the Visual Studio Community Edition
here. It's free.
The community edition requires about 1 GB of unused disk space.
If you are a matriculated student you can download the Enterprise Edition at no cost from
Dreamspark
using your SU credentials.
Both editions provide all of the features you need for my courses.
Comes with a simple WPF app that selects paths and supplies command line arguments. Output is a list of
functions and methods, by package, with function size and complexity metrics. TAs and I use this tool
to analyzer your project code, so you may wish to use it, yourself, before submitting projects.
Code WebifierMore
Tool to convert source code for webpage presentation, by embedding code in <pre>...</pre> blocks,
with markup character escaping and
suitable styling. The tool writes its output to a console, so the block can be cut and pasted directly
into web pages.
Code Differences using WPF GUIMore
This tool uses Windows FC - file compare - tool via a WPF interface that supports browsing for files
and displaying differences in a text block.
Duplicate FilesMore
Console application that finds all the paths to each file, e.g., multiple files with the same name in different
locations.
File DatesMore
Lists files matching one or more patterns, ordered by their last modfication time-date stamps.
File SizesMore
simple, but not very flexible, as each application has to tailor DE's code.
DirectoryExplorer-Template:
More
More
Uses templates to incorporate application needs.
DirectoryExplorer-Inheritance:
More
More
Applications derive from DiretoryExplorer base class to provide for application needs.
DirectoryExplorer-Events:
More
More
Binds application specific event handlers to unmodified navigation code. This is a very
common idiom used for industrial code.
DirectoryExplorer-Provider:
More
More
Separates Depth First Search from Directory handling. Application defines a File System provider that DFS uses.
These projects provide a very nice illustration of ways to build flexible code that easily accomodates needs of different
applications. We will go over these examples carefully in an early lecture.
C++11 blocking queue
Defines in C++11 a thread-safe queue that blocks on a deQ() call when the queue is empty. This behavior
is implemented with a condition_variable and mutex. It is very useful for implementing asynchronous message-passing systems.
C# blocking queue
Same behavior as above. Implemented in C# using the .Net Monitor construct.
Recursively finds files and directories, and executes application specific processing when those events occur.
Navig code binds to application processing using delegate event handling, so Navig is not changed
for different applications.
Database that contains a hashtable of Key/Value pairs. Each Value contains a small set of fields which are
common to many applications, a set of Keys that point to dependencies, and a parameterized payload that can
be configured for the needs of a specific application.
Database that contains a hashtable of Key/Value pairs. Each Value contains a small set of fields which are
common to many applications, a set of Keys that point to dependencies, and a parameterized payload that can
be configured for the needs of a specific application.
MTree
Implements an M-ary Tree data structure, e.g., unbalanced tree where any vertex may have an arbitrary finite number of children.
C++ code TokenizerMore
More
Tokenizers extract words, called Tokens, from a stream, e.g., file or stringstream. Lexical scanners
form token collections using Tokenizers, to begin the process of code analysis.
C++ Lexical ScannerMore
This Lexical Scanner collects tokens from the Tokenizer, above, and uses
tokens "{", "}", ";", and "\n" for lines beginning
with "#" to terminate a token collection, called a semi-expression. Semi-expressions are the basis
for code analysis, as used in the Parser, below.
C++ code parserMore
This Parser is a core part of several of the projects listed on this page, include the CodeAnalyzer.
Parser is a container for Rules and Rules are containers for actions. Each rule is a detector of some grammatical construct. When a
rule matches a token sequence (called a semi-expression) it invokes its actions.
C# code TokenizerMore
Functionality similar to the C++ tokenizer, but written in C#.
C# Lexical ScannerMore
Functionality similar to the C++ Lexical Scanner, but written in C#.
C# code parserMore
Functionality similar to the C++ code parser, but written in C#.
Sockets - Windows
Provides classes Socket, SocketListener, SocketConnecter, and SocketSystem.
Supports both IP4 and IP6.
Sockets - Linux
Same as above, but ported to Linux.
C++ Comm with File TransferMore
Implements asynchronous message-passing communication channel, using Sockets, passing HTTP style messages.
Files are chunked by a Sender and sent in message bodies. Chunks are reassembled into a file at the Receiver.
C# Comm with File TransferMore
Implements asynchronous message-passing communication channel, Windows Communication Foundation (WCF), passing HTTP style messages.
Files are chunked by a Sender and sent in message bodies. Chunks are reassembled into a file at the Receiver.
Process
Provides a C++ class wrapper for the Win32 process creation API.
Utilities
Provides a miscellaneous collection of low-level utilities for C++ string handling and display, type conversions, and testing.
Provides an XML Document class that supports reading XML from files or strings, programmatically building and editing XML documents
and display of the resulting documents.
C++ Xml Reader
Provides a simple XML reader, based on string parsing. It's missing a few capabilities offered by the XmlDocument facility, but
is significantly simpler.
C++ Xml Writer
Provides a simple XML writer, based on string parsing.
This is my solution for Project #4. It's still incomplete,
but functional. All the parts, including the Server and Client GUI are working. What's still
missing are: connecting and using the NoSql Database, versioning, Checkin, and Checkout.
Many of the parts for that are working, including message and file transfer, and directory navigation, but not yet fully integrated.
This is my solution for Project #4. It's relatively complete. It supports versioning, checkin, checkout,
browsing with both local and remote file views. Its structure is based on a set of pluggins for each of those
functions - allowing users to tailor the repository to their own development styles by implementing one or more
altered pluggins. On limitation of this Repository is its limited directory structure. Unlike the C++ Repository,
it supports only a top level, with one level of subdirectories. That's probably easy to fix, but I haven't
done that yet.
BASIC
Basic examples of: pointers and C++ references, implementing and using classes, templates, composition, and
inheritance in simple demonstration code.
Relationships
Demonstrates the four primary class relationships: composition, inheritance, using, and aggregation (weak form of ownership)
with simple demo classes.
MutualDependencies
Demonstrates how to build code with packages that need to depend on each other. This folder contains two projects,
one that illustrates working with Type dependencies, and another that illustrates working with Instance
dependencies.
Equiv
Shows how to call constructors in different program contexts.
Hiding
Demonstrates hiding and other substitution errors in polymorphic designs.
casts
Four new casts: static_cast, reiterpret_cast, const_cast, dynamic_cast.
exceptions
Illustrates use of C++ exceptions and standard exception classes.
Alias Demo
Aliases used in Symbol Table definition
DemComp - illustrates syntax and issues with composition
DemInher - illustrates syntax and issues with inheritance
several other small, not as important, low-level demos
Look at DemComp and DemInher carefully.
They demonstrate how constructors and destructors
are called, some circumstances when temporaries are created, and most importantly why you must use
initialization sequences for all the constructors you write (with the exception of default constructors).
HexConvert
Helper macros used to convert binary code to and from hexadecimal strings.
Base64 Encoding
Convert binary code to and from base64 strings.
iostreams
Demonstrates basic iostream operations, formating, reading and writing with files, and use of stringstreams.
streambufs
Demonstrates a few uses for the streambuf classes buried inside iostreams, fstreams, and stringstreams.
streambuf example
Shows how to redirect a stream.
FileSystem for Linux
Provides capabilities to extract information from the linux file system, e.g., directories, files, and paths.
FileSystem for Windows
Same capabilities and interfaces as FileSystem-Linux for the Windows operating systems.
STL_helpers
More STL related code that will be used to look at parts of the STL.
STL Odds and Ends
Illustrates use of inserters and functors for selecting sort method in associative containers.
STR
A simple string class used to illustrate Abstract Data Types - that is, orchestrating your C++ design and implementation to
support almost all of the operations provided for built in types.
Blocking queue
Threadsafe blocking queue using std::queue, std::condition_variable and std::mutex
Xml Document
Provides an XML Document class that supports reading XML from files or strings, programmatically building and editing XML documents
and display of the resulting documents.
MTree
Implements an M-ary Tree data structure, e.g., unbalanced tree where any vertex may have an arbitrary finite number of children.
Tree Traversal
Illustrates how to walk a tree using either recursion or stack processing
QServer
Global access to queues using template wrapper holding static queue
HashTable
Good example of templates, policy - HashString, and traits - key_type, value_type, iterator. Shows how to implement
container and iterator classes so they integrate with the STL algorithms.
Math::Vector
A fixed size ordered collection of coordinates. Coming soon - Math::Matrix (linear operator on Vectors)
These will be used with graph visualizer, currently in the early stages of design.
Objects that support multiple interfaces and use object factory
This is a technique for supporting extension of interfaces without breaking a lot of client code. This is essentially
what COM does.
Factory with static map
Illustrates the use of a class factory to support the program-to-interface paradigm. Factory uses a static map of creational function pointers.
Interfaces with static factory function
Illustrates how to build object factories using static factory method. Creates any object found on a give inheritance hierarchy.
XmlDocument uses abstract base class
Illustrates using abstract base to support sharing code and data between derived classes. Uses global factory methods.
QServer
Provides singleton access to one queue in a specified category by wrapping a static blocking queue in a template class.
MakeDLL
Shows how to build a DLL. See the accompanying presentation about the required project properties.
DLL Demo
Demonstrates how to create and load, either implicitly or explicitly, dynamic link libraries (DLLs).
Notifier
Illustrates use of events and callbacks in a "Publish/Subscribe" structure.
SmartPointer
Illustrates how to build a "smart pointer" class - prefer std::unique_ptr.
SmartPtr
Illustrates how to build a reference counted "smart pointer" class - prefer std::shared_ptr.
Traceable
Illustrates use of inheritance to extend, without modification, an existing class - here the std::string class.
Blocking queue
Threadsafe blocking queue using std::queue, std::condition_variable and std::mutex
Win32 Thread class
Shows how to build a C++ thread class and locks classes based on the Win32 API (you should prefer the C++11 constructs)
Concurrent File Access
Concurrent access to files with both readers and writers
synch
Shows how to serialize access to shared resources using Win32 threads and synchronizing constructs.
ProcessDemoWin32
Shows how to programmatically start a process using the Win32 API.
WinMin
Builds a very simple windows application using the Win32 API with a message loop and WinProc function. Basic Windows
Illustrates Win32 GUI Windows programming
Win32 Controls
Illustrates Win32 GUI Windows programming using Controls
C++/CLI Winform
Illustrates how to create winforms with C++/CLI
C# Demos
Demonstrate classes, class relationships, generics, enumerables, and extension methods.
ProgramStructure
Illustrates how to lay out a C# program using an executive and server module. Also shows correct
format for manual and maintenance pages.
commandLine
Shows how to read command line, extract file patterns, and find matching files.
C# Examples
Demonstrates arrays, indexers, properties, types, and disposing
C# Equivalence
Demonstrates equivalence operators and virtual functions
Conversions
Demonstrate converting between primitive and string representations using Parse and ToString
Dynamic Types
Demonstrates dynamic types
DLLs
Illustrates use of dynamic link libraries with both implicit and explicit loading
ConcurrentFileAccess
Demonstrates how to allow multiple processes concurrent access to the same file for both reading and writing.
Base64Encoding
Demonstrates a relatively efficient way of converting binary file data into strings to send as XML messages.
FileDialogDemo
Illustrates use of FileDialog control in a WinForm application.
Interface-based Programming
Demonstrates composition of program with executive and components that expose interfaces. One component uses
three others with references to their interfaces.
Plugin Architecture
Executive loads dlls from a known path, uses reflection to find classes supporting the IPlugIn interface, creates
instances of those classes and calls their "test" method.
DLLs
Illustrates use of dynamic link libraries with both implicit and explicit loading
reusableDemo
Shows how to build reusable components using the Abstract Factory Pattern and abstract base classes.
Application Domain
Demonstrates how to create and use an AppDomain instance.
Concurrent File Access
Demonstrates concurrent file access with both readers and writers
AsyncExamples
Shows how to make asynchronous calls to both local and remote objects.
Thread Pool Demo
Illustrates how to run a method on a thread pool thread and receive a callback when the method completes.
BackgroundWorker Thread
Illustrates use of worker thread and Form.Invoke in a WinForm application.
synch
Shows how to serialize access to shared resources using Win32 threads and synchronizing constructs.
WorkerThread
One more demonstration of threading under .Net.
ProcessDemoWin32
Shows how to programmatically start a process using the Win32 API.
TcpClient and TcpListener
Illustrate .Net TcpClient and TcpListener classes
socketDemo_DotNet
Illustrates how to build a socket-based communication program in .Net. Seperate projects build
single-threaded and multi-threaded servers.
Message Framing
Shows how to extract XML messages from a socket transmission (sockets only understand bytes).
Message Framing with threads and queues
Shows how to extract XML messages from a socket transmission in a robust, reusable way with the
help of child threads and blocking queues.
WCF BasicHttp Services
Both declarative and programmatic BasicHttp services - hand crafted
WCF WsHttp Services
Both declarative and programmatic WsHttp services - hand crafted
--- Remoting - an older technology now largely replaced by WCF ---
RemotingDemo
Demonstrates communication between two machines using .Net remoting and singleton server.
Remoting_BilateralComm
Shows how to set up both a client channel and a server channel that support acting as both a client
and a server in the same process. The trick is to use named channels.
Remoting_PassByRef
Illustrates how remoting server can communicate back to client using a Pass-by-Reference object.
Remoting_PassByRefFileXfer
Shows how to download files from a single-call server using Pass-by-Reference object.
Remoting_PassByValue
Illustrates how to pass an object of a user-defined type to a remote object by value.
PeerToPeerPrototype
Shows how to build a chat application using bilateral remoting with named channels.
BijlaniPrototype
A student prototype, with presentation, that compares performance of the three remoting activation models in
an XML message-passing context.
DropDown Menu
Illustrate how to build a drop-down menu with jQuery (Javascript library) and CSS.
Javascript Examples
This is a demo of Javascript basics written for IE6. Since IE is now more standards compliant
some of the formatting is no longer correct.
jQuery Demos
Illustrates basic operations with jQuery Javascript library:
Creating alerts
Responding to button clicks on page elements
Adding new page elements
Dynamically changing styling with button clicks and mouseovers
Calc
Simple calculator compares processing on client, on server with ASP, and on server with Asp.Net.
Asp.Net Life Cycle
Demonstrates many of the events that fire when a composite page loads.
Load Control
Illustrates how to create a custom control and load/unload dynamically.
Create database using LINQ
This is a console application that shows how to create a database, add tables, make queries, and delete using LINQ.
MvcState
Demonstrates an Asp.Net Mvc application using Session to store a shopping cart.
MvcFileMgr
Demonstrates implementing File Transfers in an Asp.Net Mvc application.
MvcCRUDwithXML
Illustrates building Asp.Net Mvc site using XML as the backing store.
MvcCRUDwithSQL
Illustrates building Asp.Net Mvc site using SQL Server as the backing store.
Books Site
Illustrates developing sites with many-to-many relationships using Asp.Net Mvc.
--- Client-Server Programming ---
Classic HTML
Classic HTML application uses Markup for content, CSS for presentation, and Javascript for behaviour.
HTML5 and Javascript
Illustrates some layout techniques using HTML5.
Ajax Introduction
Simple demonstration of Ajax interaction with server. It appears to have broken with the last Asp.Net Mvc version change. I will fix eventually.
In the meantime you can create a new Asp.Net Mvc application and reproduce the code here to get this working.
CalcWebService
Presents a minimal web service. demoWebService
Demonstrates how to build a basic web service using C# code-behind. Includes step-by-step screenshots
FileXferWebService
Shows how to transfer files to a remote location using text messages.
demoAspApplication
A simple Active Server Pages demo. Requires the creation of a virtual directory. Instructions are included.
--- WCF Services ---
BasicHttp Services
A simple service passing strings. It was built from a console application that imports all of the
WCF Framework parts needed for the demo. How to do that is commented in the code.
WsHttp Services
A simple service passing strings. It was built from a console application that imports all of the
WCF Framework parts needed for the demo. This includes some security functionality.
Self-Hosted File Transfer Service
Provides file opening, tranfer of file blocks, and file closing, on both client and server.
Self-Hosted File Streaming Service
Provides file transfer using a file stream metaphor.
Peer-to-Peer chat-like application
Provides Windows Presentation Foundation GUIs connected through a WCF channel, used to send string messages.
WCF message passing using several different bindings
Provides multiple clients, each using a different binding, e.g., BasicHttp, WsHttp, and NetTcp to simultaneously
send messages to a single server that supports endpoints for each of those protocol bindings.
WCF approximately Restful service
Server supports the primary web methods: GET, PUT, POST, and DELETE, to build a CRUD facility.
XDocument
Illustrate creation of XML using the XDocument class
xmlApps
Demonstrates how to use the XmlDocument, XmlNodeReader, XmlTextReader, and XmlTextWriter classes.
XMLdemo
Illustrates how to programmatically added, delete, and modify elements of an XML file using the
XMLDocument and XMLNode classes.
XMLMessages
Shows how to build and parse a message structure that could be used in a remoting communication layer. No actual
remoting is done in this demo.
Base64Encoding
Demonstrates a relatively efficient way of converting binary file data into strings to send as XML messages.
Application Domain
Demonstrates how to create and use an AppDomain instance.
Serialization
Demonstrate serialization to and from a MemoryStream using SOAP formatting
Speech to Text
Demonstrate the Speech API reading text
Interface-based Programming
Demonstrates composition of program with executive and components that expose interfaces. One component uses
three others with references to their interfaces.
Plugin Architecture
Executive loads dlls from a known path, uses reflection to find classes supporting the IPlugIn interface, creates
instances of those classes and calls their "test" method.
Serialize
Shows how to serialize an object's state to a stream.
AttributedProgram
Illustrates creation and use of custom attributes in C# programs.
High resolution timer interop
Illustrates using native C++ high resolution timer from C# with Platform Invoke - 10,000 times
finer resolution than standard Framework Class Library timers.
RandomEvents
Creates random numbers and random events, including events occurring with some average density over time.
reflection
Demonstrates how to use Directory operations and Reflection to extract type information.
reusableDemo
Shows how to build reusable components using the Abstract Factory Pattern and abstract base classes.
XML Metadata Scanner
This is a prototype of a program to scan through a collection of files that are linked by references
in manifest files. It was a small prototype for a Software Repository project.
Test Harness Prototype
Demonstrates how to build a test harness that loads test libraries into a child AppDomain so they can
be unloaded after testing. The test harness loads the library assemblies, uses reflection to find
test classes that support the ITest interface, creates instances of the discovered classes and
invokes their test() method, using InvokeMember.
Run Compiler
Shows how to create a build process by spawning the C# compiler in a child process.
C# Winform
Illustrates how to create winforms with C#
C# Form with Browse Control
Demonstrates use of FolderBrowserDialog
Synchronous FormInvoke
Demonstrates use of synchronous FormInvoke to return results to UI thread from child thread
Asynchronous FormInvoke
Demonstrates use of asynchronous FormInvoke to return results to UI thread from child thread
Winform Worker thread
Illustrates use of worker thread and Form.Invoke in a WinForm application.
WorkerThread
One more demonstration of threading under .Net.
WinForm Demo
shows how to use images and react to mouse moves in a WinForm application. nonClientHit
Illustrates interacting with the underlying windows message loop to react to NChits - messages due to user
actions in the Non-Client area (not available from the exposed WinForm events). demoControls
Demonstrates how to build both list and treeview controls that add functionality to those provided in the
Winform toolkit. The TreeViewPlus control, for example, derives from TreeView and adds automatic lazy initialization
of the control with drives, folders, and files. It opens the control expanded to the current directory. dialogDemoCS
Shows how using a worker thread in C# can prevent UI from freezing during intensive computations. FileDialogDemo
Illustrates use of FileDialog control in a WinForm application. usingListView
Demonstrates use of ListView control and display or hiding of forms at run-time. Folder TreeView
Shows how to populate a TreeView with directory and file information, using lazy evaluation. Also
shows how to expand the TreeView to the current directory when program starts.