NPRG031 Programming II (summer 2017-8)
Instructor: Adam Dingle
Programming II is a fast-paced course that will build on our
knowledge from Programming I. The course has several goals:
We will learn the fundamentals of the C# language. We’ll
study a number of features that are shared by C# and many other
modern programming languages, such as classes, inheritance,
interfaces, generics, exceptions, and lambda expressions. 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
We’ll study various algorithms, data structures and
programming techniques including hash tables, dynamic programming,
recursive-descent parsing, informed (heuristic) searching and
We’ll learn how to build larger programs. We will discuss
basic principles of object-oriented design. Toward the end of the
semester, we’ll look at how to build programs in various practical
domains and will work through some extended examples. One such
domain will be graphical user interfaces. Others may include
network, database and/or game programming depending on how much time
we have and on students’ interests.
Lectures and other meetings
The weekly lecture for this
class takes place every Tuesday from 10:40 – 12:10 in room
S11. The first lecture will be on Tuesday, February
The weekly tutorial ("cvičení")
immediately follows the lecture every Tuesday from 12:20 –
13:50 in the laboratory SW2.
I will also hold two mentoring
sessions every week where we will work through additional exercises
together. These sessions will take place in room S510
every Wednesday from 10:00 – 12:00 and Friday from 14:00
To successfully complete this class,
Complete a number of programming
exercises through the semester. I will assign these exercises
weekly, and you can submit your solutions to the ReCodEx
automated grading system. You will need to earn at least 70% of the
possible points in ReCodEx.
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 300-500 lines long.
Take an exam at the end of the
Regularly attend the lectures and tutorials and participate
You can purchase these books in PDF format via the
This is a rough plan for the sequence of topics we will cover in
this class. It will probably evolve as the semester goes on.
- Feb 20 (tutorial notes)
Local variables and assignment. Integer types, bool, char, string.
Floating-point and decimal types. Arithmetic and Boolean operators.
Compound assignment operators. String interpolation. Flow control:
if, while, do/while. Accessing methods and properties in
the base class library.
Feb 27 (tutorial notes) (exercises)
Variable scope. More flow control: for, foreach, break, continue,
switch, goto. Implicit and explicit type conversions. Writing static
methods. Parameters and arguments. The return statement.
Expression-bodied methods. Arrays. The 'new' operator.
Multidimensional and jagged arrays. Calling constructors and
operators in the base class library. The 'using' directive. File
Mar 6 (lecture notes) (lecture/tutorial
Verbatim strings. Format strings. The conditional operator (?:).
Reference and output parameters. Out variables. TryParse. Parameter
arrays. Overloaded methods. Value and reference types. Null.
Encapsulation via abstract data types. Defining classes and instance
methods. The 'this' keyword. 'public' and 'private' access
modifiers. Defining constructors. Default constructors. Overloading
constructors. Constructor chaining. Overriding ToString().
Mar 13 (lecture notes)
Increment and decrement operators. Equality. Passing reference types
by value and reference. Nullable types and conversions.
Null-coalescing (??) and null-conditional (?.) operators. Enums.
Static fields. Static constructors. Static classes. Defining
properties. Indexers. Operator overloading. Resizable arrays. Linked
Mar 20 (lecture notes)
Assignment expressions. The 'is' operator. Polymorphism. Interfaces.
Casting between base and derived types. The 'as' operator. Interface
inheritance. Multiple interface inheritance. Explicit and implicit
member implementation. Implementation inheritance. Virtual methods.
The 'override' modifier. Calling base class methods. Defining
Readonly fields. Inheritance in the standard library. Calling base
class constructors. The 'protected' access modifier. Abstract
classes. Sealed classes and methods. Inheritance versus containment.
Model-view separation. Hash functions. Hash tables. Chaining. Open
addressing with linear probing. Dynamically growing hash structures.
The System.Object class. Overriding Equals() and GetHashCode().
Exceptions. throw, try/catch/finally. Optional parameters. Named
arguments. Finalizers. The 'using' statement. Nested methods.
Generic methods, classes and interfaces. Multiple type parameters.
Covariance and contravariance. Array covariance. Generic
constraints. Implicitly typed variables. Collection interfaces and
classes. Lists, stacks, queues, dictionaries. Collection
initializers. Extension methods on classes and interfaces. Checked
and unchecked conversions. Overflow and modular arithmetic. Bitwise
operators. Representation of signed integers and floating-point
Events. Programming graphical interfaces. The GTK# toolkit.
Delegate types. Lambda expressions. Statement lambdas, expression
lambdas. Outer variables. Map and filter functions on sequences.
Standard query operators: Where(), Select(), Count(). Deferred
Recursive-descent parsing. Dynamic programming. Top-down and
bottom-up approaches. Optimal substructure, overlapping subproblems.
No lecture (state holiday).
No lecture (state holiday).
Informed (heuristic) searching. The greedy and A* search algorithms.
Game playing. The minimax algorithm. Alpha-beta pruning.