Nhập Môn Lập Trình Hướng Đối Tượng Introduction to OOP (3 giờ)

72 439 0
Nhập Môn Lập Trình Hướng Đối Tượng Introduction to OOP (3 giờ)

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Chương 02 NHẬP MƠN LẬP TRÌNH HƯỚNG ĐỐI TƯỢNG Introduction to OOP (3 giờ) GV Thân Văn Sử Chương 01- Nhập mơn OOP Slide 1/54 Mục tiêu • Nhận biết khác biệt lập trình hướng thủ tục lập trình hướng đối tượng • Luyện tập tư lập trình hướng đối tượng • Nhận diện số ngôn ngữ OOP GV Thân Văn Sử Chương 01- Nhập mơn OOP Slide 2/54 Mục tiêu • Nắm vững số định nghĩa OOP bao gồm: – Trừu tượng hóa liệu – Lớp, đối tượng, thể – Thơng điệp gửi thơng điệp – Tính bao đóng – Tính kế thừa – Tính đa hình GV Thân Văn Sử Chương 01- Nhập môn OOP Slide 3/54 Nội dung chi tiết • Nhược điểm lập trình thủ tục • Tư hướng đối tượng • Diễn đạt hướng đối tượng • • • Ưu điểm lập trình hướng đối tượng Các khái niệm OOP Những gợi ý cần thiết lập trình OO GV Thân Văn Sử Chương 01- Nhập môn OOP Slide 4/54 2.1- Lập trình thủ tục • POP- Procedure Oriented Programming • Data structure + Algorithm = Program • Kỹ thuật POP: Program pick nouns Data structure pick verbs Operation (function) type Fun (XX x) { } Problem GV Thân Văn Sử struct XX { }; void main() { XX x; Fun(x); } Chương 01- Nhập môn OOP Slide 5/54 2.2- Nhược điểm POP • Diễn đạt “thiếu tự nhiên” Có học sinh x “Viết lý lịch cho học sinh x” “x ơi, viết lý lịch em” VietLyLich(x); x.VietLyLich(); Diễn đạt tự nhiên hơn? “x ơi, viết lý lịch em” GV Thân Văn Sử Chương 01- Nhập môn OOP Slide 6/54 Nhược điểm POP • Khó mơ tả quan hệ phức tạp giới tự nhiên Biểu diễn dạng cấu trúc “phức tạp” dễ dàng nhiều người – Quan hệ liệu biểu diễn cấu trúc lồng pointer  Tính phân lớp khó phát hiện, có khó khăn biểu diễn lẫn tính dễ hiểu • Thí dụ slide sau GV Thân Văn Sử Chương 01- Nhập môn OOP Slide 7/54 Nhược điểm POP Tự nhiên struct PERSON { }; Person is a Male Hiện thực is a Female struct MALE { PERSON Data }; struct FEMALE { PERSON Data }; GV Thân Văn Sử Chương 01- Nhập môn OOP Diễn đạt phải tường minh  không tự nhiên Slide 8/54 Nhược điểm POP • Bảo mật giới hạn truy xuất đến liệu struct STUDENT { char Name[21]; int Age; int Score; }; GV Thân Văn Sử void main() {STUDENT x = { “Hoa”, 19, 5}; x.Age=1000; Bạn nghĩ x.Score=-20; tác vụ này? } Chương 01- Nhập mơn OOP Slide 9/54 Nhược điểm POP • Cần phương pháp lập trình khác giúp giải nhược điểm • OOP có đặc điểm vượt trội so với POP hướng lập trình chủ đạo GV Thân Văn Sử Chương 01- Nhập môn OOP Slide 10/54 Question OOP stands for a- Object Online Programming b- Object Of a Program c- Object Oriented Programming c GV Thân Văn Sử Chương 01- Nhập môn OOP Slide 58/54 Question What descriptions below are not OOP format ? a- Write the record for student Phúc b- Write the record of student Phúc a c- Hello Phúc, write your record b GV Thân Văn Sử Chương 01- Nhập môn OOP Slide 59/54 Question What description below is POP format? a- DrawCircle(v); a b- v.Draw(); GV Thân Văn Sử Chương 01- Nhập môn OOP Slide 60/54 Question Identify the basic characteristics of OOP: a- Data hidding b- Inheritance c- Polymorphism d- All of the above d GV Thân Văn Sử Chương 01- Nhập môn OOP Slide 61/54 Question class is: a- Data which describes a concept b- A code segment of a program c- Template of a set of objects which have the same properties and behaviors c d- All of the above are wrong GV Thân Văn Sử Chương 01- Nhập môn OOP Slide 62/54 Question Select incorrect statements: a- class = properties + methods b- class = properties b c- class = functions that will operate on data c GV Thân Văn Sử Chương 01- Nhập môn OOP Slide 63/54 Question Indentify the correct statement a- Encapsulation: the packaging of attributes (properties) and functionality (methods or behaviors) to create an object that is essentially a “black box” b- inheritance: The transfer of the characteristics of a class in object-oriented programming to other classes derived from it c- polymorphism :The ability to redefine a routine in a derived class d d- All of the above GV Thân Văn Sử Chương 01- Nhập môn OOP Slide 64/54 Question Identify the advantages of OOP a- High level modulization b- Able to describe the complex relations in real objects c- Able to reuse code d- Easy to maintain application e- All of the above e GV Thân Văn Sử Chương 01- Nhập môn OOP Slide 65/54 Question C++ is a a- Multiple inheritance OOP language a b- Single inheritance OOP language GV Thân Văn Sử Chương 01- Nhập môn OOP Slide 66/54 Question 10 Identify the correct keywords that will be used when a class is implemented using C++: a- Class, Private, Public b- Class, private, public c- class, private, public d- CLASS, PRIVATE, PUBLIC c GV Thân Văn Sử Chương 01- Nhập môn OOP Slide 67/54 Question 11 What is the correct syntax when a method is implemented outside the class declaration block abb DataType Method (params) { } DataType ClassName::Method (params) { } GV Thân Văn Sử Chương 01- Nhập môn OOP Slide 68/54 Question 12 Study error code below: class A { int x; public: void T() { } } What line will cause an error? a- b- c- d- missing ‘;’ at the end of class e e- declaration GV Thân Văn Sử Chương 01- Nhập môn OOP Slide 69/54 Question 13 Identify the wrong statement a a- All objects of a program will be alive and dead at the same time b- The life of an object begins at the time when the code line, that defines it, is executed, and ends when the code block, that contains it, is executed completely c- Scope of an object is code block that begins at the line that the object is defined and ends at the curly closed brace of the block GV Thân Văn Sử Chương 01- Nhập môn OOP Slide 70/54 Question 14 In order to make easiness in maintaining an application a- We should store class implement and using a class code separately b- We should not store class implement and using class code separately GV Thân Văn Sử Chương 01- Nhập môn OOP Slide 71/54 THANK YOU GV Thân Văn Sử Chương 01- Nhập môn OOP Slide 72/54 ... Nhận biết khác biệt lập trình hướng thủ tục lập trình hướng đối tượng • Luyện tập tư lập trình hướng đối tượng • Nhận diện số ngôn ngữ OOP GV Thân Văn Sử Chương 01- Nhập môn OOP Slide 2/54 Mục... điểm lập trình thủ tục • Tư hướng đối tượng • Diễn đạt hướng đối tượng • • • Ưu điểm lập trình hướng đối tượng Các khái niệm OOP Những gợi ý cần thiết lập trình OO GV Thân Văn Sử Chương 01- Nhập. .. a đối tượng GV Thân Văn Sử Chương 01- Nhập môn OOP Slide 19/54 Diễn đạt hướng đối tượng • Diễn đạt tác vụ theo hướng thủ tục : TênTácVụ(ĐốiTượngDữLiệu);  Tổng(a,n); • Diễn đạt tác vụ theo hướng

Ngày đăng: 25/08/2017, 09:49

Từ khóa liên quan

Mục lục

  • Chương 02 NHẬP MÔN LẬP TRÌNH HƯỚNG ĐỐI TƯỢNG Introduction to OOP (3 giờ)

  • Mục tiêu

  • Slide 3

  • Nội dung chi tiết

  • 2.1- Lập trình thủ tục

  • 2.2- Nhược điểm của POP

  • Nhược điểm của POP...

  • Slide 8

  • Slide 9

  • Slide 10

  • 2.2- Tư duy hướng đối tượng

  • What is an object?

  • Objects…

  • How to describe a real-object?

  • How to describe a real-object? …

  • Software Object- Đối tượng phần mềm

  • Software objects

  • What is a class?

  • 2.3-Diễn đạt hướng đối tượng

  • Diễn đạt hướng đối tượng

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan