Send Close Add comments: (status displays here)
Got it!  This site "robinsnyder.com" uses cookies. You consent to this by clicking on "Got it!" or by continuing to use this website.  Note: This appears on each machine/browser from which this site is accessed.
CS: code improvement
by RS  admin@robinsnyder.com : 1024 x 640


1. Code improvement
If it ain't broke, don't fix itWhenever writing new code keep the logic as clear as possible. For old code, if it works, leave it alone. For new code, keep the logic as simple and clear as possible.

2. Code improvement
Programmers are usually notoriously bad at guessing which parts of the code are the primary consumers of the resources. It is all too common for a programmer to modify a piece of code expecting to see a huge time savings and then find that it makes no difference at all because the code was rarely executed. Bentley, J. (1982). Writing efficient programs. Englewood Cliffs, NJ: Prentice-Hall., p. 32.

Bentley is author of the popular series Programming Pearls and the book Writing Efficient Programs.

Information sign More: Jon Bentley

3. Code speed
Book: Delphi Component DesignProbably the biggest misuse of time any programmer can make is to invest in improving the performance of something that doesn't matter - a body of code whose execution time is already well below the end user's perception threshold (such as submillisecond text redraw) or that is dwarfed by the costs of other operations that occur in the same context. Thorpe, D. Delphi component design. Reading, MA: Addison-Wesley., p. 251.

Information sign More: Danny Thorpe

4. Anders Hejlsberg
As Anders Hejlsberg, chief architect of Delphi, is fond of saying:

If you take a program with an inefficient design and implement the whole thing in hand-coded assembler, all you'll get is a faster implementation of a low design, which is never the same as a fast program. Thorpe, D. Delphi component design. Reading, MA: Addison-Wesley., p. 250.

Anders Hejlsberg, coauthor of Turbo Pascal and chief architect of Delphi, was hired away from Borland by Microsoft a years ago and is the chief architect of C# and a chief contributor to the .NET architecture.

Information sign More: Danny Thorpe
Explain a specific example of getting it right before you make it faster and one of not getting it right before you make it faster.

5. Jackson's rules

6. Making code run fast
Programming fallacyFallacy: You should make your code run fast.
FASTHere are Jackson's rules of code improvement (to run faster or take less space).
Try to make your code clear as to correctness. If it does not have to work correctly, I can make the code as fast as you want.

7. Fast code
Book: Writing efficient programsA CS student takes courses on simple ways to make code reasonably fast. Making code fast has issues. The same remarks hold for making code take less space.

Before spending time making code fast, or taking less space, get the approval of the manager. [opportunity cost]



8. Careers
Few computer science undergraduates will ever do real computer science.

Many computer science undergraduates will do software development/engineering. The goal of software engineering is to develop software on-time, on-budget and that meets the needs of the customer.

The inherent problem in the goal of software engineering is that only two of the following three are possible. Thus, many trade-offs must be made.

9. General guideline
Here are some general guidelines. In areas such as computer and data science, there are parts that need to be made fast. There are usually libraries that have done this. Use them.

10. Repeated code
Manually created code that is repeated is almost always a potential problem.

A large part of computer science and software engineering techniques are designed to help eliminate or minimize repeated code.

In most cases, this is always a good idea (for any new code or broken code that needs improved).

11. End of page

by RS  admin@robinsnyder.com : 1024 x 640