:-|Hi all,
I'm new to programming and I've been learning on my own. I seem to be writing way too much code for simple exercises. I just finished one where all they wanted was to convert your change into a total dollar amount. I went ahead and created a method for each coin. For instance, quarterToDollar(), dimeToDollar() etc. When I looked up the answer they did it all in one line of code

dollars = (0.25 * quarters) + (0.10 * dimes)
+ (0.05 * nickles) + (0.01 * pennies);

Does every new programmer run into this or am I making things harder than they have to be?

Member Avatar for iamthwee

It doesn't matter. You learn how to minimize your code later.

At the moment the most important part is understanding how you got there.

:-|Hi all

Hi! :)

Does every new programmer run into this or am I making things harder than they have to be?

There are about as many solutions as there are new programmers. That alone should make you feel better, but don't forget that size and quality are completely independent code metrics. Just because someone came up with a one liner doesn't mean it's somehow better than your code that does the same thing with a hundred lines.

Java's a good start.
After a while, but before you get comfortable with any language, I recommend you check out Lisp.

Lisp is pretty much the language for multiple solutions for any given problem - not to mention, it's great for writing minimal code with the least amount of effort provided.

The main reason I switched from writing my applications primarily in Java to primarily in Lisp, is because I, too, found myself writing far too much code for the simplest tasks. I have come under the impression it's just the way Java is, but then again, I could be wrong.

more or less... I know coz i did too....
But hey... guess what??
Java is also known as the most hardest language to master....
so, you should give urself some credit for even have the guts to learn....

Java isn't the hardest language to master by far.
In fact the core language is quite easy.

If you want hard, think C or Assembler.

Programming any language though is like playing the guitar. It's easy to learn for most people, but very hard to learn well.

Thank you all for replying. As Java is my first language to learn, I'll hold off trying other languages for now. Thank you for the advice on LISP though, I'll keep it on the back burner for later consideration.

noone uses lisp except some university departments, it's a non-language if you want to have any serious work in the industry.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.