Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

how to improve my program code ?

 
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 ]
 
author
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 ]
 
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic