Solving Programming Problems and Challenges Step-by-Step
Today, I want to talk about how to go through solving challenges in a programming course, specifically some of the courses that I put out, so let’s talk about that.
Today we’re talking about solving challenges and this video is really specific to some of my programming courses, because what I tend to do with the course, and this is not just me doing this, a lot of other instructors will do the same.
I’ll teach a certain concept or a set of concepts, then at the end of that video or a series of videos, I’ll issue a challenge, and the challenge will normally be for you to write a program that will go through and use that functionality, those features that I’ve actually taught in the preceding videos.
So you need to write a program to solve a particular challenge or problem using those features, so the idea is by doing that, you’ve looked at the how to do it by watching me in a video, but now you’re applying those skills and you’re learning something, so that could be a great way for you to solidify these skills that you’ve learnt.
Now, one of the things that students can get bogged down with is how to actually go about solving these, because that can seem overwhelming. And if you think about it, if problem at its highest level, and if you’re looking at it sort of from a helicopter looking down on a problem, can be quite intimidating, because there’s a lot to it.
So if I told you to write Space Invaders, the computer game, that’s a high-level thing, so you’re thinking, well, how do I do all this? Where do I start, how do I make the players move, how do I draw the score on the screen, et cetera. It can be overwhelming looking at the whole project, so one of the obvious things you can do is break down the problem, the problem into smaller sections. So getting back to the analogy of a particular challenge, normally you’ll find that, I set three or four specific things that you need to do, so as an example would be, writing a method, a particular method that returns the sum of two numbers.
Now, that might be intimidating when you’re starting out learning how to program, because you’ve never done it before, and just a quick aside here, that no one is born a programmer. So every programmer you’ve ever met or spoken to or read about and me, myself included, at some point, we didn’t know how the program, so we’ve been through these steps, we’ve been overwhelmed at times, and we’ve worked through it, powered through it, and succeeded, so getting back to the example, break down the problem, okay, you need to return, write a method that returns the sum of the numbers.
Now, obviously, there’s a few things in there, we need to know what a method is, we need to know how to return a number, and we also need to know how to actually calculate the sum of two numbers, so there’s a number of things in there and you’ll notice that I’m breaking that down straightaway into its specific area.
You’d think, “I need to know what a method is”, so you then go back into preceding videos if you weren’t sure, and you rewatch the section where I explained how to define a method and what a method is, what it’s used for, and from there, the next step would be “Okay, I now understand the basics of a method, of what a method is, it’s basically a separate block of code”.
Now you need to figure out, “How do I get it to return something, to return a value?” That’s where you look at return types and look at defining a type for the method to return. Again, usually, in my course and most other courses, how to do that is explained in the preceding videos, so you’ll understand that again.
So you’ve broken down the two things, and the third step is, “How to figure out the sum of two numbers?” So you go back again and see if that was specifically covered which it may or may not be, you could search and find out how to figure out the sum of two numbers.
So you can see, by breaking down the problem into smaller problems, you’re not overwhelmed, and the other great thing is that as you’re doing that, you might find for example that you’ve got a problem that’s, you’re breaking it down into 10 subproblems and you can only fix six of, work out how to do six of those.
So instead of saying, “This challenge is too hard, I don’t know how to do it.” You can be more specific and say, “Well, I’ve managed to do this and this”, so you’ve done six things, but these four things, you’re stumped by, and you’re breaking down the problem into smaller areas, and it’s making easy for you to get answers either from the instructors going through helping you or just researching that.
I’m sure you agree that if you’re searching for a solution, searching Google for how to figure out the sum of two numbers, is a very specific search request and you’ll likely get thousands, tens of thousands or hundreds of thousands of results and different ways of doing that.
But if it’s a more generic thing, how do I write a method that returns the sum of two numbers, that’s a harder thing to search for in Google, so try and break down your problem into the smallest bits that you can, and work down like that and gradually work back and you’ll find that that’ll become a lot easier for you to program
The other thing I wanna say just before ending the video is that by doing that, as you’re actually solving things, that really solidifies that you’re understanding the material, because it can be quite overwhelming again when you’re learning something new, and you can be thinking, “oh, I’m just not understanding this, this is just too hard.”
But getting back to that analogy where I talked about writing a method that returns the sum of two numbers, if you knew how to write a method declaration, if you knew what a return type was, and you managed to fix both of those straightaway and you’re only getting stuck at how to return, how to calculate the sum of two numbers, then you can see straightaway, and go, “Okay, I’ve learnt that, I know how to write a method declaration, I know what a method is, I know what a return type is.”
That’s giving you more confidence because then you’re thinking, “Well, I really am learning, I only got stuck on this one little area.” It’s giving you more confidence to move on. So celebrate your successes.
I can’t really state that enough that it’s very easy to be negative and think that, “I’m never gonna understand this.”
But if factoring in that, “Okay, I’ve learnt this, great, I’ve learnt what this method is, I’ve learnt what a return type is”, and you know that you’re succeeding, so that’s how you go about it, but in general, break it down into small little smaller sub problems, and try and solve them one at a time, and before you know, you’ll have the whole thing completed, and you’ll be good to go.
I hope that helped. If you’ve got any questions, feel free to leave a comment and I’ll get back to you.