Programming 2 (NPRG031), Summer 2022

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# 10 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, 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 your tutorial teacher will assign weekly. You can submit your solutions to ReCodEx.

    In Adam Dingle's tutorial, you will need to earn at least 70% of the possible points for ReCodEx exercises. Any points that you earn over 85% (up to a maximum of 15%) will be applied as bonus points to your exam score. For example, if your ReCodEx score is 90%, then you will have a 5% exam bonus.

    In Martin Pergel's tutorial, you will need to earn at least 50% of the possible points for ReCodEx exercises. Any points that you earn over 70%, divided by 2 (up to a maximum of 15%) will be applied as bonus points to your exam score. For example, if your ReCodEx score is 80%, then you will have a 5% exam bonus.

  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 your tutorial teacher a one-paragraph project proposal by Sunday, April 24th. A first working version of your project is due by Sunday, June 5th. A final version is due by Sunday, June 12th.

  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.

Feb 14 (lecture video) (tutorial video) (notes) (exercises)
Introduction to C#. C# implementations. Hello, world. Local variables. Comments and whitespace. Fundamental data types: int, bool. Integer overflow. Arithmetic, boolean, and relational operators. Flow control: if, while, for.
Feb 21 (lecture video) (tutorial video) (notes) (exercises)
Writing a Main() function. Implicit namespaces. Preincrement and postincrement operators. Characters and strings. String interpolation. Reading input. Null. Nullable types. The null-forgiving operator (!). Foreach. Arrays.
Feb 28 (lecture video) (tutorial video) (notes) (exercises)
More integer types. Numeric conversions. Floating-point numbers. The 'do' statement. The conditional operator (?:). The 'switch' statement. Multidimensional arrays.
Mar 7 (lecture video) (tutorial video) (notes) (exercises)
Tuples. Named tuples. Functions. Expression-bodied functions. Optional arguments. Variable numbers of arguments. Reference and output parameters. Enums. Classes. Fields. Private and public members. Value and reference types. Constructors. 'this'. Methods.
Mar 14 (lecture video) (tutorial video) (notes) (exercises)
Overloaded methods and constructors. Static members, static classes. 'using static'. Properties. Indexers. Operator overloading.
Mar 21 (lecture video) (tutorial 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. The top-level 'object' class.
Mar 28 (lecture video) (tutorial video) (notes) (exercises)
Exceptions. try/catch/finally. The 'using' statement. Interfaces. Interface inheritance. Generic methods. Generic classes and interfaces. Constraints. The 'var' keyword. Default values. Nested classes. Collection classes in the standard library.
Apr 4 (lecture video) (tutorial video) (notes) (exercises)
Delegates. Local functions. Lambda expressions. Events. Iterators. The 'yield' statement. Extension methods.
Apr 11 (lecture video) (tutorial video) (notes) (exercises)
Dynamic programming. Graphics libraries. Introduction to GTK.
Apr 18 (tutorial video) (exercises)
No lecture (Easter Monday)
Apr 25 (lecture video) (tutorial video) (notes) (exercises)
Two-dimensional dynamic programming problems. Game playing. Minimax.
May 2 (lecture video) (tutorial video) (notes) (exercises)
Alpha-beta pruning. Simple games. More about GTK. Drawing with Cairo. Mouse and keyboard input.
May 9 (lecture video) (tutorial video) (exercises)
Text processing. Regular expressions. Comma-separated values. JSON.
May 16 (lecture video) (tutorial video) (exercises)
Writing larger programs. Organizing and structuring code. Debugging. Optimization. Performance profiling. Software engineering. Development methodologies. Code reviews. Bug tracking systems.