Programming 2 (NPRG031), Summer 2021

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 C# language and expand our knowledge of object-oriented programming. We’ll study features shared by C# and other modern languages, such as static typing, 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# 9 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 and programming techniques including dynamic programming and game-playing algorithms.

  3. We’ll learn about event-driven programming and graphical interfaces, and will discuss how to build larger programs using object-oriented design.

  4. If time permits, we may also discuss other topics such as regular expressions, recursive-descent parsing, multithreaded programming, network programming, and/or writing interpreters.

lectures and other meetings

All lectures and tutorials will occur over Zoom for at least the beginning of the semester.

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 1. 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 2 might be 300-500 lines long. Here are some project ideas. Please send me a one-paragraph project proposal by Sunday, May 2nd. A first working version of your project is due by Sunday, June 20th. A final version is due by Sunday, June 27th.

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

  4. Regularly attend the lectures and tutorials.

textbooks

resources

syllabus

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

To access any of the videos below, use our Zoom meeting ID and passcode (not your CAS login) as the username/password.

Mar 1 (lecture video) (notes) (exercises)
Introduction to C#. C# implementations. Hello, world. Local variables. Comments and whitespace. Fundamental data types: int, bool. Arithmetic, boolean, and relational operators. Flow control: if, while, for. Preincrement and postincrement operators. Characters and strings. String interpolation. Reading input. Variable scope. The standard class library.
Mar 8 (lecture video) (notes) (exercises)
More integer types. Numeric conversions. Integer overflow. Floating-point numbers. The 'do' statement. Foreach. The conditional operator (?:). The 'switch' statement. Arrays. Multidimensional arrays. Null.
Mar 15 (lecture video) (notes) (exercises)
Tuples. Named tuples. Methods. Expression-bodied methods. Overloaded methods. Optional arguments. Variable numbers of arguments. Reference and output parameters. Classes. Value and reference types. Fields. Constructors. 'this'. Private and public members.
Mar 22 (lecture video) (notes) (exercises)
Overloaded constructors. Static members, static classes. 'using static'. Enums. Properties. Indexers. Operator overloading.
Mar 29 (lecture video) (notes) (exercises)
Inheritance. Conversions between base and derived types. The 'is' and 'as' operators. Single and multiple inheritance. Overriding the base class. Virtual methods. Accessing base members. Protected members. Abstract methods and classes.
Apr 5 (tutorial video) (exercises)
No lecture (Easter Monday).
Apr 12 (lecture video) (notes) (exercises)
The top-level 'object' class. Interfaces. Interface inheritance. Generic types. Constraints. Generic methods. Default values. Nested classes. Collection classes in the standard library. Lists. Queues and stacks. Sets. Dictionaries. The 'var' keyword. Local functions.
Apr 19 (lecture video) (notes) (exercises)
Dynamic programming.
Apr 26 (lecture video) (notes) (exercises)
Delegates. Lambda expressions. Events. Two-dimensional dynamic programming problems.
May 3 (lecture video) (notes) (exercises)
Reading and writing files. 'using'. Exceptions. Programming graphical interfaces. GTK and Windows Forms.
May 10 (lecture video) (notes) (exercises)
Game playing. Minimax. Alpha-beta pruning.
May 17 (lecture video) (notes) (exercises)
Object serialization. Structured text formats: CSV, JSON, XML. Text processing. Regular expressions.
May 24 (lecture video) (notes)
Organizing and structuring code. Debugging. Optimization. Performance profiling. Build systems. Testing. Unit tests.
May 31 (lecture video) (notes) (exercises)
Processes and threads. Multithreaded programming. Test-driven development. Software engineering. Development methodologies. Code reviews. Bug tracking systems.