推荐:《The Practice Of Programming》

方工 2002-12-01 06:06:15
Title The Practice Of Programming
Authors Brian W. Kernighan and Rob Pike

Excerpts from "The Practice Of Programming"
(From the Preface)
Have you ever...

wasted a lot of time coding the wrong algorithm?
used a data structure that was much too complicated?
tested a program but missed an obvious problem?
spent a day looking for a bug you should have found in five minutes?
needed to make a program run three times faster and use less memory?
struggled to move a program from a workstation to a PC or vice versa?
tried to make a modest change in someone else's program?
rewritten a program because you couldn't understand it?
Was it fun?

These things happen to programmers all the time. But dealing with such problems is often harder than it should be because topics like testing, debugging, portability, performance, design alternatives, and style --the practice of programming-- are not usually the focus of computer science or programming courses. Most programmers learn them haphazardly as their experience grows, and a few never learn them at all.



...全文
111 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
kenryHuang 2003-01-01
  • 打赏
  • 举报
回复
这本书是我最喜欢的一本程序设计书。
借用《人月神话》上的一句话,这本书就是我买的计算机书籍中
的“神品”
wangxj0600 2002-12-31
  • 打赏
  • 举报
回复
up
vata 2002-12-07
  • 打赏
  • 举报
回复
呵呵.
方工 2002-12-01
  • 打赏
  • 举报
回复
Appendix: Collected Rules
Each truth that I discovered became a rule that served me afterwards in the discovery of others.

René Descartes, Le Discours de la Méthode

Several chapters contain rules or guidelines that summarize a discussion. The rules are collected here for easy reference. Bear in mind that each was presented in a context that explains its purpose and applicability.

Style
Use descriptive names for globals, short names for locals.

Be consistent.

Use active names for functions.

Be accurate.

Indent to show structure.

Use the natural form for expressions.

Parenthesize to resolve ambiguity.

Break up complex expressions.

Be clear.

Be careful with side effects.

Use a consistent indentation and brace style.

Use idioms for consistency.

Use else-ifs for multi-way decisions.

Avoid function macros.

Parenthesize the macro body and arguments.

Give names to magic numbers.

Define numbers as constants, not macros.

Use character constants, not integers.

Use the language to calculate the size of an object.

Don't belabor the obvious.

Comment functions and global data.

Don't comment bad code, rewrite it.

Don't contradict the code.

Clarify, don't confuse.

Interfaces
Hide implementation details.

Choose a small orthogonal set of primitives.

Don't reach behind the user's back.

Do the same thing the same way everywhere.

Free a resource in the same layer that allocated it.

Detect errors at a low level, handle them at a high level.

Use exceptions only for exceptional situations.

Debugging
Look for familiar patterns.

Examine the most recent change.

Don't make the same mistake twice.

Debug it now, not later.

Get a stack trace.

Read before typing.

Explain your code to someone else.

Make the bug reproducible.

Divide and conquer.

Study the numerology of failures.

Display output to localize your search.

Write self-checking code.

Write a log file.

Draw a picture.

Use tools.

Keep records.

Testing
Test code at its boundaries.

Test pre- and post-conditions.

Use assertions.

Program defensively.

Check error returns.

Test incrementally.

Test simple parts first.

Know what output to expect.

Verify conservation properties.

Compare independent implementations.

Measure test coverage.

Automate regression testing.

Create self-contained tests.

Performance
Automate timing measurements.

Use a profiler.

Concentrate on the hot spots.

Draw a picture.

Use a better algorithm or data structure.

Enable compiler optimizations.

Tune the code.

Don't optimize what doesn't matter.

Collect common subexpressions.

Replace expensive operations by cheap ones.

Unroll or eliminate loops.

Cache frequently-used values.

Write a special-purpose allocator.

Buffer input and output.

Handle special cases separately.

Precompute results.

Use approximate values.

Rewrite in a lower-level language.

Save space by using the smallest possible data type.

Don't store what you can easily recompute.

Portability
Stick to the standard.

Program in the mainstream.

Beware of language trouble spots.

Try several compilers.

Use standard libraries.

Use only features available everywhere.

Avoid conditional compilation.

Localize system dependencies in separate files.

