File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java programming contest

 
Jigar Gandhi
Greenhorn
Posts: 20
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We are conducting a java programming competition and we are going to eliminate the participants on the basis of number of lines of code.
But we have a problem how to count the number of lines.
 
Joe Ess
Bartender
Posts: 9214
9
Linux Mac OS X Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are serious, I think you are barking up the wrong tree because lines of code are not an indication of correctness or quality of code (unless, of course, short/long code is the purpose of the exercise).
In any case, how about showing some effort? Do you know how to read files? Keep a counter? What exactly don't you need help with?
 
Jesus Angeles
Ranch Hand
Posts: 2068
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What you might want to do is create a program similar to a tokenizer/syntax analyzer that:

0) Given an input file (the program you are counting)
1) eliminate comments
2) count constructs like method declarations, blocks like for-loop, semicolons that terminates statements (e.g. those inside for loop are not counted)

You would therefore need to learn all constructs allowed in your competition, e.g. inner classes.
 
Jigar Gandhi
Greenhorn
Posts: 20
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for the reply it helped but my friend Joe Ess says that the quality of the program does not depend upon the lines of code. then being a student and conducting competition for students then tell me the unbiased method to judge a code( actually we can judge but we do not want to get in argument with the participants who are hungry for the prize).
Is there any standard method.
 
Jesus Angeles
Ranch Hand
Posts: 2068
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by JIGAR GANDHI:
Thank you for the reply it helped but my friend Joe Ess says that the quality of the program does not depend upon the lines of code. then being a student and conducting competition for students then tell me the unbiased method to judge a code( actually we can judge but we do not want to get in argument with the participants who are hungry for the prize).
Is there any standard method.


Yes, there are good ones you can do.

Here's one.

Require the solution to be in a format, such that, you can automatically test his solution by passing it to you test program.

If all of them have correct solutions, then you can base it on who finished first.

You can also specify which java statements, classes, etc. are allowed.

For example, the solution must 'implement' an 'interface' that you provided.

You simply create a test program that tests his solution, as you know the interface. Test it on all scenarios to see that his solution is correct.
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just in case you're curious anyway about the NCSS (non-commenting source statements) of a piece of code -which is really what you want to count, not LOC-, look for the JavaNCSS library.
 
Joe Ess
Bartender
Posts: 9214
9
Linux Mac OS X Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The ACM sponsors programming contests for college students. You could look at their rules and problem sets and see if they are a good match. They use a setup similar to what Jesus proposes and the winner is the team that solves the most problems in the given time (ties are broken by times).
 
Jigar Gandhi
Greenhorn
Posts: 20
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The method of counting lines through JavaNCSS library is a bit complicated you people being infallible software programmers since ages may be doing something more easier to count the number of lines in your project. Can I know what you people do to count the non commenting source statements. If using a tool can i get to access the tool or is their any easy way to count the lines by any java API classes .
please help!!
 
Jesus Angeles
Ranch Hand
Posts: 2068
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The advice given to you above, from different members, already constitute the simplest, most efficient, and realistic clues on how you can proceed on your problem.
 
Suraj Chandran
Ranch Hand
Posts: 53
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you really shouldn't conduct the exam.
 
Rob Spoor
Sheriff
Pie
Posts: 20381
46
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you really shouldn't wake the zombies.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic