Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to improve my program code ?

 
Alvin chew
Ranch Hand
Posts: 834
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi, good day, can anyone give me some ideas how to i improve my program, should i have few more classes rather than just keep all my code in one class ? thanks in advance for viewing and answering



[Please type "&lt;td>" instead of "<td>", -- the latter breaks the post ]
[ November 28, 2004: Message edited by: Mapraputa Is ]
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, you should definitely break it into more classes or into more methods.

A good starting point might be to go through a list of code smells and think whether some of those are present in your code (and then fix them, of course).
[ November 28, 2004: Message edited by: Lasse Koskela ]
 
Gerald Davis
Ranch Hand
Posts: 872
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would basically say the same as the other dude; break up methods into smaller ones.

The code between the case statements basically do the same thing, so make them into static method that returns new NewCompanyFrm object, you case statements will look like this.

case 2:
{
System.out.println("choose 2");
int[] alist = [1,2,4,5,7,8,10,11,13,14,16] //however arrays are implemented
arr.add(funcNewCompanyform(alist);
}break;

You code seems very complicated, have you looked for a better way of doing this. Could PHP or JSP help you; the mixing of HTML and source code makes changing HTML a pain. If you must use Java this way, maybe there are simple librarys on Internet that could hide the complication of ODBC database access to simplify the code for you.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic