Common Programming Principles

From LabVIEW Wiki
Jump to: navigation, search

A simple internet search for Programming Principles will return many articles. Below is a list of Common Programming Principles that appear on multiple lists.

Keep It Simple, Stupid (KISS)

Keep the code simple. Simple code is easier to read, extend, and maintain. If the code is simple, other developers, or "future you", will be able to understand the code logic and be able to continue with the code.

  1. Attempt to split complex code into smaller components by using SubVIs
  2. Remove unnecessary code
  3. Don't try to write clever code

Write DRY Code

The Don't Repeat Yourself (DRY) principle means to avoid duplication of code. This also pertains to data or logic.

  1. Use SubVIs for logic used in many places
  2. Don't duplicate/copy data storage. Inevitably, one of the copies will be out-of-date or wrong.

Open/Closed

Make the code Open to extension but Closed to modification. Organize the code in such a way that it encourages extension but prevents direct modification. This separates core behavior from modified behavior so that if the core behavior is changed, it won't break the extended, modified behavior.

You Aren't Going to Need It (YAGNI)

Document Your Code

Refactor

Low Coupling, High Cohesion