Hide system dependencies behind interfaces.

Use text for data exchange.

Use a fixed byte order for data exchange.

Change the name if you change the specification.

Maintain compatibility with existing programs and data.

Don't assume ASCII.

Don't assume English.

From The Practice of Programming by Brian W. Kernighan and Rob Pike; Addison-Wesley, 1999; ISBN 0-201-61586-X
方工 2002-12-01
  • 打赏
  • 举报
回复
Table of Contents
Preface

Chapter 1: Style
1.1 Names
1.2 Expressions and Statements
1.3 Consistency and Idioms
1.4 Function Macros
1.5 Magic Numbers
1.6 Comments
1.7 Why Bother?
Chapter 2: Algorithms and Data Structures
2.1 Searching
2.2 Sorting
2.3 Libraries
2.4 A Java Quicksort
2.5 O-Notation
2.6 Growing Arrays
2.7 Lists
2.8 Trees
2.9 Hash Tables
2.10 Summary
Chapter 3: Design and Implementation
3.1 The Markov Chain Algorithm
3.2 Data Structure Alternatives
3.3 Building the Data Structure in C
3.4 Generating Output
3.5 Java
3.6 C++
3.7 Awk and Perl
3.8 Performance
3.9 Lessons

Chapter 4: Interfaces
4.1 Comma-Separated Values
4.2 A Prototype Library
4.3 A Library for Others
4.4 A C++ Implementation
4.5 Interface Principles
4.6 Resource Management
4.7 Abort, Retry, Fail?
4.8 User Interfaces

Chapter 5: Debugging
5.1 Debuggers
5.2 Good Clues, Easy Bugs
5.3 No Clues, Hard Bugs
5.4 Last Resorts
5.5 Non-reproducible Bugs
5.6 Debugging Tools
5.7 Other People's Bugs
5.8 Summary

Chapter 6: Testing
6.1 Test as You Write the Code
6.2 Systematic Testing
6.3 Test Automation
6.4 Test Scaffolds
6.5 Stress Tests
6.6 Tips for Testing
6.7 Who Does the Testing?
6.8 Testing the Markov Program
6.9 Summary

Chapter 7: Performance
7.1 A Bottleneck
7.2 Timing and Profiling
7.3 Strategies for Speed
7.4 Tuning the Code
7.5 Space Efficiency
7.6 Estimation
7.7 Summary

Chapter 8: Portability
8.1 Language
8.2 Headers and Libraries
8.3 Program Organization
8.4 Isolation
8.5 Data Exchange
8.6 Byte Order
8.7 Portability and Upgrade
8.8 Internationalization
8.9 Summary

Chapter 9: Notation
9.1 Formatting Data
9.2 Regular Expressions
9.3 Programmable Tools
9.4 Interpreters, Compilers, and Virtual Machines
9.5 Programs that Write Programs
9.6 Using Macros to Generate Code
9.7 Compiling on the Fly

