File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes OO, Patterns, UML and Refactoring and the fly likes how to improve my program code ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "how to improve my program code ?" Watch "how to improve my program code ?" New topic

how to improve my program code ?

Alvin chew
Ranch Hand

Joined: Jan 08, 2004
Posts: 834
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

Joined: Jan 23, 2002
Posts: 11962
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 ]

Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Gerald Davis
Ranch Hand

Joined: May 15, 2002
Posts: 872
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

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.
I agree. Here's the link:
subject: how to improve my program code ?
It's not a secret anymore!