Programming 2 (NPRG031), Spring 2020

Instructor: Adam Dingle

Programming 2 will build on our knowledge from Programming 1 and Introduction to Algorithms. 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# 8 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 learn about event-driven programming and graphical interfaces, and will discuss how to build larger programs using object-oriented design.

  3. We’ll study various algorithms and programming techniques including combinatorial searching, dynamic programming and game-playing algorithms.

  4. We will discuss additional practical topics including the Git version control system. If time permits, we may also discuss multithreaded programming, network programming, recursive-descent parsing and/or writing interpreters.

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. Any points that you earn over 85% (up to a maximum of 15%) will be applied as bonus points to your exam score when you take the exam.

  2. Write a program in C# as a semester project. Your program should accomplish something that is interesting, and should be more substantial than your semester project for Programming I. It should be written in an object-oriented way, making good use of classes and other features we have learned in this course. A typical project for Programming II might be 300-600 lines long. Here are some project ideas. Please send me a one-paragraph project proposal by Sunday, May 3rd. A first working version of your project is due by Sunday, June 14th. A final version is due by Sunday, June 21st.

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

  4. Regularly attend the lectures and tutorials.

extra help

My office hours this semester are every Friday from 10:30 – 12:00 in room 405. Feel free to stop by if you'd like to discuss any material from this class.

textbooks

resources

syllabus

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

Feb 19 (notes) (exercises)
Introduction to C#. C# standards and implementations. Hello, world. Local variables. The 'var' keyword. Comments and whitespace. Fundamental data types: numeric types, booleans, characters, strings, arrays. String interpolation. Operators. Flow control: if, while, do, for. Variable scope.
Feb 26 (notes) (exercises)
The conditional operator (?:). The 'switch' and 'foreach' statements. Tuples. Multidimensional arrays. Classes. Private and public members. Fields. Constructors. 'this'. Methods. Overloaded methods. Expression-bodied methods. Static members, static classes. 'using static'. Value and reference types. Naming conventions. The standard class library.
Mar 4 (notes) (exercises)
Enums. Nullable types. Optional arguments. Reference and output parameters. Variable numbers of arguments. Properties. Indexers. Operator overloading.
Mar 11 (notes)
Interfaces. Generic types. Constraints. Default values. Generic methods.
Mar 18 (notes) (exercises)
Inheritance. Accessing base members. Virtual methods. Protected members. Conversions between base and derived types. Abstract methods and classes. Interface inheritance. Single vs. multiple inheritance. System.Object. Collections. Lists. Sets. Dictionaries. Queues and stacks.
Mar 25 (notes) (exercises)
The 'is' and 'as' operators. Exceptions. Handling exceptions. Throwing exceptions. Nested classes.
Apr 1 (notes) (exercises)
Delegate types. Functions as values. Local functions. Lambda expressions. Captured variables. Extension methods.
Apr 8 (notes) (exercises)
The 'using' statement. Events. The null-conditional operator ("?.()"). Programming graphical interfaces.
Apr 15 (notes) (exercises)
Covariance and contravariance. Iterators.
Apr 22 (notes) (exercises)
Generating sequences using recursion.
Apr 29 (notes) (exercises)
Searching using recursion. Dynamic programming.
May 6 (notes) (exercises)
Dynamic programming, continued.
May 13 (notes) (exercises)
Game playing. Minimax. Alpha-beta pruning.
May 20 (notes)
Version control. Git.