make my code more efficient

DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: make my code more efficient

  1. #1
    Join Date
    Jul 2005

    make my code more efficient


    I coded an application and in the application I have this code:
    	public void testAtHighHealthRisk(HealthRiskCalculator calc) {
    		System.out.println("\nTesting atHighHealthRisk");
    		// TODO: replace the following line with testing of calc.atHighHealthRisk( )
    		//System.out.println("no testing yet.");
    		System.out.println(calc.atHighHealthRisk(26, 60));
    	public void testAtMediumHealthRisk(HealthRiskCalculator calc) {
    		System.out.println("\nTesting atMediumHealthRisk");
    		// TODO: replace the following line with testing of calc.atMediumHealthRisk( )
    		//System.out.println("no testing yet.");
    	public void testOutputAllPatientInfo(HealthRiskCalculator calc) {
    		System.out.println("\nTesting outputAllPatientInfo");
    		// TODO: after implementing outputAllPatientInfo:
    		// comment out the next line and remove the comments from the following block of code
    		//System.out.println("no testing yet.\n");
    Can someone give me advise how to be more efficient.

    Thanks to anyone who helps.


  2. #2
    Join Date
    Aug 2005
    Most of the code is println statements. Could you paste the rest of the code. That is where the real work is being done I believe. That code is what has to be optimized.

    For more help,

  3. #3
    Join Date
    Sep 2005
    That actually looks fine. If you want to condense the three methods into one, you could add an enumerated constant to your HealthRiskCalculator class that tells what level of risk it is and then inside your consolidated method have a switch statement that performs different operations depending on the health risk level of the HealthRiskCalculator. This would not be as time efficient as having three separate methods, but it would reduce code make it a little more object oriented.

  4. #4
    Join Date
    Jul 2005
    Thanx a bunch guys.

Similar Threads

  1. Control Arrays in VB.NET
    By Gary Nelson in forum .NET
    Replies: 277
    Last Post: 10-01-2003, 12:00 AM
  2. VS.Net and Code Behind
    By Chaitanya Marvici in forum ASP.NET
    Replies: 6
    Last Post: 07-21-2003, 09:15 AM
  3. Code security
    By Rob Teixeira in forum .NET
    Replies: 5
    Last Post: 11-27-2001, 06:12 PM
  4. Brain Washing
    By Danny Bowman in forum .NET
    Replies: 152
    Last Post: 09-13-2001, 07:23 AM
  5. Replies: 90
    Last Post: 04-17-2001, 12:45 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center