The DATASTRUCTRUE homework --- 随笔啦

The principles ofprogram design


Data Structuresaim to describe the programming methods and tools. As for a program, the biggerit is, the more difficult to solve the large problems.

Therefore, thereshould be a consistent、unified and logical approach, which shouldfollow the principles of program design.

When we started aprogram, first of all, we need think of the major problem we will meet, andtrying to make it more clear; And then find ways that can handle the problemefficiently as many as you can, in which you need to choose the best methodcarefully. Usually, we will separate the bigger problems into several smallerissues, which is much more convenient to program design for the programmers.

For the programdesign, many programmers believe the principle: “First make your program work,then make it pretty.” However, I give you my opinion that the above principlemay be effective for small programs, but not for the large ones. Each part of alarge program is supposed to be well-organized , clearly written, andthoroughly understood.

Even with verylarge projects, difficulties usually arise not from the inability to find asolution but, rather, from the fact that there can be so many different methodsand algorithms that might work that it can be hard to decide which is best,which may lead to programming difficulties, or which may be hopelesslyinefficient. The greatest room for variability in algorithm design is generallyin the way in which the data of the program are stored:

A. How they arearranged in relation to each other.

B. Which data arekept in memory.

C. Which arecalculated when needed.

D. Which are keptin files, and how the files are arranged.

When there areseveral different methods to organize data and device algorithms, it’s vital todevelop criteria to recommend a choice.

Testing andverification:  program correctness:

  a. Reduce the number of errors, making iteasier to spot those that remain.

  b. Enable us to verify in advance that ouralgorithm are correct.

  c. Provide us with ways to test our programsso that we can be reasonably confident that they will not misbehave.

Maintenance: Please see it thata large project be written to make it as easy as to understand and modify aspossible.

Using C++ toprogramming: We can learn from the features of C++, such as :

a.    Dataabstraction.

b.    Objected-orienteddesign.

c.     Thetop-down approach.

d.    Codereuse.

e.     C++improves on several of the inconvenient and dangerous aspects of C.

f.      C++maintains the efficiency that is the hallmark of the C language.

By the way, we getthose principle:

a.               Includeprecise preconditions and post conditions with every program, function, andmethod that you write.

b.               Alwaysname your classes, variables and functions with the greatest care, and explainthem thoroughly.

c.                Keepyour documentation concise but descriptive.

d.               Thereading time for programming is much more than the writing time.

e.                Don’tlose sight of the forest for its trees.

f.                 Useclasses to model the fundamental concepts of the program.

g.               Eachfunction should do only one task, but do it well.

h.               Eachclass or function should hide something.

i.                 Keepyour connections simple. Avoid global variables whenever possible.

j.                 If youmust use global variables as input, document them thoroughly.

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值