Presentation is loading. Please wait.

Presentation is loading. Please wait.

T01. Outline and concepts Promising future comes from the dedication.

Similar presentations


Presentation on theme: "T01. Outline and concepts Promising future comes from the dedication."— Presentation transcript:

1

2 T01. Outline and concepts

3 Promising future comes from the dedication

4 Topics 1.Course outline. 2.Concept of programming P175B013 T01 3

5 Course outline

6 Introduction to programming P175B013 Liudas Motiejūnas, liudas.motiejunas@ktu.lt

7 Course Target For beginners who want to become professionals i.e., people who can produce systems that others will use who are assumed to be bright Though not (necessarily) geniuses who are willing to work hard Though do need sleep occasionally, and take a normal course load Using the C++ programming language Some experience in programming is preferred

8 The Aims Teach/learn Fundamental programming concepts Key useful techniques Basic standard C++ facilities After the course, you’ll be able to Write small colloquial C++ programs Read much larger programs Learn the basics of many other languages by yourself Proceed with next programming course

9 Why C++? You can’t learn to program without a programming language C++ is the language that most directly allows you to express ideas from the largest number of application areas C++ is widely used language in different areas C++ has inspired several other programming languages and still remains in large use. Programming concepts that you learn using C++ can be used fairly directly in other languages

10 Programming languages P175B013 T01 9 C family langua ges >50%

11 P175B013 T01 10 Rough course outline Introduction to object-oriented programming I/O facilities Program structuring Objects and arrays Basic algorithms on arrays Containers

12 P175B013 T01 11 Practice P0. C++ tool. P1. Class. P2. Array of objects. P3. Container.

13 P175B013 T01 12 Time table

14 P175B013 T01 13 Final score P = ( P1 + P2 + P3) / 3, where: P i – assessment( up to 10), Final score = P * 0,7 + T *0,3 T - test (All grades ≥ 5)

15 P175B013 T01 14 Exam If there will be assignements with grades less than 5 after semester, exam will be mandatory. Exam (oral) – questions from your programs Final score = P * 0,5 + T * 0,2 + E * 0,3 E - exam

16 P175B013 T01 15 Microsoft Visual C++ 2012 Express Edition : http://www.microsoft.com/en- us/download/default.aspx Tool

17 P175B013 T01 16 Visual C++ tool

18 P175B013 T01 17 #include // the library facilities needed using namespace std; // name space int main()// main() is where every C++ program starts { cout << "Hello, world!\n"; // output the 13 characters Hello, world! // followed by a new line return 0;// return a value indicating success } // note the semicolons; they terminate statements // curly brackets { … } group statements into a block // main( ) is a function that takes no arguments ( ) // and returns an int (integer value) to indicate success A first program

19 P175B013 T01 18 It’s almost all “boiler plate” Only cout << "Hello, world!\n" directly does anything That’s normal Most of our code, and most of the systems we use simply exist to make some other code elegant and/or efficient “Boiler plate,” that is, notation, libraries, and other support is what makes our code simple, comprehensible, trustworthy, and efficient. We should not just “get things done”; we should take great care that things are done elegantly, correctly, and in ways that ease the creation of more/other software: Style Matters! Hello world

20 P175B013 T01 19 Compilation and linking C++ source code C++ compiler Object code Linker Library Object code Executable program

21 P175B013 T01 20 Linker works if there no errors Information on warnings and errors is shown in the lower window below the program text Read the information and correct the program Syntax errors Debugging of the program

22 P175B013 T01 21 You have executable program You have to test it: To enter the data in order to validate the program The test has to be designed for every branch of the program Testing of the program

23 P175B013 T01 22 Conventional definition A plan for solving a problem on a computer Specifying the order of a program execution But modern programs often involve millions of lines of code And manipulation of data is central The definition we’ll use Specifying the structure and behavior of a program, and testing that the program performs its task correctly Never forget to check that “it” works Software == one or more programs Definition of the programming

24 P175B013 T01 23 Programming is fundamentally simple Just state what the machine is to do So why is programming hard? We want “the machine” to do complex things And computers are nitpicking, unforgiving, dumb beasts The world is more complex than we’d like to believe So we don’t always know the implications of what we want “Programming is understanding” When you can program a task, you understand it When you program, you spend significant time trying to understand the task you want to automate Programming is part practical, part theory If you are just practical, you produce non-scalable unmaintainable hacks If you are just theoretical, you produce toys Programming activity

