The principles of program design

 

Data Structures aim to describe the programming methods and tools. As for a program, the bigger it is, the more difficult to solve the large problems.

Therefore, there should be a consistentunified and logical approach, which should follow the principles of program design.

When we started a program, first of all, we need think of the major problem we will meet, and trying to make it more clear; And then find ways that can handle the problem efficiently as many as you can, in which you need to choose the best method carefully. Usually, we will separate the bigger problems into several smaller issues, which is much more convenient to program design for the programmers.

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

Even with very large projects, difficulties usually arise not from the inability to find a solution but, rather, from the fact that there can be so many different methods and algorithms that might work that it can be hard to decide which is best, which may lead to programming difficulties, or which may be hopelessly inefficient. The greatest room for variability in algorithm design is generally in the way in which the data of the program are stored:

A. How they are arranged in relation to each other.

B. Which data are kept in memory.

C. Which are calculated when needed.

D. Which are kept in files, and how the files are arranged.

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

Testing and verification:  program correctness:

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

  b. Enable us to verify in advance that our algorithm are correct.

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

Maintenance: Please see it that a large project be written to make it as easy as to understand and modify as possible.

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

a.     Data abstraction.

b.     Objected-oriented design.

c.      The top-down approach.

d.     Code reuse.

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 get those principle:

a.                Include precise preconditions and post conditions with every program, function, and method that you write.

b.                Always name your classes, variables and functions with the greatest care, and explain them thoroughly.

c.                 Keep your documentation concise but descriptive.

d.                The reading time for programming is much more than the writing time.

e.                 Don’t lose sight of the forest for its trees.

f.                  Use classes to model the fundamental concepts of the program.

g.                Each function should do only one task, but do it well.

h.                Each class or function should hide something.

i.                  Keep your connections simple. Avoid global variables whenever possible.

j.                  If you must 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、付费专栏及课程。

余额充值