And I know how to how to use braces to properly end a switch statement.
Since I am guessing you were waiting for applause...
Since many of them are either in college or school, and many of the problems involve assignments, spoonfeeding is frowned upon. It does not help, except in the simplest of ways.
The old adage of teaching someone to fish rather than simply giving someone a fish applies.
So please, don't spoonfeed.
If you wanted to quote adage, I would say that this also applies:
We learn by example and by direct experience because there are real limits to the adequacy of verbal instruction.
I was told one of the best ways of learning was by teaching others; that is why I am here.
Spoonfeeding isn't** teaching.
If giving an example is 'spoonfeeding' than I disagree. I much prefer to learn coding by example rather than having technical jargon shoved down my throat; but that is just me.
I am not a professional teacher, nor a professional programmer for that matter, just some kid looking to learn. Since my encounter with Fubarable, I don't believe I have participated in 'spoonfeeding', but please provide an example for clarity if I have. Or better yet, show me any inadequacies in my answers to people; that would actually benefit me. I would love for your guy's little clan to dislike me, and go over my posts with a fine tooth comb looking for flaws in my answers; waiting for me to make a mistake. That would not be a bad thing in my eyes.
If I hadn't been rude to pbrockway2, I probably wouldn't have spent a few hours learning about the printf method.
I'm a professional programmer and trainer.
In this case pbrockway had already pointed the OP to the tutorial on switch statements.
The next step was up to the OP to try it (which they said in their post they were going to do) and come back with any problems, including code to show where they are lost. We then provide help in that area.
Now, your example above is borderline, it has to be said, as it is not a copy/paste job.
Take my post above more as a nudge than a "you did this wrong".
Besides, the tutorial should have covered enough for the OP to do the job, barring some misconceptions.
I've taken the liberty of moving this off topic discussion here where it belongs (from here).
For what it's worth: (taken from its original form here: The Problem with Spoon-feeding)
Spoon-feeding is NOT helping. It robs a person of the process of solving a problem by working through it, which is not only fun but is also a crucial skill to learn. Problem solving is much harder to learn than memorizing syntax. Even if a person looks through the syntax you provide, you’ve taken away the chance to practice problem solving, which will only make it harder for the person to solve the next problem. Spoon-feeding only makes you look like a newbie. If you actually want to help, a better way to do so is by helping people work through the problems (instead of simply posting the solution)- suggest breaking the problem up into smaller steps, or ask where they’re stuck. Spoon-feeding can lead to moderator action.
What is spoon-feeding?
Before I get into the problems with spoon-feeding, I guess I should define what I mean when I use the term. Spoon-feeding is giving somebody a full solution before that person has really put a full effort into solving the problem. Helping somebody along with examples and links to tutorials is not spoon-feeding, but copying and pasting a complete code solution IS spoon-feeding. It’s not an exact science, and every situation is different, but it’s the difference between helping somebody with homework and doing homework for somebody- one is helpful, one is hurtful. Spoon-feeding is not helping.
For example, say a person has a FizzBuzz assignment (print out numbers 1-100, but print out “fizz” instead of numbers that are multiples of 3 and print out “buzz” instead of numbers that are multiples of 5). Spoon-feeding would be if you wrote the program and copied and pasted it as a reply. A better way to start helping people is by asking which part of the program is giving them trouble, where they’re stuck, and what they’ve tried.
What’s the problem with spoon-feeding?
The problems with spoon-feeding are the same problems with taking a person’s homework and doing it for him or her. It doesn’t actually help the person learn, and it can actually lead to more serious situations down the road.
Problem solving is fun, and offering full solutions robs people of that fun.
Some people might feel the need to offer a full solution because they view the problem as interesting or a fun challenge. But if you think the problem is interesting or a fun challenge, maybe the OP does too. Offering a full solution is like ruining the ending of a movie or giving away the answer to a riddle too soon. Part of the fun of programming is the process of working through a problem and figuring things out, and spoon-feeding robs people of that process, which is extremely rude and not helpful at all. A better option is to give hints that the person can use to help solve the problem him/herself.
Problem solving is extremely hard to teach (harder than memorizing syntax), so providing syntax as a solution is missing the point.
Problem solving is not only fun, it’s one of the fundamental skills required to be a good programmer, and it’s one of the hardest to teach. Anybody can memorize syntax, but how do you learn how to work through a problem? The answer is by working through different kinds problems, over and over again. Offering a full solution before a person has worked through the problem is robbing the person of that process, and that prevents the person from becoming a good programmer. A better option is to help the person work through the process by suggesting breaking the problem up into smaller pieces or thinking about how a human would solve the problem in his or her head or with a pencil and a piece of paper.
One can argue “but the person can look through my solution and learn from it”, which not only assumes that one’s answer is actually correct (see below), but is also misleading. Like I said above, anybody can memorize syntax, but the knowledge of how to use that syntax to solve problems is only learned by working through a problem, making mistakes, and realizing the uses of the language structures.
Give a man a fish, feed him for the day. Teach a man to fish, feed him for a lifetime.
Given the FizzBuzz example, let’s say you provided the person with the full solution. Even if what you post is correct, and even if the user takes the time to understand the syntax, what happens during a test that asks the user to print out prime numbers or to calculate what coins add up to a certain change amount? All of those problems can be solved in similar ways, but the person would not understand the process of taking a question and turning it into syntax. And that would be your fault.
Not only does spoon-feeding rob a person of the fun and experience that comes with working through a problem, but it actually puts the user at risk. Downloading solutions from the internet is against most institutions’ academic dishonesty policies, which can result in failing the assignment or the course, or even being expelled. It might seem melodramatic, but I don’t want to be responsible for somebody being kicked out of school.
Spoon-feeding does not impress anyone. There are other places to get practice.
Another reason people might spoon-feed is because they feel the need to prove themselves. But if you want to prove yourself, keep in mind that the community of these forums judges you simply by helpful you are. Chances are, most of the regulars of any Java forum could have solved the problem but chose not to post a full answer, for all of the reasons outlined here. Offering the solution to simple programming assignments as if it was an impressive accomplishment is actually a sign of an inexperienced user. That’s not what these forums are for- check out Project Euler instead, or post a thread in the Café section of the forum asking for challenges. But when replying to a question, you should offer hints, examples, or links to tutorials instead of offering copy-pasted code.
If you're spoon-feeding, chances are you're wrong.
Given that most spoon-feeders are generally pretty inexperienced (oftentimes less experienced than the person asking the questions), I’m not exaggerating when I say that nine times out of ten, spoon-fed answers are actually incorrect. They almost always contain basic and obvious syntax or logical problems. This is obviously not helpful to the person who is receiving bad advice, misunderstanding important concepts, and probably handing in incorrect work, but it’s also bad for the forums. We have thousands of posts here and only a handful of moderators volunteering their time to answer questions and keep things organized, and it takes a very long time to correct bad advice. Also, if users come to the forums looking for an answer to a question and see that bad advice has been given, they’ll probably not trust other answers they see here.
So what happens to spoon-feeders?
There is a special place in hell reserved for them. Just kidding. Actually, all of the above being said, each situation is different, so it’s hard to make an all-encompassing rule about spoon-feeding. For example, when people are dealing with a bug (which is rare), offering workarounds in the form of full code might be okay. Or if a person has put forth enough effort and almost has the problem solved except for some basic syntax errors, fixing them might be fine. But for the most part, if something is obviously homework, posting full solutions is a bad idea. Each moderator is different, but I personally delete spoon-fed answers and will vote to ban users who continue spoon-feeding.
Is it spoonfeeding to post an alternative answer after the OP has already succeeded in finding a path to the answer? Just to post a more optimized way of writing something; or asking if there is a more optimized way of writing something other then how I would go about doing it?
If the OP has posted code that works, but might have an atypical way of doing something, then posting a "you might want to consider" type of posting isn't a problem.
For a simple example "if (<someboolean> == true)"..saying that the "== true" is pointless is not a problem. It's also not spoonfeeding.
Suggesting using a case statement instead of a mass of if/else, or the classic "use a PreparedStatement" for almost any JDBC question we seem to get, often linking to the relevant doc (tutorial in the former, API in the latter).
It's all really finger in the air stuff, to be honest. For example, little of the above applies to someone who is clearly doing this as a job. Well, unless they have no code to show for their efforts.
I suppose that's probably the best guide. How much effort have they made? Have they shown a grasp of the basics and simply made a mistake?
If it's someone who is asking (as the post that set this off was) how to do XYZ then pointing to tutorials (usually the Oracle ones) is a fairly typical response. Then they can come back with a code attempt you can critique, or fix.
But in any case there is likely to be few (if any) instances where you will be providing more than a snippet fixing the relevant part of the code.
Is a 'case' statement better then a massive 'if' statement? Does it run faster or something?.. Or just because a 'case' statement is easier on the eyes in large cases?