25 P175B013 T01 24 Summary  Course structure  Course contents  System of the assessments  Program development environment  Definition of the programming  Questions? 24

26 Concept of object-oriented programming

27 Topics 1.Representation of real world. 2.Features of object-oriented programming. 3.The beginning of the example. P175B013 T01 26

28 P175B013 T01 27 Real world and abstraction Objects in the real world: – Men, cars, goods Characteristics of the objects in the real world: – What they have (features) – What they can (behavior) Objects in the computer are abstractions

29 P175B013 T01 28 Abstraction and computer Principle of the abstraction: – To model features and behavior related to the particular task only Features in the computer are data Behavior is described by the functions or methods

30 P175B013 T01 29 Grouping of objects Some of the real world objects have a lot in common: – Object group students – Object group professors – Object group cars Therefore, the features and behavior of the group can be described once and then used a lot of times for every particular object

31 Class and object Class describes group of the objects. Class is a type. Object is the representative of the class. Object is a variable – Real implementation of the class Objects have different data but their behavior is the same. P175B013 T01 30

32 Description General form (class): class ClassName { Features Behavior }; General form (objects): ClassName object1, object2,... ; P175B013 T01 31

33 P175B013 T01 32 Description of the class Class name has to be unique identifier in the name space. Description of the class is stored in the file.h. Implementation of the class is stored in the file.cpp. The class name is valid in all the file.cpp that the following: #include "filename.h"

34 OOP principles

35 P175B013 T01 34 History Became popular in the last decade of the XX century Languages: – Smalltalk, C++, Java, C#, C objective Terminology: – Class, object, encapsulation, inheritance, polymorphism, method.

36 P175B013 T01 35 The basic idea Data and functions, which operate on these data, are bundled into the same unit:  The data of the class are not directly accessible outside of the class  If there is need to change the data, the interface methods of the class has to be used This principle is called encapsulation.

37 Other principles Inheritance: Hierarchy of classes Abstract classes at the top More specialized at the bottom of the tree. Polymorphism: Ability of the object to behave depending on the context

38 P175B013 T01 37 Object-oriented program

39 Stages of the programming Analysis of the task, Choice of the solution, Design of the algorithm Coding, Debugging, Testing, Execution P175B013 T01 38

40 Programming language Programming language – tool to write the code that is understood be the computer. C language was created in 1972 as the part of the UNIX Its successor is C++

41 C++ C++ was created by Bjarne Stroustrup in the years between 1981 and 1986. The standards are created regularly The last standard was accepted in 2011.

42 Program development tool

43 Tool Visual Studio The development starts from the creation of the project Next, you added an item to the project –.cpp file – class P175B013 T01 42

44 Student’s version Microsoft Visual C++ 2012 Express Edition can be loaded freely from the Microsoft page. You need registration with this page only

45 Beginning of the example

46 Problem The following information is available about goods: name, code, price of single unit. Two customers bought several items of goods. You have to calculate total sum that the goods cost P175B013 T01 45 Eggs EGG0001 3,27 John 1 Emily 3 Eggs EGG0001 3,27 John 1 Emily 3

47 Basic data types Data have to be declared: int – integer numbers; double – real numbers; char – single characters; string – line of text. There are more types available P175B013 T01 46

48 Declaration int count; doublesum, price; charcharact; stringline, name; P175B013 T01 47

49 Example: class of single item class Item { string name; string code; double price; }; P175B013 T01 48

50 Example: class of buyer class Buyer { string name; int count; }; P175B013 T01 49

51 Declaration of objects Item item1; Buyer buyer1, buyer2; P175B013 T01 50

52 Problems We can not proceed because: P175B013 T01 51

53 Summary 1.Introduction to programming 2.Object-oriented programming (OOP) 3.C++ 4.Tool – VS Studio C++ P175B013 T01 52

54 Questions?


Download ppt "T01. Outline and concepts Promising future comes from the dedication."

Similar presentations


Ads by Google