This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Java in General and the fly likes How many lines of code on average for a small personal project? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "How many lines of code on average for a small personal project?" Watch "How many lines of code on average for a small personal project?" New topic
Author

How many lines of code on average for a small personal project?

Jason Hardaway
Greenhorn

Joined: Apr 11, 2011
Posts: 26

Hello ranchers, I was curious to know how many lines of code on average would be within a small personal project.

I know that it all depends on the type of project but I am currently looking for a rough estimate if it is possible.

I ask because my goal is to develop some small personal projects to place in my portfolio when potential employers/clients would like to see my work.

Thank you all in advance for your help.
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 6109
    
    6

Well, yes, it does depend, and it's totally subjective. Off the top of my head, I would arbitrarily say that a "small personal project" might typically have between 10 and 50 classes and between 500 and 5,000 lines of code.

That's the opinion of one random guy you don't know on the net. You may get a handful of others. What then? How does that help you? A potential employer isn't going to judge you based on the size of your "personal project" (that just sounds oh so wrong), nor will he read much of the code, if any.

Find something that interests you and work on it, and don't worry about the amount of code, or even if it's complete by the time you go interview. If I were interviewing you, to the extent that this came up at all, I would be more interested in why you chose the project, what architecture and design choices you made and why, what difficulties arose and how you handled them, if you used any technologies that we're using at my company, or at least something similar to them, etc.
dennis deems
Ranch Hand

Joined: Mar 12, 2011
Posts: 808
If I were reviewing someone's code portfolio, I wouldn't count lines. I would look for: a well-articulated, cohesive class hierarchy; strong encapsulation; focused methods that perform specific tasks; coding to interfaces; use of standard libraries, especially the Collections framework; and consistent formatting that adheres to one of the common Java conventions. Also, I would be interested in the author's approach to the problem at hand. How well do the class names and method signatures tell the story of the application?
Brian Burress
Ranch Hand

Joined: Jun 30, 2003
Posts: 122
A tangent to the original question which is just as subjective, but might help frame good coding practice. "How many lines of code is average or typical for a Class and/or method". There will be many opinions on the #s here, but where I would steer the answer toward is that if the lines of code become "too many" then you are likely doing too much in that class or method and need to look at breaking things up to be smaller such that you'll improve the ability to test that it works (simplify debugging, etc) and should foster better re-use by having smaller, simpler, focused (atomic, fine-grained or granualar) logic that can be called on rather than a massive (coarse grained) set of logic.

The above will still depend on what problem(s) your project is trying to solve, but may help guide.

While solid design and thinking up front is always a good idea in my opinion, for a personal project, you'll have a lot more freedom to refactor. As you code you are likely to see things that make more sense if they were "abstracted" from the code base or put into a utility class and so forth.

Just my one cent worth -- the govt. took the other penny ;)
Jason Hardaway
Greenhorn

Joined: Apr 11, 2011
Posts: 26

Jeff Verdegan wrote: A potential employer isn't going to judge you based on the size of your "personal project" (that just sounds oh so wrong), nor will he read much of the code, if any.

Thanks, Jeff. That took a weight off of my shoulders. I had a bad experience in the past with some "recruiters" who said I did not have any "professional experience".
Jeff Verdegan wrote: Find something that interests you and work on it, and don't worry about the amount of code, or even if it's complete by the time you go interview. If I were interviewing you, to the extent that this came up at all, I would be more interested in why you chose the project, what architecture and design choices you made and why, what difficulties arose and how you handled them, if you used any technologies that we're using at my company, or at least something similar to them, etc.

I will definitely take all of this information into consideration.

Dennis Deems wrote:If I were reviewing someone's code portfolio, I wouldn't count lines. I would look for: a well-articulated, cohesive class hierarchy; strong encapsulation; focused methods that perform specific tasks; coding to interfaces; use of standard libraries, especially the Collections framework; and consistent formatting that adheres to one of the common Java conventions. Also, I would be interested in the author's approach to the problem at hand. How well do the class names and method signatures tell the story of the application?

Wow This is exactly what I would hope that all my projects would have. Thanks.

Brian Burress wrote:There will be many opinions on the #s here, but where I would steer the answer toward is that if the lines of code become "too many" then you are likely doing too much in that class or method and need to look at breaking things up to be smaller such that you'll improve the ability to test that it works (simplify debugging, etc) and should foster better re-use by having smaller, simpler, focused (atomic, fine-grained or granualar) logic that can be called on rather than a massive (coarse grained) set of logic.

I never thought of the code having too many lines but it does make sense that more is not necessarily better. Thank you for this.

Brian Burress wrote:Just my one cent worth -- the govt. took the other penny ;)

They wanted both of my pennies but I hid one of them away...but don't tell anyone. LOL
Anyway, thanks everyone for your awesome feedback.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39478
    
  28
Brian Burress wrote: . . . the govt. took the other penny ;)
I had the same problem; they worked out I should pay £ijk of tax, so I clicked the button to reduce the on-account payment to 0 on the grounds that I had actually paid £(ijk + 5) tax.

You can navigate to the “beginning Java” forum and see lots of examples where people write 50-line long main methods. You go through them and wonder who on earth is teaching them.
Jason Hardaway
Greenhorn

Joined: Apr 11, 2011
Posts: 26

Campbell Ritchie wrote:
You can navigate to the “beginning Java” forum and see lots of examples where people write 50-line long main methods. You go through them and wonder who on earth is teaching them.

I did notice that and I imagine that some of them are being taught by the internet. Me personally, I like it old school...I use books. And of course, JavaRanch but what do I know.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39478
    
  28
Jason Hardaway wrote: . . . being taught by the internet. . . .
And have nobody to show them that what they have picked up is rubbish. That would explain some of them.
Brian Burress
Ranch Hand

Joined: Jun 30, 2003
Posts: 122
I guess you also need to consider the background of the developer. When I first got into Java, I was on a team who were not only mostly newbies but also converting over from Mainframe/COBOL. Shortly into the project, I recall one of the members observing that a particular JSP had way to much code in it and observed that it looked like one of our COBOL programs. Of course, I also recall one of the members of the team, OO seasoned, worked hard to make folks aware to watch for re-use opportunities, consider helper classes, etc. I fortunately had enough OO background mainly due to my Comp Sci degree that it did not take too long to shake off the cobwebs in conjunction with said seasoned member and understand how to with Java the way it should be....
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How many lines of code on average for a small personal project?