4 Replies - 877 Views - Last Post: 06 March 2013 - 05:37 PM Rate Topic: -----

#1 tieugiang94  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 160
  • Joined: 07-December 11

What should i learn to write a nice java source code ?

Posted 03 March 2013 - 10:34 AM

I'm new to Java programming. With a basic background knowleged.
What should i learn to organize Java source code ? ( In english it maybe "design pattern" Oops, I speak English not well.

I have read something on Google ( DAO, BOL..v.)
Is This A Good Question/Topic? 0
  • +

Replies To: What should i learn to write a nice java source code ?

#2 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5678
  • View blog
  • Posts: 12,216
  • Joined: 02-June 10

Re: What should i learn to write a nice java source code ?

Posted 03 March 2013 - 11:55 AM

*
POPULAR

We learn more by doing than reading theory.
Patterns are nice and all but...
Build... build... build.

The more you build, the more you will learn through experience why you don't do certain things because they lead to dead ends.

But programming is such a general term that this question is hard to answer. What you do for web programming is not what you do for making programs that read underwater seismic sensors, and that's different than coding for mobile apps, and that's different than coding for business stock report apps.

At these early stages don't worry so much about patterns as learning the language itself. Right now that's more than enough to have to learn.
Was This Post Helpful? 5
  • +
  • -

#3 baavgai  Icon User is online

  • Dreaming Coder
  • member icon

Reputation: 5941
  • View blog
  • Posts: 12,870
  • Joined: 16-October 07

Re: What should i learn to write a nice java source code ?

Posted 03 March 2013 - 01:16 PM

*
POPULAR

I agree with tlhIn`toq 100%.

Design patterns, and even object oriented design in general, are really just abstractions until you've written enough code. Once you start writing a large program you'll be in a position to say, "Damn, this is getting really complex, time to step back and clean this up."

If you wish to follow any of the development guru's advice out there it's this: refactor, refactor, refactor.

Too many newbie programmers are happy to simply have the program run. That's not good enough. How can it run better? Can extra crap be removed? Are things done just to get it to work messy or unclear? Will even you be able to tell what's going on if you look at your code six months from now?

Do your best to write the cleanest code possible. Don't settle for only "it runs." Do this and you'll be fine.
Was This Post Helpful? 5
  • +
  • -

#4 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10821
  • View blog
  • Posts: 40,346
  • Joined: 27-December 08

Re: What should i learn to write a nice java source code ?

Posted 03 March 2013 - 04:24 PM

This really isn't an advanced discussion topic. Moved to Java.

Check out my thread Getting Better at Programming Java.
Was This Post Helpful? 2
  • +
  • -

#5 cfoley  Icon User is offline

  • Cabbage
  • member icon

Reputation: 2069
  • View blog
  • Posts: 4,307
  • Joined: 11-December 07

Re: What should i learn to write a nice java source code ?

Posted 06 March 2013 - 05:37 PM

The advice above is by far the most important. What I'm about to say is the icing on the cake.

Run FindBugs on your code. It will point out a bunch of bad programming practices and potential problems with your code. The first time I ran it on a large project of mine, it caught hundreds of problems. These days, it hardly catches anything. If you use it, it's important to take its advice with a pinch of salt. A static code analyser can never be perfect.
http://findbugs.sourceforge.net/

The book Effective Java has a lot of advice on Java best practices. Although it's Java-specific, much of the advice transfers well to any object orientated language. It's a bit long in the tooth and some of the advice is out of date but for the most part it's spot on.
http://www.amazon.co...h/dp/0321356683

Refactoring: Improving the Design of Existing Code is an excellent insight into restructuring your code in a disciplined way that helps avoid breaking things. This book has helped me a lot but I'm hesitant to recommend it to someone who describes themselves as having basic knowledge.
http://www.amazon.co...e/dp/0201485672

Clean Code: A Handbook of Agile Software Craftsmanship is utterly brilliant. It turned me into a much better programmer overnight. It has excellent advice on everything from choosing variable names, when and how to comment to method design, class design and even complex topics like concurrency. I look back at the code I wrote before I read this book and cringe!
http://www.amazon.co...ords=clean+code

I've presented these in the order I used or read them. If you want to try them out, maybe start with FindBugs. It's free. Of the rest, I might recommend starting with Clean Code. It's got something for beginners and experts alike. Code Complete is another popular book but I haven't read it so can't recommend it.

Remember, the most important thing is to practice writing code.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1