-
Notifications
You must be signed in to change notification settings - Fork 0
Goals, changes, style, indenting, sorting etc.
Set editor to 4 column tabs, fixed with font, wide screen.
-
Goals: I think good code is many things, but for me, it's easy to read, and easy to see if it's working properly.
-
Test procedures included: I have deliberately left in some 'commented out test procedures'.
Sometimes when things aren't working or understood it's helpful to quickly test the parts. Other times it's useful to have a simple, runnable example of how a function works and what it can do. Rather than delete and remove from code after development, I choose to leave test code in and comment out. -
If Then..: You might notice that I wrap "If" structures differently than you're used to.
I use what makes the most sense to me, in terms of simplicty and readability. -
DIMs: I find that in Basic keeping DIMs close to where they are used makes the most sense. That way I can quckly and easily (without a lot of scrolling) usuially see who uses what variables. So I often use the colon (:) to put the DIM on the same line as where the var is initialized.
It allows vars to be commented once. :-) In rewriting this, I also removed a number of unused DIMs from the original code that weren't used. -
Many renames: I shoot for good, short, & useful names. (e.g. Rather than j, iStart).
-
Wide load: I rewrote this to satisfy my own taste. I find coding using greater screen width more productive.
-
Blank lines: I use extra blank lines to see blocks. I like blocks.
-
Horizontal lines: I like horizontal liNote: nes to seperate things. They come in different strengths, - = #.
-
Vertical alignment: I like to line things up vertically. It helps me see many things more clearly which are often related from line to line. Parallelism.
-
Indenting: I like rigorous indenting with tabs. Tabs are much quicker to edit than spaces. Tip: Kate and Notepad++ allow easy and quick block indent or unindented using tabs to reglarize indents. Kate and Notepad++ also have block mode, which allows cutting/pasteing vertical blocks.
(Notepad++ has the edge in that space and tab also works in vertical blocks to move a bunch of stuff together.) -
Comments: You might notice that I use the wide screen to put the code on the left, and comments on the right.
This allows me to read the code without the comments, but keep the comments close by, and also very importantly, keep the number of lines to the minimum, .. so I can get the most possible code on the screen at the same time. -
Credits: -I am endebted to the other authors before me for developing this basic code. Thank you. I learned a lot from you! -I revised and simplified the insertion sort and removed the credits.
Heck, the first insertion sort was written before I was born, and I'm an old guy. I think this history is interesting:
"The quicksort algorithm was developed in 1959 by Tony Hoare while in the Soviet Union, as a visiting student at Moscow State University. At that time, Hoare worked in a project on machine translation for the National Physical Laboratory. As a part of the translation process, he needed to sort the words of Russian sentences prior to looking them up in a Russian-English dictionary that was already sorted in alphabetic order on magnetic tape.[4] After recognizing that his first idea, insertion sort, would be slow, he quickly came up with a new idea that was Quicksort." - ref, see "History" at https://en.wikipedia.org/wiki/Quicksort
I am grateful to a book on the elements of coding style I was forced to read 30 years ago which first got me thinking about non-functional coding style.