5.29k likes | 5.63k Views
Advanced Programming Techniques. Dr.- Ing . Harald Köstler 18.10.2010. Educational Goals, Lecture, Exercises, Exam, Contents, Literature . Organization and Motivation. Educational Goals. Know basics of C++ and object-oriented programming
E N D
Advanced Programming Techniques • Dr.-Ing. HaraldKöstler • 18.10.2010
Educational Goals, Lecture, Exercises, Exam, Contents, Literature Organization and Motivation
Educational Goals • Knowbasicsof C++ andobject-orientedprogramming • Beableto do modular andefficientimplementationsofalgorithms • Apply design patternsandstructureyoursoftware • What do youexpectfromthelecture?
Lecture • First partmainlybased on C++ Primer • Lessslides, morecodediscussions • Bring yourlaptopandworkaloneor in pairs • Askandgivefeedback • Change ofschedule • Monday 8:30-10:00, 0.111 • Tuesday 8:30-10:00, 0.111
Exercise • Responsible: K. Iglberger • Hand in ALL exercises • Exercisesheetsarefound online • http://www10.informatik.uni-erlangen.de/Teaching/Courses/WS2010/AdvProg/ • Schedule • Monday 16:00-17:30, 01.155 • Friday 12:30-14:00, 0.141
Organization • Youmayuse all operatingsystems (Linux, Mac OS, Windows) • Compilers, e.g. g++ or cl (Visual Studio) • Learntoprogramplatformindependent! • Prepare simple mainprogramforsmalltests • Why C++? • Object-orientedlanguage • Supports mostprogrammingparadigms • Usedbymanyresearchersandcompanies • suitablefor HPC (?!)
Contents • Part I : C++ • Introduction to C++ • Introduction to the C++ standard library • Basic Object Oriented Concepts • Advanced C++ Features • Part II : (Parallel) Software Design • Design Patterns and Software Engineering • Parallel Programming Concepts • Introduction to Parallel Programming Paradigms
Contents: Part I : C++ • Introduction to C++ • Variables, Types, Pointers • Expressions, Statements • Functions • Basic Object Oriented Concepts • Classes, Overloading, OO Programming • Introduction to the C++ standard library • IO library • Containers, Generic Algorithms
Contents: Part I : C++ (continued) • Advanced C++ Features • Generic Programming and Templates • Exceptions, namespaces • Multiple andvirtualinheritance • Special C++ andstandardlibraryTechniques (e.g. run-time type identification, unions) • Expression Templates and Template Meta Programming • C++ codingrulesandprogrammingparadigms • The Boostlibrary
Contents: Part II : (Parallel) Software Design • Design Patterns and Software Engineering • Basic Software Engineering concepts • Design Patterns • Software engineering@LSS: PE engineandwaLBerlaframework • Introduction to Parallel Programming Concepts and GPU Programming with CUDA/OpenCL • Summary and questions
Exam • Mainlybased on C++ Primer • Date: February on a Monday • Test exam in Dezember • Categories: • Reproduceandexplainterms in C++ and OO • Explainsyntaxandsemanticof C++ programs • Find errors in codefragmentsandcorrectthem • Write ownclassesandfunctions • Mapproblemstoclassesandalgorithms • Apply simple design patterns
Literature • S. Lippman et al, C++ Primer, 4th edition. Addison Wesley, 2005 (www.awprofessional.com/cpp_primer) • Andmanymore
Test • Explain: • Template • standardlibrary • operatoroverloading • expressionvsstatement • memberfunction • List standardlibrarycontainers • Describethe singleton design pattern
Basics Introduction to C++
The first C++ program • Terms: • statement, block, curly brace • function, function name, parameter list, function body • return type, argument • Questions: • How to compile and run program in Linux/Windows? • How to get return value in Linux/Windows?
Programming Language Features I • Essentially all programming languages provide: • Built-in data types (integers, characters, …) • Expressions and statements to manipulate values of these types • Variables, to name the objects we use • Control structures (if, while, …) to conditionally execute or repeat a set of actions • Functions to abstract actions into callable units of computation • But Programming languages also have distinctive features that determine the kinds of applications for which they are well suited
Programming Language Features II • Most modern programming languages supplement this basic set of features in two ways: • they let programmers extend the language by defining their own data types • they provide a set of library routines that define useful functions and data types not otherwise built into the language.
Standard IO • Terms: • variable, built-in type, expression, comment • standard library and IO, header, preprocessor directive • input/output operator, namespace, scope operator • Questions: • What means flushing a buffer? Why do so? • When to initialize variables?
While Statement I • Terms: • condition • compound assignment operator, prefix increment
Reading inputs • Questions: • How many inputs are read?
Classes • Terms: • data structure, class, member functions / methods • dot operator
Advanced Programming Techniques – Lecture 2 • Dr.-Ing. HaraldKöstler • 19.10.2010
Variables and Basic Types – C++ Primer Chapter 2 Introduction to C++
CodingConventionsforExercisesandExam • Intendyourcodeconsistently • Start a newlineforeachstatement • Namingconventions • Ownobjectnames: LikeThis • variables: likeThis • Class members: likeThis_ • Macros: LIKE_THIS • Integer types: i,j,k • Floating point: x,y,z • Comment yourcode, e.g. in declarationwhen variable isinitialized
Useful Tipps • plan-edit&comment-compile-debug-test • Compilecleanlyathighwarninglevels • Wall • Knowcompileroptions: g++, cl • Use an automatedbuildsystem • Make, cmake • Use a versioncontrolsystem (biggercodes) • svn • Invest in codereviews • Debuggers: gdb, ddd • Valgrind • Profilers: gprof