The traditional method of teaching involves introducing students to a new concept, then exhaustively explain everything about that concept before moving to the next concept. This is linear learning. I think of it as depth-first learning, where a topic is studied in detail, sometimes to the point of redundancy.
There’s a huge flaw in linear learning. It’s boring. Different learners have different learning styles. When applying one singular teaching method with an emphasis on giving out as much detail as possible, students are interested up to a certain point in the lesson and then stop. They stop because either they’ve learned enough or got bored with the subject. In any case, they need to apply that knowledge and then move on to something else.
Searching for a more comprehensive learning method
Another learning method is spiral learning, where students touch on a new concept, learn to apply it, move on to a related concept, apply that one and move on to another related concept. The idea is for students to gain a level of mastery in other subjects and acquire greater understanding about previously taught subjects. A concept may be revisited again for a deeper discussion, thus completing a cycle or in this case, a spiral.
I think of spiral learning as breadth-first learning, where many related subjects are covered as much as possible. Spiral learning solves the boredom problem in a linear learning pattern. It too has a flaw, though it’s not obvious.
In an academic setting, the topic of study is often determined by the degree requirements, subject prerequisites, a friend’s recommendation or even a whim of the moment. “Related” subjects are weakly connected to each other, where “weak” refers to the level of personal interest. And this is a weak point of spiral learning. Few people know what they want to learn next, so they follow predetermined guides.
They work better for computers
So linear learning and spiral learning, the former being a depth-first, the latter a breadth-first. They follow two standard search methods, the depth-first search and the breadth-first search. Both try to find a sought after item in the shortest amount time or with the least effort. This works well… for a computer program. Computers need structure, a predetermined system to do their work.
I believe human learning behaviour is radically different. Children learn an extraordinary amount of knowledge about many seemingly disparate subjects quickly. They learn to differentiate colours, ride a bike, do math, sing and dance, speak and read and write, be a friend to someone. They learn about as many subjects as they are interested in. Then school kicks in and institutionalised a learning behaviour for every single child.
What happened when we grow up? We are faced with problems to be solved and there’s not enough time and energy to learn linearly. We don’t even do spiral learning. We pinpoint the problem and we search for an exact answer for that problem.
I see this happening particularly in programming forums, where someone post a question and sought an exact answer to that question. A kind soul answered the question and gave an incomplete code sample, which just needed a little tweaking to get it right for the questioner’s unique situation. Keyword here is “unique”. It’s always better for the person to determine if a solution is usable. Not good enough for the questioner though.
If the questioner had the habit of connecting many different concepts at once, a little thought would have given him the answer. The incomplete code sample would simply act as a nudge in the right direction. The habit however, needs to be formed when we’re younger, and generally speaking freer in our time.
The nebula learning pattern
Humans follow a nebula learning pattern. We form interests, emotions and knowledge of different topics and are therefore proficient at different levels. Our knowledge can be visualised as a nebula where denser clouds represent deeper interest and proficiency. We learn about things with no relation to each other, yet sometimes with almost equal amount of interest and intensity. We touch on topics till bored, then jump to another topic.
In a way, our questioner above is following the same pattern. The question posed was important to him, probably because his job depended on it. That’s why he’s interested in the answer. He probably doesn’t even care about the concepts that led to that answer. He just wants to copy and paste the answer.
We don’t all have to become polymaths, but if we can consciously learn and form nebulae of knowledge, I believe the world will be a better place. We have too many specialists anyway.
Many times when we’re busy churning out code and worrying about the accuracy of our calculations, we can forget that ultimately our users are looking at the results. We have to care about how to present those precious calculations so our users can make sense of it.
So you’ve learnt a bit about
Arrays offer a simple syntax to declare a series of variables of the same type with minimum work. Think of arrays as boxes in sequential order, where the boxes can only hold a certain type of item.
I was intrigued by this math problem a while ago. It took me a couple of pages of calculations to get the solution. Then I kicked myself because the solution was actually staring in my face.
I’ve been writing a few 


I'm a mathematician, programmer, writer, 






