Kris's blog

Posted Di 09 Juni 2020

Did you experiment with the color themes?

My color theme for every programming language has golden(yellow) color for every comment. I have set the same color for all strings also.

I did that, because the best method to code is the literate programming. There is only one problem with it. It takes time and it's not flexible. To fix that I came with two solutions.

First, I made comments stand out more than the code. Till now, grayish comments, became the dominant thing in the source code. The description of what the code does is more important than the code.

Some people say that code is the best documentation. Those people are mental. Just don't listen to them. No code can make up for a bunch of good examples, some diagrams(they make everything so simple), maybe a tutorial and some user guides.

Example

With the comments standing out, like on the picture above, things become easier to understand. It's important that it's easy for me. We use subsets of english language as programming languages, because source code has to be for humans first, for computers second.

That brings us to the second reason. The clean code, SOLID, DDD, TDD, BDD, YAGNI, DRY, KISS and whatevere there is, boils down to writing as simple, dumb, expressive, and as close to english language as possible. Simple descriptions and stories for four year olds. Also, this way I can remove those nasty yellow comments. Or not, like in this place cause creating functions would just add useless code. Comments will do.

Example 2

This is also a good way to work with ugly code. Usually, ugly legacy code looks more uglier than that on the image above. Usually there are commented out "print"s, some old pieces of code, but also very usefull descriptions of what happens below the comment. You can take those comments and change them into functions names. This way you get a functional portion of the code wrapped around a function, that is quite descriptive. You can see example below.

Example 3

This trick is quite awesome. And, you get tests close to BDD tests. (Devs have to test!!). All I did was changing the colors.

Category: coding themes tricks