Professional Documents
Culture Documents
06 Thuc Thi
06 Thuc Thi
1 Thực thi
4 Tái sử dụng
3
Dương Hữu Thành
4
Dương Hữu Thành
5
Dương Hữu Thành
6
Dương Hữu Thành
8
Dương Hữu Thành
Ảnh: Wikipedia
9
Dương Hữu Thành
10
Dương Hữu Thành
10
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
Phong cách lập trình
11
Dương Hữu Thành
11
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
12
Dương Hữu Thành
12
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
Phong cách lập trình
13
Dương Hữu Thành
13
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
int m, n;
void nhap(int &m, int &n)
{
void nhap()
cin >> m;
{
cin >> n;
cin >> m;
}
cin >> n;
}
int main()
Bad Good
{
int main()
int m, n;
{
nhap(m, n);
nhap();
return 0;
return 0;
}
}
14
Dương Hữu Thành
14
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
Phong cách lập trình
15
Dương Hữu Thành
15
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
16
Dương Hữu Thành
16
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
Phong cách lập trình
• Mỗi câu lệnh nên được đặt riêng trên một dòng
giúp mã nguồn dễ đọc, dễ theo dõi, gỡ lỗi
(debug) thuận tiện, hiệu quả hơn.
// bad
if (a % 2 == 0) cout << "Even";
else cout << "Odd";
// good
if (a % 2 == 0)
cout << "Even";
else
cout << "Odd";
17
Dương Hữu Thành
17
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
18
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
Phong cách lập trình
• Các khối lệnh con của các câu lệnh nào đó nên
dùng tab thụt vào và nên có một dòng trắng
giữa các khối lệnh có mục đích khác nhau.
if (a == b) if (a == b)
{ {
a += c; a += c;
c--; c--;
Bad } } Good
else else
{ {
a -= c; a -= c;
c++; c++;
} } 19
Dương Hữu Thành
19
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
char ten[100];
char ten[100]; float diem;
float diem;
cout << "Ten:"; cout << "Ten:";
cin.getline(ten, 100); cin.getline(ten, 100);
cout << "Diem:";
cin >> diem; cout << "Diem:";
cin >> diem;
Bad Good
20
Dương Hữu Thành
20
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
Phong cách lập trình
a ++; // bad
a++; // good
a = - b; // bad
a = -b; // good
21
Dương Hữu Thành
21
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
22
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
Phong cách lập trình
if(a == b) // bad
if (a == b) // good
strcmp (a, b); // bad
strcmp(a, b); // good
23
Dương Hữu Thành
23
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
24
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
Tái sử dụng
25
Dương Hữu Thành
25
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
Tái sử dụng
26
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
Tái sử dụng
27
Dương Hữu Thành
27
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
Tái sử dụng
28
Dương Hữu Thành
28
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
Tái sử dụng
29
Dương Hữu Thành
29
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
30
Dương Hữu Thành
30
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
Phát triển mã nguồn mở
31
Dương Hữu Thành
31
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
32
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
Q&A
33
33
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com