Lectures of the Technopark. 1 semester. C / C ++

  • Tutorial
We continue our weekly publication of Technopark training materials. Previous lectures were devoted to web technologies in general, as well as algorithms and data structures . The third block of lectures talks about the languages ​​C and C ++.

Lecture 1. Language C. Fundamentals of the organization and use of operational and superoperative memory


The lecture begins with an introduction to the language C: it tells about the history of its appearance, features, advantages and disadvantages, and areas of application. The basics of preprocessing are described, memory management issues (memory management models, visibility areas of storage objects) and the performance of C programs are discussed. Linking storage objects and their initialization is discussed. Then, memory classes in C are described. The next part of the lecture is devoted to the problems of pointers, as well as work with one-dimensional arrays. In conclusion, the POSIX standard and portability issues are discussed.



Lecture 2. Additional questions of the organization and use of operative and superoperative memory


The lecture begins with a discussion of multidimensional arrays. Using a two-dimensional array as an example, an effective bypass is shown. An example of the problem of matrix multiplication is analyzed, vectors of vectors are discussed. The following are a series of questions about pointers:
  • pointers and two-dimensional arrays;
  • pointer compatibility;
  • pointers to constants and constant pointers;
  • pointers and qualifier restrict.

Then it talks about the use of functions in relation to multidimensional arrays, about arrays of variable length. The following discusses the alignment and packaging of variable composite types, including the reorganization of data structures. Optimization of cache loading is considered: asymmetry of conditions, inlining of functions. The final part of the lecture is devoted to systemic aspects of memory allocation and release. In particular, it describes four parts of the data memory structure.



Lecture 3. Special Encapsulation Issues


Encapsulation is one of the three basic principles of object-oriented design. First of all, what encapsulation is described. The definition of the class is given, its composition is analyzed, the existing types of classes are listed. Class objects are considered in detail, including const, class attributes and methods, bit fields, and nested classes. The following describes the different types of class methods (static and non-static, built-in, constant, unstable), as well as pointers to them. Then the so-called friendly classes and functions are considered. Towards the end of the lecture, we will talk about union classes, anonymous and nameless associations, bit fields in class definitions. The final part of the lecture is dedicated to designers and destructors.



Lecture 4. Special issues of inheritance and polymorphism. Multiple and virtual inheritance. Dynamic Type Identification (RTTI)


At the beginning of the lecture, initialization without a constructor, default constructors, constructors with parameters, private and protected constructors are discussed. The following describes the mechanisms of term-wise initialization and assignment, copy constructors, conversion operations, as well as destructors, including virtual ones. The idiom RAII (Resource acquisition is initialization), an explicit call to destructors, and an initialization list in the constructor are discussed. Describes hyphenation in C ++ 11, including semantics and hyphenation constructor. The following basic principles of OOP are discussed, such as inheritance (early and late binding, base and derived classes) and polymorphism (protected and closed class members, overloading and overlapping class members). Then it talks about calling constructors and destructors of derived classes, initialization list for inheritance, virtual functions, and abstract classes. Describes virtual and multiple inheritance. The lecture concludes with a discussion of dynamic runtime type identification (RTTI) and type casting operations, the performance and security of polymorphism, and RTTI support.



Lecture 5. Templates of classes and methods. Exception handling. Generalized and safe programming


At the beginning of the lecture, class templates are defined and their parameters are considered. The mechanism of concretization of class templates is explained. It talks about template methods, about friendly objects in templates, about static members, about specialization of templates, including full and partial ones. An example of metaprogramming is the recursive definition of patterns. The essence of the new idiom, SFINAE (Substitution failure is not an error), is explained, including in relation to the introspection of compilation time. The solid part of the lecture is devoted to all kinds of characteristics of types. Describes the technology for handling exceptional situations. The next block of information is devoted to safe programming: the safety of classes, methods, constructors and destructors, security criteria and code neutrality.



Lecture 6. Practical introduction to STL. Functional programming in C ++


First, the story of the creation of the standard template library (STL) is described: the premises, the purpose of the STL, and the guarantees of performance. The following details about all the components that make up the STL:
  • sequential containers (vectors, decks, lists);
  • ordered associative containers (sets and multisets, mappings and multimaps);
  • sequential algorithms;
  • sequencing algorithms;
  • algorithms on numbers;
  • copying, predicate algorithms;
  • on-site algorithms;
  • sorting algorithms.

Comparison relations in algorithms, inverse relations, operations on sets and heaps are considered. Then it talks about STL iterators, their types (including insert iterators and stream iterators), ranges and operations supported by iterators. Toward the end of the lecture, standard STL functional objects and their base classes are discussed. Information on adapters (container, functional) is given. At the end, the use of containers in STL is addressed.



Lecture 7. Practical Introduction to Boost


The lecture begins with a story about lambda functions, the basic rules for their design, key advantages and the use of closures. Then Boost (a set of several dozen stand-alone libraries), its composition and purpose are discussed. The main part of the lecture is devoted to examining examples of using Boost: checking compilation time, type characteristics, variant containers, and smart pointers. In conclusion, we talk about using Boost tools to improve code performance and security.



Lecture 8. Principles and patterns of object-oriented design. Basic templates, GoF templates


The lecture opens with a lengthy discussion of the goals, problems and principles of object-oriented design. The following describes design patterns: what it is, what types of patterns are, and what are their advantages. The basic patterns and their implementations are considered:
  • inheritance and composition;
  • delegation;
  • immutable objects;
  • interface.

After that, three groups of GoF templates are parsed. Generative patterns:
  • abstract factory;
  • builder;
  • factory method;
  • prototype;
  • class with a single instance.

Structural patterns:
  • adapter;
  • decorator;
  • bridge;
  • linker;
  • facade;
  • opportunist;
  • deputy.

Behavioral patterns:
  • interpreter;
  • command;
  • chain of responsibility;
  • iterator;
  • the keeper;
  • state;
  • observer;
  • strategy;
  • intermediary;
  • visitor;
  • template method.

And finally, we talk about the principles of SOLID



Lecture 9. Idiomatics of C ++ language. The basics of refactoring and the quality of the source code. Coding Standards and Software Development Methodology


The final lecture in the framework of this course. First, the term “programming language idiom” is defined. Describes the idioms of procedural programming, about object-oriented idioms. Discusses memory management methods related to idioms of increased complexity:
  • context-sensitive indexing overload;
  • “Automatic” garbage collection and reference counting;
  • memory management by replacing new and delete operations;
  • envelope / letter idiom and delegated polymorphism.

The next part of the lecture is devoted to refactoring and static analysis of the source code: definitions are given, the possible application is described, advantages, disadvantages and associated risks are considered. Next, typical anti-patterns, “dirty techniques”, logical and semantic errors are analyzed. The problems of program optimization from the point of view of performance, the size of the object code and the amount of data memory are discussed. Then the concept of “quality software” is considered, functional and structural indicators of code quality are described. Describes the models and factors of software quality, including the McCall model. The following refers to code complexity as an attribute of software quality, how to manage complexity, and how modularity affects it. Then the concept of “technical debt”, standards and code styles, industrial development methodologies (organization rules and recording methods, commenting and documenting, software development life cycle, its models). And at the end of the course is an overview of SWEBoK (Software engineering body of knowledge).


Also popular now: