PROCEDURAL AND OBJECT-ORIENTED PROGRAMMING

Degree course: 
Corso di First cycle degree in COMPUTER SCIENCE
Academic year when starting the degree: 
2021/2022
Year: 
2
Academic year in which the course will be held: 
2022/2023
Course type: 
Compulsory subjects, characteristic of the class
Credits: 
6
Period: 
Second semester
Standard lectures hours: 
48
Detail of lecture’s hours: 
Lesson (48 hours)
Requirements: 

The knowledge of a programming language and of basic data structures is highly recommended. The knowledge and skills necessary for a successful learning of this teaching are given in the fundamental courses of the first year of Programming and Algorithms and data structures.

Final Examination: 
Orale

The objective of the exam is to verify the acquisition of the knowledge and skills described in the "Educational goals" section, assessing the level of knowledge and the ability to put into practice the programming techniques seen in class.
The exam consists of a written test to be held in the classroom, followed by an optional oral test in case of a positive outcome. The written test - of an approximate duration of 120 minutes - includes a series of 6 questions related to the topics covered in class (5 points available for each question). The first three questions concern procedural programming and the C language, whereas the last three ones concern object-oriented programming and the C ++ language. A positive outcome (assessed in thirtieths) allows to access to the oral exam (optional). The oral exam starts with a joint vision of the written test. The student is informed about the correction criteria and called to provide any clarifications, thus allowing the teacher to verify the correctness of the assigned grade, making changes if necessary. Then, the student can choose whether to accept the grade or to continue the oral with in-depth questions on various topics covered in class. In this case, the final grade is given by the sum of the marks obtained in the written (weight 70%) and oral (weight 30%) exams.
The knowledge of the specific domain terminology is implicitly tested, as questions and problem specification use this terminology.

Assessment: 
Voto Finale

The course provides the basics of procedural and object oriented programming. These two paradigms are presented through concrete examples inspired to C and C++, the two languages that will be learned. The main goal is the knowledge of the inner mechanisms of language implementation.

Eventually, the student will be able

1. to develop programs in C and to understand the operational semantics of C;
2. to exploit basic and advanced features of OOP to develop C++ programs, through an effective use of the main constructs of the language.

Furthermore, the student will achieve the capability to proceed to an autonomous in-depth analysis of other programming languages (both procedural and object oriented), as well as a knowledge of the terminology in use in the OOP context. This is also facilitated by the acquisition of transversal skills, such as autonomy of judgment and critical spirit in the evaluation of the choices made when designing a language.

Lectures deal with the following topics:

Procedural Programming (24 h, educational goal 1)
- Procedural programming: basic definitions and notions (4h)
- The C language: basics (8h)
- The C language: advanced features (12h)
Object oriented programming (24 h, educational goal 2)
- Object oriented programming: basic definitions and notions (6h)
- The C++ language: basics (6h)
- The C++ language: advanced features (single and multiple inheritance, visibility, polymorphism, subtyping) (10h)
- The STL library (2h)
Topics are illustrated by using C and C++. Nevertheless, most of the topics covered in the course are of general validity, and the techniques illustrated work also for other languages.

Procedural programming: basic notions (procedures, functions, rules for passing parameters, scope rules). Static vs. dynamic type checking.
The C language: history and evolution, built-in types. C: arrrays and structures. The control structures of C. Input output (printf and scanf). Pointers, operators * (indirect addressing - dereferencing) and & (address extraction). Pointer-array equivalence. Arithmetic of pointers. Expressions, functions and return statement. Rules for passing parameters. Procedure activation record format. Scope rules. Local variables and global variables. Memory layout of a C program. Storage classes. The C preprocessor: header files and macros (with or without parameters). The preprocessor and the conditional compilation. Functions with a variable number of arguments. The va_list, va_start, va_arg and va_end macros. Unformatted input/output: getc (), getchar (), putc () and putchar (). Dynamic memory management (malloc, calloc and free). Arrays as function parameters. Function pointers. The "const" type qualifier. Operators with side effect and expression evaluation. The C and the file system.

Origin of object-oriented programming: Hw and Sw evolution. SW quality and development methodologies. SW development and modularity. The object-oriented approach. Information hiding and encapsulation. Classes, methods and attributes. Interfaces. Modeling and identification of classes. Data types and abstract data types. Classes, objects and inheritance. Simple and multiple inheritance. Specialization and replacement. Messages and conflicts. Types and subtypes. Inheritance and constraints (specialization and replacement). Polymorphism and genericity.
Pure languages ​​and hybrid languages. Object-oriented languages ​​overview. Binding and overloading mechanisms. Methods as a function of the recipient and supermethods.

C++: main characteristics, class-structure correspondence, visibility control.
Constructors and destructors. Call order of constructors and destructors. The This pointer. Online methods, declaration of friendship. Type conversions, ambiguity in type conversions. Static members. Simple inheritance. Inheritance and calling order of constructors/destructors. Modes of inheritance (public, protected, private). Modes of inheritance and pointer conversions (base class access control). Virtual functions and virtual function table. Final virtual classes and functions. Polymorphism. Abstract classes. Multiple inheritance and virtual base classes. Multiple inheritance and ambiguity. Implementation of virtual base classes. Overloading: basics. Function overloading, rules for matching actual parameters - formal parameters. Operator overloading. Genericity (template classes and template functions). The Standard Template Library.

Lectures (48 hours). Each lecture presents both theoretical and implementation issues.
All the educational material is available in advance. The student is invited to be present in the classroom after having read the lesson material. The lesson will be carried out in such a way as to increase interaction, discussion and consequently learning.

The teacher receives by appointment, upon request by e-mail to name.surname@uninsubria.it. The teacher responds only to e-mails signed and coming from the students.uninsubria.it domain.