Beginning C# – Precision and control
So you’ve learnt about variables, and you’re wondering, “What’s the practical difference between float, double and decimal variable types?” The difference is in precision.
floats represent single precision real numbers, known as such because of the floating point (or decimal point).doubles represent double precision real numbers, taking up two times the storage space of afloat(different from representing two times the range of a float).decimals are a bit special, as they can represent up to 28 significant figures. It’s easier to just show you, so here’s the example code (only contents of the Main function).float lowprecision; double highprecision; decimal exactprecision; lowprecision = 1.61803398874989484820f; highprecision = 1.61803398874989484820; exactprecision = 1.61803398874989484820m; Console.WriteLine(lowprecision); Console.WriteLine(highprecision); Console.WriteLine(exactprecision); if (5 > 3) { Console.WriteLine("First condition"); } else { Console.WriteLine("Second condition"); } // variables can be declared and assigned a value // on the same line of code. int truthchecker = 17; if (truthchecker == 17) { Console.WriteLine("The truth is the number 17."); } if (truthchecker != 17) { Console.WriteLine("The truth is NOT the number 17."); } /* The following if-else statement is equivalent to the above * two if statements. * This comment also illustrates how to use a multiline comment. * */ if (truthchecker == 17) { Console.WriteLine("2nd check: The truth is the number 17."); } else { Console.WriteLine("2nd check: The truth is NOT the number 17."); } Console.WriteLine("End of program"); Console.ReadLine();I’ve used a prominent mathematical number, the golden ratio, as an assigned value for our
float,doubleanddecimalvariables. You should have noticed the “f” at the end of golden ratio for thefloatvariable assignment, and the “m” for thedecimalvariable. These are known as suffixes, and there are other suffixes for other variable types. For now, just remember to append an “f” forfloats, and an “m” fordecimals.Output for float, double and decimal
When you print the variables, you get 1.618034, 1.61803398874989 and 1.61803398874989484820 respectively. The difference is due to the size of the variable type, affecting how a variable stores a value. So even though the assigned value is the same, the storage and thus the stored value is different for the three variables.
One practical use of preferring
floats over the other two types is their speed. Smaller storage sizes translates to faster calculation speeds, while sacrificing accuracy. This is particularly useful in games, such as calculating 3D positional points where the results don’t have to be accurate as much as being quickly computed. The player isn’t going to notice that a box is 0.000005 units off to the left, because he’s too busy shooting some dastardly evil aliens.When accuracy is extremely important, such as in financial applications,
decimals come into play. There are real numbers thatfloats anddoubles cannot represent exactly. For example, the only money values afloatordoublecan represent exactly are 0.00, 0.25, 0.50 and 0.75 (or any dollar amount with those cent values, like 14.75). Why is this? Short answer is it’ll take too long to explain. Try searching with the words “exponent” and “mantissa”. Anyway, with 28 significant figures for accuracy,decimals are ideal for financial applications.Decisions, choices and forks
Next we learn a new concept: the
ifstatement, one of the most powerful and most used construct for controlling program logic flow.if (5 > 3) { Console.WriteLine("First condition"); } else { Console.WriteLine("Second condition"); }Note where the round brackets () and the curly brackets {} are used.
The above code can be read as “If 5 is greater than 3, then print ‘First condition’, otherwise, print ‘Second condition’”.
The
ifstatement can also be used alone without theelsepart, such asif (truthchecker == 17) { Console.WriteLine("The truth is the number 17."); }Note: The double equals mean mathematical equality. A single equal mean assignment.
In English, the above code reads “If the variable ‘truthchecker’ is equal to the number 17, print ‘The truth is the number 17.’” Some programmers prefer to reverse the check, like “
17 == truthchecker“, to avoid confusing equality checks and assignments. I find it kinda funny to check in reverse, so take your pick.Then there’s the converse.
if (truthchecker != 17) { Console.WriteLine("The truth is NOT the number 17."); }The exclamation mark followed immediately by an equal sign means “not equal to”. So the chunk of code reads “If the variable ‘truthchecker’ is not equal to the number 17, print ‘The truth is NOT the number 17.’”
Multiline commenting
Two consecutive forward slashes
//means whatever follows on the same line is a comment, and to be ignored by the computer. What if your comments are too long and go over the next line? You can start another line with//and continue writing comments. Or if you can start your comments with a forward slash and an asterisk/*and end your comments with an asterisk and a forward slash*/, which achieves the same effect.Homework
Wow, that was a long lesson. So homework will be short. Download the source code, and replace the line
with
Change the numbers around and see what happens.