aspose file tools*
The moose likes Beginning Java and the fly likes Java programming like pro? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Java programming like pro?" Watch "Java programming like pro?" New topic
Author

Java programming like pro?

sahar eb
Ranch Hand

Joined: May 06, 2009
Posts: 38
Hi,
This might sound a little silly but I am going to start my first job as a JAVA developer and I need to be confident about this! So please bear with me! I start programming by C++ and then moved to JAVA. I developed an academic project for 3 years. Now I am going to be a java developer and dealing with industrial project. I am a little worried about my programming skills. I was able to code almost every thing that I have needed, but I think I have some mistakes in the way I code, Although I am not sure. I have listed them below. can you tell me as a professional weather they are bad habits or its fine to do these things in programming:

1) If the program gets complicated I will end up with a class including 1000 lines. Is that a mistake? Is it professional?
2) I do understand the meaning of OO and Interfaces and synchronization but I never happened to use them a lot? for OO some cases I used, for Interfaces Never used (in 3 years).
3)many times I look at other developers code and there are lots of classes and methods which each include just a couple of lines!. That is the Professional way to do it? or its just another method of coding?
4) Are there any kind of method to evaluate the quality of a code?
5) Are there any sources that can teach me how to program like a Pro?
6)Installing some tools like "CodePro Analytix" will help me or just make me depend on the tool itself?
7) Of course there are differences in programming an academic project and an industrial project. Is there any list of questions or Errors that may be helpful in my case?

Sorry, too long and too many questions.
Thank you sooooooo much for your help, in advance ! ;)
D. Ogranos
Ranch Hand

Joined: Feb 02, 2009
Posts: 214
I don't know so much about professional, but there are a few guidelines to follow to produce "good" code:
- don't go for "clever" code, instead go for easily readable, understandable code (-> maintainable!)
- refactor often: if a method/class grows in length, see if you can extract parts as methods, or if you can split classes
- follow the "one method/class, one purpose": a method/class should do one thing, not try to do everything

Google for "clean code" as one starting point for more ideas.

Also google for PMD and Checkstyle, these are tools for static code analysis. They can help you to evaluate and improve your code.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39773
    
  28
Very short methods are usually a good thing.
A class which contains only a few lines might be a subckass where it is only necessary to provide a constructor. This is an acceptable class in its own right:-
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 8176
    
  23

sahar eb wrote:1) If the program gets complicated I will end up with a class including 1000 lines. Is that a mistake? Is it professional?

Very possibly. A class should be as big as it needs to be. java.lang.String, for example, contains over 3,000 lines of code; and I'll bet it's the first class you ever learned about. At the same time, when developing you should always be asking yourself "do I need this?".

4) Are there any kind of method to evaluate the quality of a code?

Sure. Run your code by other programmers - or indeed, post it on a forum like this. We love trashing other people's work.

5) Are there any sources that can teach me how to program like a Pro?

Tons; but personally, I'd start with the Java tutorials. Once you're past the basics, I'd also advise getting this book. You may also find this article useful.

6)Installing some tools like "CodePro Analytix" will help me or just make me depend on the tool itself?

I suspect that the tool checks code correctness rather than quality. Any fool can write a program that works; only someone else can tell you how good it is (see above).

7) Of course there are differences in programming an academic project and an industrial project.

Actually, if you were taught well, there shouldn't be that big a difference.

HIH

Winston

Isn't it funny how there's always time and money enough to do it WRONG?
Articles by Winston can be found here
K. Tsang
Bartender

Joined: Sep 13, 2007
Posts: 2584
    
    9

Each company may have its own coding convention/style. The project may need to follow the client's coding style.

Yet long story short, aim for maintainable, easy to understand (think like junior programmer), document code (write comments) as you go along,

K. Tsang JavaRanch SCJP5 SCJD/OCM-JD OCPJP7 OCPWCD5 OCPBCD5
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39773
    
  28
I think a major difference between “academic” code and “industrial” code is that “academic” people trust their users and use far less of a defensive style. The “industrial” people assume every user is about to write rubbish in the input and include code to take care of that.

Of course “academic” people should teach prospective “industrial” people to write defensive code!
J. Kevin Robbins
Bartender

Joined: Dec 16, 2010
Posts: 1038
    
  13

sahar eb wrote:Hi,
This might sound a little silly but I am going to start my first job as a JAVA developer and I need to be confident about this!


This is normal. For the first few months in my first professional developer job, I wondered what the hell I had gotten myself into. I felt completely overwhelmed. If at all possible, find someone at the new job who will mentor you and help you get familiar with the environment and tools.

sahar eb wrote:
1) If the program gets complicated I will end up with a class including 1000 lines. Is that a mistake?


Opinions differ on this, but I would say probably. Anytime my classes run more than 200 lines or so, I step back and take a good, hard look at it to see if I can break it down into smaller classes. Sometimes I can, sometimes I can't, but it pays to consider it because large complicated classes are harder to maintain and unit test.

sahar eb wrote:
2) I do understand the meaning of OO and Interfaces and synchronization but I never happened to use them a lot? for OO some cases I used, for Interfaces Never used (in 3 years).

I would say this is a weakness that you need to address. Coding to interfaces is an important concept that you should learn to use.

sahar eb wrote:
3)many times I look at other developers code and there are lots of classes and methods which each include just a couple of lines!. That is the Professional way to do it? or its just another method of coding?

This gets back to my answer about unit testing and maintainability.

sahar eb wrote:
4) Are there any kind of method to evaluate the quality of a code?
5) Are there any sources that can teach me how to program like a Pro?

I haven't tried it yet, but I've heard good things about the Cattle Drive here on Javaranch.

I would also second the suggestion on the book Effective Java. It probably did more to improve my skills than any other single book I've read. And it's one that you can go back and read again once a year and learn something new every time.

Lots of luck in your new job!


"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." -- Ted Nelson
sahar eb
Ranch Hand

Joined: May 06, 2009
Posts: 38
hi guys,
thank you sooo much for all these replies and wishes. most of the comments were really helpful!
may be that is the problem. i never had an "academic" teacher and no one have ever looked at my code. I learned java and developed a fairly big project only by the help of java tutorial and this lovely forum. thanks to you guys!
I am still confused on when i should use Interfaces and stuff like this. i will read the sources and google on those suggestions and will come back to you!
thanks again!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java programming like pro?