DEV Community

Steffen Frosch
Steffen Frosch

Posted on • Updated on

My approach to teach programming

Recently I got a new responsibility at my work place. I am now officially responsible for the training of our apprentice and intern.

In case of the apprentice there is a lot of stuff he has to learn because he has little to no programming experience when he started. This is perfectly fine because he got the job so he can learn.

I came up with a plan, which from my point of view is somewhat unconventional but i hope it'll work out.

In the first few weeks he learned about html/css. Basic stuff because we do a lot of web development and this is a field where he can quickly contribute.

To get him started learning programming i created him a small project. Just a README and some configuration files for the test framework we use. In the README there are some programming challenges. And i hope these challenges are not overkill to begin with. But i do really want to manifest the habit of writing test directly from the start. (I have to add that he had some time to familiarize himself with the syntax of the language we use)

The first one is pretty easy. Run the test suite and fix the failed test. There is a little program that calculates the sum of two numbers and the difference. The subtraction method has just mixed up the parameters in the wrong order. This is just to get to know the basic on how to run the test and how to make 'em green again ;) After that he should add multiply and division methods to the "calculator" and write test cases for that as well.

The next challenge is to write a program that calculates values of the fibonacci sequence. He should use a for loop in the algorithm and write some test cases to verify that the algorithms work. After that he should rewrite the for loop for a while loop and try to not touch the test cases. After that he should rewrite the while loop for a recursive solution. And also trying not to touch the test cases.

The third challenge is the roman literal challenge. Convert a roman number to an integer. And write the test cases as well.

I am planning to add more challenges even some for functional and acceptance testing over time.

What do you think? Is this doable? Do you have some ideas for challenges? What would you change?

Top comments (8)

Collapse
 
tamouse profile image
Tamara Temple

For years now I've been considering this as an approach to teaching; many places have done something similar to this in that they provide the test cases and you have to write the code that passes them.

Putting the emphasis on testing, and the development/test tools and environment, probably doesn't meet some folks expectations of learning, but I think it's both reinforcing learning the syntax and learning the concepts of problem solving. Tests are code, and it's a very legitimate way to learn how to program.

Only one thing I'd add at even this early stage is version control, learning to branch and merge, make incremental improvements, and having code reviews as part of that.

Collapse
 
kodierkroete profile image
Steffen Frosch

Yep git will be introduced in the very near Future. But i don't want to overwhelm him with a million Things at once.

But the plan ist that he will soonish do small things in a customer project. Before that there is no way around learning the git basics.

The idea of the providing tests is really good. I will definitely add a challenge like that to the project.

Collapse
 
rpalo profile image
Ryan Palo

That sounds like an awesome way of doing it and incorporating practical things like testing and documentation! Is the apprentice already comfortable with the command-line/running tests or are you planning on covering that first?

That's the thing I've had trouble figuring out: I want to teach important things like version control, testing, etc. as early as possible, but how early is too early? I also don't want to scare the student with all of that stuff before they've gotten comfortable with basic coding concepts and gotten all fired up about it.

Anyways, you should definitely do a follow up and let us know how it goes and what you learn! :)

Collapse
 
kodierkroete profile image
Steffen Frosch • Edited

It is never too early i think you should just limited the things that you throw at them ;)

In case of my apprentice the project README has everything needed to install it and run the test suite described. So no googling should be necessary. As this is the first time i have tried this approach i took approximately 1 hour to get it up and running on his machine.

I explained the things i was doing and limited the information i was providing so that it was (at least in my opinion) manageable to comprehend. I will definitely keep you posted on how that experiment went.

Edit: No he is not comfortable with the cli yet... but i promised him the terminal will soon be his go to weapon for a lot of stuff ;)

Collapse
 
larswaechter profile image
Lars Wächter • Edited

I definitely like the way you teach him programming. Especially the testing part.

The new interns at our company started with the basics like HTML/CSS and some Javascript. Afterwards they learnt our backend language and version control.

Within the next 3 months they had the basic knowledges. Like loops, if-conditions and so on.

Afterwards I asked them to build simple algorithms like switching the position of the highest and smallest number in an array or to sort it in a certain order. It was really hard for them to solve these tasks, even after several days they couldn't solve them and they didn't want to solve such kind of tasks any more.

Though I think these tasks helps one a lot to learn the principles of programming and the way of thinking you need. So I would recommend everybody who has already basic knowledges of a programming language to solve such kind of tasks.

Collapse
 
kodierkroete profile image
Steffen Frosch

I know exactly what you mean. I once tried to do code dojos in a company i worked. Interns besides senior and "regular" devs (whatever the hell that means). A 20 minute duration is not much to solve a problem and we time boxed it to 2 hours (with discussions between the iterations).

With each iteration the interest in solving the problem shrunk more and more. I think when you deal with complex problems on a daily basis you need a lot of discipline to challenge yourself to do these "trivial" task to learn more.

So maybe it is a motivational problem. And you are absolutely right that everybody once in a while should do these kind of tasks. And even if it is only to stay "sharp"

Collapse
 
costinmanda profile image
Costin Manda

I believe all teaching using this mechanical approach will ultimately fail. I like the idea of testing how people think in a practical situation rather than fill them with knowledge and see what they remembered, but if the tests are fixed, then all they have to do is go to an Indian forum on how to get hired and learn by rote what the solution is. I don't have an alternative for you, though, other than a huge database of low level problems they can try to solve. Frankly, I would not feed them programming problems, but real problems that they need to solve. And make sure they need programming to solve them :)

Collapse
 
kodierkroete profile image
Steffen Frosch

Hi,

i do believe it'll work out but i get your point regarding real world problems. He is currently doing his first issues in a real customer project. This approach wouldn't work without some practical task. But my job is to get him from 0 to productive and it is my believe that real world tasks are overwhelming if you are not quite familiar with the language and concepts behind development.

A thing that i hoped for and validated over the last weeks is, that writing the tests from the very beginning resulted in confidence in his code and it was fun to see how it evolved from "I have no idea what to test" to "hey i should also test this as well".

He won't do the code exercises full time but he will get a new code challenge from time to time.