Programming II (NPRG031), Spring 2019

Instructor: Adam Dingle

Programming II will build on our knowledge from Programming I. The course has several goals:

  1. We will learn the fundamentals of the C# language and object-oriented programming. We’ll study features shared by C# and other modern programming languages, such as classes, inheritance, interfaces, generics and exceptions. We will also study the C# collection class hierarchy and will learn to build our own collection classes.

    We will not attempt to cover every feature of C# 7 or go deeply into its class library; for that, you can take NPRG035 C# Language and .NET Framework, offered in the winter term.

  2. We’ll study various algorithms, data structures and programming techniques including hash tables, large numbers, expression trees, combinatorial search, dynamic programming, graph algorithms, game-playing algorithms, and recursive-descent parsing.

  3. We’ll learn how to build larger programs using object-oriented design.

  4. We will discuss additional practical topics, depending on how much time we have toward the end of the semester. These may include graphical user interfaces, interpreters, network programming, multi-threaded programming, informed (heuristic) searching, and/or version control systems.

lectures and other meetings

requirements

To successfully complete this class, you must:

  1. Complete a number of programming exercises through the semester, which I will assign weekly. You can submit your solutions to ReCodEx. You will need to earn at least 70% of the possible points for these exercises.

  2. Write a program in C# as a semester project. Your program should accomplish something that is interesting, cool, or fun and should be more substantial than your semester project for Programming I. A typical project for Programming II might be 400-600 lines long. Here are some project ideas. Please send me a one-paragraph project proposal by Sunday May 5th. Send me a first working version of your project by Sunday June 16th. The final version of your project is due by Wednesday June 26th.

  3. Take an exam at the end of the semester.

  4. Regularly attend the lectures and tutorials and participate in class.

textbooks

resources

syllabus

This is a rough plan for this class; it will probably evolve as the semester goes on.

Feb 19 (exercises)
Introduction to C#. Hello, world. Local variables and assignment. Integer types (int, long), bool, char, string. Floating-point types. Arithmetic and boolean operators. Compound assignment operators (e.g. +=, -=). 'if', 'while', 'do'/'while'. 'for', 'foreach', 'break', 'return'. (Michaelis, ch. 1-4)
Feb 26 (notes) (exercises)
String interpolation. Format strings. Arrays. Multidimensional arrays. Increment and decrement operators. The conditional operator (?:). 'switch'. Declaring and calling methods. Expression-bodied methods. Value and reference types. (Michaelis, ch. 3-5)
Mar 5 (notes) (exercises)
Implicit and explicit conversions. Type casts. Nullable types. Null-coalescing (??) operator. Reference and output parameters. Overloaded methods. Declaring and instantiating classes. Instance fields and methods. 'this'. Private and public. Constructors. Static members. (Michaelis, ch. 2-6)
Mar 12 (notes) (exercises)
'continue'. Parameter arrays. Defining properties. Static classes. Inheritance. Casting between base and derived types. 'protected'. Virtual methods. 'override'. Calling base class methods and constructors. Resizable arrays. Linked data structures. (Michaelis, ch. 4-7)
Mar 19 (notes) (exercises)
Implicitly typed variables. Single vs. multiple inheritance. The System.Object class. The 'is' and 'as' operators. Abstract classes and methods. Interfaces. Converting between classes and interfaces. Interface inheritance. Enums. Modular arithmetic. (Michaelis, ch. 7-9)
Mar 26 (exercises)
Generic methods. Generic classes and interfaces. Comparable objects. Generic constraints. Hash functions. (Michaelis, ch. 12; Cormen, ch. 11.3)
Apr 2 (exercises)
Hash tables. Separate chaining. Open addressing. Overriding Equals() and GetHashCode(). Operator overloading. Indexers. The 'default' operator. (Michaelis, ch. 10, 17; Cormen, ch. 11)
Apr 9 (notes) (exercises)
Nested classes. Enumerators. Iterators. Combinatorial search. (Michaelis, ch. 6, 15, 17)
Apr 16 (notes) (exercises)
Covariance. Collection interfaces and classes. Dynamic programming. (Michaelis, ch. 12, 17; Cormen, ch. 15)
Apr 23 (notes) (exercises)
Exceptions. throw, try/catch/finally. The 'using' statement. More dynamic programming. (Michaelis, ch. 5, 10; Cormen, ch. 15)
Apr 30 (exercises)
Delegates. Events. Programming graphical interfaces. Model-view separation. (Michaelis, ch. 13, 14; Sells)
May 7 (notes) (tutorial notes) (exercises)
Game playing. Minimax. Expression trees. Recursive-descent parsing.
May 14 (exercises)
No class (Rector's Day)
May 21 (exercises)
Multithreaded programming. (Michaelis, ch. 19, 20)