1. Trang chủ
  2. » Tất cả

Chapter 2 - Xay dung ung dung da tang

26 3 0

Đ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

Thông tin cơ bản

Định dạng
Số trang 26
Dung lượng 236,48 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

In the C# language the interface is a definition of a role a group of abstract actions Interfaces are also known as contracts or specifications of behavior An object can have multiple ro

Trang 1

Chương 2

XÂY DỰNG ỨNG ĐA TẦNG

Trang 4

4

Trang 6

Abstraction

Trang 7

In the C# language the interface is a definition

of a role (a group of abstract actions)

Interfaces are also known as contracts or

specifications of behavior

An object can have multiple roles (or

implement multiple interfaces/contracts) and its users can utilize it from different points of

view

Abstraction

Trang 8

Abstraction

Trang 11

11

Trang 13

Polymorphism is often referred to as the third pillar

of OOP, after encapsulation and inheritance

Polymorphism is a Greek word that means shaped" and it has two distinct aspects:

"many-At run time, objects of a derived class may be treated as objects of a base class in places

such as method parameters and collections or array

Base classes may define and implement virtual

methods, and derived classes can override

them

Trang 14

Polymorphism

Trang 15

Polymorphism

Trang 16

Polymorphism

Trang 17

Polymorphism

Trang 18

Polymorphism

Trang 19

Kết quả thực thi

Polymorphism

Trang 21

Class in C#

Constructor

Properties Attributes

Methods

Trang 22

Garbage Collection

Operator new allocates memory

When objects are no longer referenced, the CLR (Common Language Runtime) performs garbage collection

Garbage collection helps avoid memory leaks

(running out of memory because unused memory has not been reclaimed)

Allocation and deallocation of other resources

(database connections, file access, etc.) must be explicitly handled by programmers

Trang 23

Garbage Collection

Use finalizer in conjunction with the garbage

collector to release resources and memory

Before garbage collector reclaims an object’s

memory, it calls the object’s finalizer

Each class has only one finalizer (also called

Trang 24

// Cleanup statements

} finally {

} }

Trang 25

Garbage Collection

Trang 26

Mô hình 3 tầng

Ngày đăng: 19/09/2016, 14:12