There are a lot of requests for help with programming homework posted on forums. They range from requests to help with fixing one small problem that is stopping their solution from working through to attempts to get someone else to do the homework for them. Many forums permit the former type of request while not allowing the latter - since obviously if you get someone else to do it for you then you don't learn how to do it yourself and learning how to do it is the real purpose for which the homework is given.
From the way a lot of these requests are worded it appears that the person hasn't the slightest clue as to how to solve the particular problem. The way they word their question gives the impression that the task has been given to them without their having been taught anything at all previously that they could use to produce a solution. Presumably the person has actually attended classes on the subject prior to being given that homework and during those classes will have been taught how to write code that does certain things (whether the code they are being taught is actually appropriate or not is a different matter - many computer programming classes teach techniques that were outdated many years ago).
The homework that they are given would be intended to take the things that they have been taught how to do and combine them together to produce a specified result. Just what the person is expected to know how to do will vary from class to class as there are many different orders in which most of the aspects of a given programming language can be taught.
Now even if the people on a forum were inclined to produce a solution for the person (and hence ensure that the person not learn anything from the homework), there is never any indication given by the person asking for help as to what things that they have been taught in class so far. Presumably if they had actually learnt what was being taught then they'd have no need to ask for help. Now with most of these homework questions there are usually a number of different ways to achieve the result. Depending on the stage in the course at which the homework is set, it is possible that some or even most of the possible solutions would use code that has not yet been taught in the course. So even if someone on the forum were to provide a solution there is a very good chance that it would be easily recognised as not having been written by anyone taking the class.
Only by providing complete information on what has been taught in the course so far would it be possible for someone to provide a solution appropriate to what the homework question is asking for. Now if the person asking for help were able to supply that information then they'd already know how to produce code that would at least be reasonably close to what is required since the solution is simply a matter of assembling parts of what is already known and in particular some of the things most recently taught. While the code that the person can produce by doing this might not work either because they have mistyped something or have misunderstood a concept, producing this before asking for help does achieve a number of results. First it means that they have actually made an effort to solve the problem themselves. Second it demonstrates to those who have been asked for help what sorts of commands that have been taught to the person asking for help. Third it presents a situation where providing a fix for the code actually teaches the person who has asked for help. So asking for and getting help at that point is reasonable and useful whereas asking for help before trying to produce a solution is not.
So what should the person do when they have been given homework and have no idea as to how to proceed?
Well the first thing to consider is that the homework probably relates to the things that you have been taught most recently in the class. At least some of what you have just been taught will be needed in providing the solution. You might consider listing the commands that you have learnt recently with a description of what each does and then think about how each might assist in developing a solution to the problem. It doesn't hurt to do this after each class anyway even if you don't have homework that you can't solve since it will help you to revise what you have learnt.
Another thing to try is to think about the problem in terms of how you would solve it if you were doing it without a computer. Write down the steps that you would perform in producing a solution. If necessary break each step down further into smaller tasks. Now think about how you would go about writing code to solve each of those tasks. By combining the code that solves each of the small tasks together you would get a solution to the overall problem.
Many of the problems given as homework for computer classes do not have any real world use and are being given simply to help you learn how to combine the commands you have learnt together to produce a given result. It also means that you are unlikely to find an exact match to the problem in any code that you can find to look at that does produce real world results. This doesn't mean that it isn't worth looking at other people's code to see if it might provide you with an idea of how to solve the problem that you have been given. Of course if you are being taught properly then any really old code you find may be completely obsolete and inappropriate to use and if (as is more likely) you are being taught an older style of writing that language then the more modern ways of doing things may be beyond what your teacher knows. So you do need to be aware of some of the things that might have changed over the years if you are going to examine other people's code (and just because they wrote it yesterday doesn't mean that the code they used wasn't obsolete ten years ago).
There are lots of things that can be done to at least attempt to do homework yourself before asking for help. You will learn a lot by carrying out these steps even if it doesn't result in your actually getting a working solution to the homework. Once you have got as far as you can then it makes sense to ask for specific help with whatever it is that has you stuck - either code that you think should produce the solution but which doesn't for some reason so that you can ask why it doesn't or where you don't know how to tackle some small part of the problem and ask for suggestions on what commands to use.
If you ask for help at an early stage where you haven't even got any code at all yet then you need to still ask specific questions. If you actually ask if specific commands might be useful in solving the problem then someone will be able to tell you whether they are or not so that you can either proceed in trying to work out how to use them or move on to look for different commands. If you are really lucky someone might answer such a question by actually suggesting in general terms how to break up the problem into smaller tasks. This would then make it more obvious to you as to which of the commands you have just learnt that you are supposed to be using in the solution.
There is nothing wrong with asking for help with homework provided that you have already attempted to do it yourself and the questions that you ask are specific ones that are intended to help you to learn how to solve the problem. The goal of any course should be to learn how to do something. There is no point in passing a course just because you got other people to do the work for you and where in the end you don't really know much more than you did before you started.
This article written by Stephen Chapman, Felgall Pty Ltd.