review of c++ elements

review of c++ elements
a class collects data and the methods used to access or change the data
such a collection of data(data members) and methods(methods or member functions) is called an object belonging to the given class
information hiding:by relying on its specification,a client can use a method without needing to know how the data are actually stored or how the methods are actually programmed.

Public:data members and methods available to a client are called public
Private:can be used in the implementation of the class,but are not available to a client

Convention(约定俗成)methods of a class are public ; funcitons in a class are private

Utility package(多用途工具包)util包:contains various declarations and functions.even these are not related to each other,we put them in a class

Clients:user programs with access to a particular class,can declare and manipulate(操纵) objects of that class.e.g. declare a Life object:Life configuration.

Members selection operator(成员访问运算符 包括. 和 ->)
Apply methods to work with configuration:configuration.print()

Preconditons state what is required before;postconditons state what has happened when the method ,function,or program has finished

Use classes to model the fundamental concepts of the program
Each function should do only one task,but do it well
Each class of function should hide something

Input parameters—passed by value or by reference(const)
Output parameters—passed by reference(suggest)

Local variables-defined in the funcction and exist only while the function is being executed
Global variables—dangerous,cause side effect

Stubs(占位程序)
To compile each function and class separately
To compile the main program correctly,there must be something in the place of each function that is used,so put in short,dummy functions.
e.g.
void instruction(){}
bool user_says_yes() {return false;}

drivers:a short auxiliary whose purpose is to provide the necessory input for the fuction,and evaluate the result:so that each function can be isolated and studied by itself

black-box method:effictive(most subtle error occur in the interface between functions
glass-box method:trace all the paths through the program,for a single small method
ticking-box method:just hope(?!

Program maintenance程序维护
First step is to begin the continuing process of review,analysis,and evaluation.
。Problem specification
。program correctness
。user interface
。modularity and struct
。documentation
。efficiency
Program revision and redevelopment

Review the logic
Optimize a program after it works,(it is correct
能跑就不优化
Keep functions short
Be sure your algorithm is correct
Verify the intricate parts of algorithm

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值