From the course: Troubleshooting and Debugging Bash

Style guides - Bash Tutorial

From the course: Troubleshooting and Debugging Bash

Start my 1-month free trial

Style guides

- [Instructor] Style guides are common in the publishing industry but you might be surprised to find out that style guides exist for scripting and they're a great idea. People have already given a lot of thought to the question of how a script should be written and formatted, and in many cases, there are great guides on what styles you should follow. Have you ever been in a shared Google Document for example and found that you're writing with one set of goals in mind and one writing style, and another person is trying to accomplish something different with the same document and writing with a completely different style? It simply doesn't work. Both people end up pushing and pulling each other in different directions resulting in a bad document that does not accomplish the intended goal and it takes much too long to collaborate. If everyone in that shared Google Doc had the same rules to write with, and everyone agreed to work together in locked step, you could accomplish a lot more. That's the value that style guide adoption can bring to you and your team. There are a couple of great style guides to consider like this one from Google. If you write in an environment where lots of other people collaborate with you on projects, say for example on a large enterprise organization, where there are many systems administrators who access and write scripts in a shared repository, it's going to be important for you to follow a style guide like this one so that when you write your scripts in the same way, you can interact efficiently without having to rewrite or reformat each other's code. Working within an adopted style guide in an organization allows everyone involved to write to one consistent style. This avoids lots of problems including how things are commented, how functions are called out, how math is dealt with, and other elements that might be written in different ways but need to be consistent. Style guides are available from several solid resources including the ones that I have here, this one from Google, and this one over here up at GitHub. It is a relatively small task to distribute the style guide to the people on your team and for everyone on the team to use the style guide so they're coding in a coordinated and efficient manner. Some products also offer their own style guides. This is the style guide embedded within the Atom code editor. A style guide offers your team the opportunity to work together, efficiently, and with fewer errors created by a lack of coordination resulting in better code and less need for troubleshooting down the road.

Contents