Epilogue
Appendix: Collected Rules
Index
Bjarne Stroustrup, "Programming: Principles and Practice Using C++"Addison-Wesley Professional | 2008 | ISBN: 0321543726 | 1272 pages | PDF | 129 MBAn Introduction to Programming by the Inventor of C++Preparation for Programming in the Real WorldThe book assumes that you aim eventually to write non-trivial programs, whether for work in software development or in some other technical field.Focus on Fundamental Concepts and TechniquesThe book explains fundamental concepts and techniques in greater depth than traditional introductions. This approach will give you a solid foundation for writing useful, correct, maintainable, and efficient code.Programming with Today’s C++The book is an introduction to programming in general, including object-oriented programming and generic programming. It is also a solid introduction to the C++ programming language, one of the most widely used languages for real-world software. The book presents modern C++ programming techniques from the start, introducing the C++ standard library to simplify programming tasks.For Beginners–And Anyone Who Wants to Learn Something NewThe book is primarily designed for people who have never programmed before, and it has been tested with more than 1,000 first-year university students. However, practitioners and advanced students will gain new insight and guidance by seeing how a recognized master approaches the elements of his art.Provides a Broad ViewThe first half of the book covers a wide range of essential concepts, design and programming techniques, language features, and libraries. Those will enable you to write programs involving input, output, computation, and simple graphics. The second half explores more specialized topics, such as text processing and testing, and provides abundant reference material. Source code and support supplements are available from the author’s website.Part 1depositfiles.comuploading.commirrorPart 2depositfiles.comuploading.commirrorNot all books on AvaxHome appear on the
Title: Automate the Boring Stuff with Python: Practical Programming for Total Beginners Author: Albert Sweigart Length: 504 pages Edition: 1 Language: English Publisher: No Starch Press Publication Date: 2015-05-01 ISBN-10: 1593275994 ISBN-13: 9781593275990 If you've ever spent hours renaming files or updating hundreds of spreadsheet cells, you know how tedious tasks like these can be. But what if you could have your computer do them for you? In Automate the Boring Stuff with Python, you'll learn how to use Python to write programs that do in minutes what would take you hours to do by hand—no prior programming experience required. Once you've mastered the basics of programming, you'll create Python programs that effortlessly perform useful and impressive feats of automation to: Search for text in a file or across multiple files Create, update, move, and rename files and folders Search the Web and download online content Update and format data in Excel spreadsheets of any size Split, merge, watermark, and encrypt PDFs Send reminder emails and text notifications Fill out online forms Step-by-step instructions walk you through each program, and practice projects at the end of each chapter challenge you to improve those programs and use your newfound skills to automate similar tasks. Don't spend your time doing work a well-trained monkey could do. Even if you've never written a line of code, you can make your computer do the grunt work. Learn how in Automate the Boring Stuff with Python. Table of Contents Part I. Python Programming Basics Chapter 1. Python Basics Chapter 2. Flow Control Chapter 3. Functions Chapter 4. Lists Chapter 5. Dictionaries and Structuring Data Chapter 6. Manipulating Strings Part II. Automating Tasks Chapter 7. Pattern Matching with Regular Expressions Chapter 8. Reading and Writing Files Chapter 9. Organizing Files Chapter 10. Debugging Chapter 11. Web Scraping Chapter 12. Working with Excel Spreadsheets Chapter 13. Working with PDF and word Documents Chapter 14. Working with CSV Files and JSON Data Chapter 15. Keeping Time, Scheduling Tasks, and Launching Programs Chapter 16. Sending Email and Text Messages Chapter 17. Manipulating Images Chapter 18. Controlling the Keyboard and Mouse with GUI Automation Appendix A. Installing Third-Party Modules Appendix B. Running Programs Appendix C. Answers to the Practice Questions
Title: Machine Learning in Python: Essential Techniques for Predictive Analysis Author: Michael Bowles Length: 360 pages Edition: 1 Language: English Publisher: Wiley Publication Date: 2015-04-20 ISBN-10: 1118961749 ISBN-13: 9781118961742 Learn a simpler and more effective way to analyze data and predict outcomes with Python Machine Learning in Python shows you how to successfully analyze data using only two core machine learning algorithms, and how to apply them using Python. By focusing on two algorithm families that effectively predict outcomes, this book is able to provide full descriptions of the mechanisms at work, and the examples that illustrate the machinery with specific, hackable code. The algorithms are explained in simple terms with no complex math and applied using Python, with guidance on algorithm selection, data preparation, and using the trained models in practice. You will learn a core set of Python programming techniques, various methods of building predictive models, and how to measure the performance of each model to ensure that the right one is used. The chapters on penalized linear regression and ensemble methods dive deep into each of the algorithms, and you can use the sample code in the book to develop your own data analysis solutions. Machine learning algorithms are at the core of data analytics and visualization. In the past, these methods required a deep background in math and statistics, often in combination with the specialized R programming language. This book demonstrates how machine learning can be implemented using the more widely used and accessible Python programming language. * Predict outcomes using linear and ensemble algorithm families * Build predictive models that solve a range of simple and complex problems * Apply core machine learning algorithms using Python * Use sample code directly to build custom solutions Machine learning doesn't have to be complex and highly specialized. Python makes this technology more acces

662

社区成员

发帖
与我相关
我的任务
社区描述
提出问题
其他 技术论坛(原bbs)
社区管理员
  • community_281
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