What Is Good Code?

AMEX:GLD   SPDR Gold Trust
Programmers are artisans—not scientists. Our code must work, yet good code is not only tested and functional; it is a pleasure to read. Good code is that which others can learn from and enjoy the most. It is beautiful. It oozes the care that went into each line, leaving only those with unassailable purpose. Good code is whole; lines cannot be removed without compromising one of any good program's essential qualities: functionality, readability, elegance.

Good code is as often ingenious as it appears to be obvious. Its elegance masks the programmer's labor, like a ballerina twirling on stage. Good code frequently makes comments unnecessary, yet they conveniently appear in complex passages to assist the reader. Good code reflects a programmer's agility in cycling between the macro and micro views of his code; better programmers are both astronomers and particle physicists. They are also artists.

Good code is equally usable by other coders and by users of the program. It is always the work of an optimist because it represents an investment for the future, a proud bet the coder's effort is worth it because his code will last. If it does, it will shine as good code does when it must be revisited by its author or someone else.

Like wine, good code sits in silence during its making. Aging code allows us to shape missing elements and recognize superfluous bits. Code reveals the intimate nature of its maker. It brings to light an author's thought processes and how he expresses them. Only good humans can write good code, people who care for their work, and for those who will use its result.

This is the code we used to create this chart:
//@author=LucF, for PineCoders
study("Good Code", "", true, scale = scale.none, max_labels_count = 500)

int i_charsPerLine = input(300, step = 50)
int i_lines        = input(160, step = 50, maxval = 499)

var string[] letters = array.from("G", "o", "o", "d", "C", "o", "d", "e")
var int lettersQty = array.size(letters)

// Create i_lines strings of i_charsPerLine randomly selected characters from our array.
if barstate.islast
    // Cover the chart with random pattern of characters.
    for _i = 1 to i_lines
        string _textLine = ""
        for _j = 1 to i_charsPerLine
            _textLine += array.get(letters, int(random(0, lettersQty - 1)))[100], _i, _textLine, style = label.style_none, size = size.normal)
    // Overprint the larger text in the middle a few times to gain density.[130], i_lines / 2, "Good Code", style = label.style_none, size = size.huge, textcolor =[130], i_lines / 2, "Good Code", style = label.style_none, size = size.huge, textcolor =[130], i_lines / 2, "Good Code", style = label.style_none, size = size.huge, textcolor =

Tools and ideas for all Pine coders:
Our Pine FAQ & Code:
Pine news broadcasts: or

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.