You are currently viewing How We Should Teach Students Programming

How We Should Teach Students Programming

I had been exposed to students who are striving to learn a programming languages. Either it’s in Java, C++, PHP, Objective-C, Perl, Ruby, SQL, or Dart, some of them have a difficulty in making scripts and code to solve a particular problem. Some of the students are basing their coding through memorization. If they see an “if”, they automatically say it’s a conditional statement which is correct but they fail to see the logic. Sure, memorization is important to a certain degree but we need to make them understand that an “echo” is more than just displaying a certain text. There are so many problems on this issue so I’m only going to tackle on how we could help students understand programming languages on a logical scale.

We need to treat programming languages as if it’s we are communicating with the computer. Students are only using programming keywords as if they do something. This problem causes their brains to be dependent on what it does rather than a certain command that to express onto a computer. Here’s an example, in PHP an “echo” is a construct that outputs or displays one or more strings. Rather than ending the explanation at that, we can explain to them that it echoes back to whatever string or text that we include.

echo “Hello students. I am echoing back this text. My answer is ” . $sum;

To explain the code above, it’s like saying “Computer, I would like you to echo back ‘Hello students. I am echoing back this text. My answer is ’ whatever the $sum.

We have the “.” which signifies string concatenation and we can treat that like a period or comma which signifies that the statement doesn’t end there. So it’s just like the computer would say:

– If $sum = 5
Hello students. I am echoing back this text. My answer is , $sum
Hello students. I am echoing back this text. My answer is , 5
omit the comma
Hello students. I am echoing back this text. My answer is 5

I know if you’re thinking that I’m making this more complicated, but the sense that you understand how it goes would definitely be beneficial in the end.

Another language that I enjoyed teaching is SQL because I could definitely explain to my students on how to make a query that is understandable to anyone. Like for example:

SELECT * FROM `articles` WHERE `published_date` > ‘2015-02-02’

This is how would I explain this, Select all from the articles table where the published date is greater than 2015-02-02. That’s pretty simple, but how about a little bit complex? I’ve taken this example from Wikipedia:

SELECT b.isbn, b.title, b.price, sales.items_sold, sales.company_nm FROM Book b JOIN (SELECT SUM(Items_Sold) Items_Sold, Company_Nm, ISBN FROM Book_Sales GROUP BY Company_Nm, ISBN) sales ON sales.isbn = b.isbn

Since we saw a parenthesis, we automatically treat that one first so:

SELECT SUM(Items_Sold) Items_Sold, Company_Nm, ISBN FROM Book_Sales GROUP BY Company_Nm, ISBN

Select the sum of the Items_Sold, the Company_Nm, the ISBM FROM the Book_Sales table which we group by the Company_Nm

So that’s already done, then we can now take care of the rest:

SELECT b.isbn, b.title, b.price, sales.items_sold, sales.company_nm FROM Book b JOIN (SELECT SUM(Items_Sold) Items_Sold, Company_Nm, ISBN FROM Book_Sales GROUP BY Company_Nm, ISBN) sales ON sales.isbn = b.isbn

Select the isbn from the “b”, title from the “b”, price from the “b”, items_sold from the “sales”, company_nm from the “sales” FROM the Book table which we treat as “b” then we will JOIN whatever we Select the sum of the Items_Sold, the Company_Nm, the ISBM from the Book_Sales which we group by the Company_Nm which we treat as “sales” compared it ON the isbn from the “sales” to the isbn from the “b”

Sounds like a science lesson which makes your nose bleed but it’s like learning your English 101 during your school days. First it’s a bit confusing as hell because you need to learn about composition, direct objects, nouns, verbs, and all of that. But once you’ve got a hang of it, it’s like communicating a certain language to your computer.

I believe that all people can code but the question is how we can teach them that even a simple person can understand. Yes, learning a programming language is hard especially if you don’t have the enough logic to deal with the syntax but I believe that there are ways that we can teach people how to code.

I don’t know, maybe I’m talking trash or something but if you have some efficient ways on how to teach programming languages, comment it out below.