Tip:
Highlight text to annotate it
X
You know, every programmer should be able to read code in plain English as a sentence.
This is something that can easily be done to solve problems or even to have a firm idea
on what the code is supposed to do.
Well Hello!
I am Jesco the Rising Phoenix Dev and So today, we are going to discuss the reasons why you
should do this and how to go about utilizing this skill in a few different ways.
So, let’s sit back, relax and go into How to read your code like a *** sentence!
Note: I am saying English but this does not mean that if English is not your native language
that this does not apply to you.
You should be able to translate your code into complete sentences regardless of what
your native language is, and if you do plan on being a programmer, having an understanding
of the English language will make your life substantially easier.
Before we go into depth with this, I first want to explain why it is important that you
should be able to do this consistently and very often.
Being able to translate your code into plain English means that you understand every function
call, parameter’s usage and language syntax which makes it very easy to see where your
code went wrong or how the code is supposed to work.
Every line of code does something very specific and should have a reason for existing.
This includes comments, fields, properties and functions.
Being able to explain all of these things clearly goes a long way in understanding not
just your code, but another person’s code as well.
Think of your source code as a book and it tells a fantastical story.
With each line of code written, another sentence is created in that novel.
Each class is a separate chapter of the story until it culminates into a full novel that
has a beginning, middle and an end.
Now that I have described the why of reading code like a sentence, let’s get into the
how.
On the screen, you should see some code.
Take a moment to read the code and try to understand what it is supposed to do.
Don’t worry, the code in the image isn’t too comp--- *ahem* damnit…
Hopefully the image won’t go haywire on us again.
I’ll give you a few moments to look it over and to try writing it down as
a sentence.
Alright, Now.
Let’s see how you fared.
This is what that code says in plain English.
System gives commonly used value and reference data types, events and event handlers, interfaces,
attributes and processing exceptions.
Example is the name of this specific set of tasks that makes sure there is no naming conflicts.
Class program is the name of this set of blueprints to follow and it is private by default.
The entry point into this application is static void Main and without it, the program would
not run.
Var population is set to be a new Tuple with the parameters of string, int, int, int, int,
int, int.
This means there is a 7 tuple or a septuple, which is a tuple with 7 parameters.
The string value is New York and we have the numbers 7891957, 7781984, 7894862, 7071639,
7322564, and 8008278.
Each of these numbers represents the census information that dates from the year 1950
until 2000.
Console dot WriteLine will format and write population of the first parameter in 2000:
second parameter comma population dot Item 1 which is the first item of the tuple (the
string value) comma population dot item 7 which is the last item (the last int value).
1:N0 designates that this should add all of the other int values together with the last
int value and have a precision of 0 meaning that it will drop all the excess decimal points.
How did you fair?
Did you write something similar that explained the code as closely as possible to something
the average idiot could understand?
Now, you should notice right away that there is something missing from this code, if you
run it, you wouldn’t have time to actually see the results.
In other words, I should have added a Console dot ReadLine to pause the exiting process
until I pressed the enter key.
This can be expanded into game development, more complex application development, mathematics,
and everything else related to programming or computer science.
I went with a simple example to show that it doesn’t matter how trivial an application
is, it is a good habit to get into no matter what your level of programming is.
If this doesn’t convince you, take a look at my How Its Developed series where my tutorials
are designed with this exact setup in mind.
Every tutorial and book pretty should much follow this exact idea if they are worth their
salt because they should be designed to teach you exactly what you need to know and why
you are doing something, not just the how to.
This has been the Rising Phoenix Dev and remember… read your code like a *** sentence and
99.99% of all of your problems can be solved.