How To Make Mistakes in Python

How To Make Mistakes in Python

I stumbled upon this book recently. It was quite good. I highly recommend everyone (yes even LabVIEW Developers) read it. It is very insightful. It's also free and very short at 76 pages and it reads fast. There really is no excuse.

I very much like the title. I think a little self-deprecating humor is good. I also like the honesty in it. It's ok to cringe at your previous code. In fact, it is a good thing. It means you've grown and learned things. The author doesn't just talk about theoretical mistakes. He points out his own past mistakes using real-world examples. What I like about this book is that I don't have to go through all the pain of learning some of these lessons, I can learn from the author's experience.

2 Types of Mistakes

The mistakes the author talks about fall into 2 broad categories:

  • Readability and Maintainability - These are mistakes that are technically correct in that yes the code does provide the correct result. However, making these types of mistakes will lead to difficulty reading and understanding the code later. This includes things like:
    - Cramming too much onto one line
    - Overly complicated lamda functions, comprehensions, and generators
    - Too many layers of nesting or abstraction
    - Poor Error handling and logging
  • Bugs and Surprising Behavior - These are mistakes that actually cause your code to behave in unexpected ways. This isn't a matter of opinion or style. These are true bugs. This includes things like:
    - Not understanding mutability
    - Name shadowing
    - Dependency mismanagement

How To Make Mistakes in LabVIEW

A lot of the mistakes mentioned in this book are generic programming mistakes. Many of them have analogs in LabVIEW. For example, name-shadowing is very similar to cross-linking. Not understanding mutability leads to similar problems in a similar way to not understanding dataflow.

Here are some of the more common areas where I see LabVIEW Developers Making mistakes.

  • Managing Your Environment and Dependencies
  • Understanding Dataflow, References, lifetimes, and race conditions
  • Circular Dependencies
  • Concurrency Issues
  • Coupling and Cohesion