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

Hybrid View

  1. #1
    Join Date
    Jul 2005
    Posts
    7

    make my code more efficient

    Hi,

    I coded an application and in the application I have this code:
    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.");
    		System.out.println(calc.atMediumHealthRisk(15,55));
    	}
    
    
    	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");
    		
    		calc.outputAllPatientInfo();
    		
    	}{
    Can someone give me advise how to be more efficient.

    Thanks to anyone who helps.

    Daisy

  2. #2
    Join Date
    Aug 2005
    Posts
    17
    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, www.NeedProgrammingHelp.com

  3. #3
    Join Date
    Sep 2005
    Posts
    10
    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
    Posts
    7
    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, 01:00 AM
  2. VS.Net and Code Behind
    By Chaitanya Marvici in forum ASP.NET
    Replies: 6
    Last Post: 07-21-2003, 10:15 AM
  3. Code security
    By Rob Teixeira in forum .NET
    Replies: 5
    Last Post: 11-27-2001, 07:12 PM
  4. Brain Washing
    By Danny Bowman in forum .NET
    Replies: 152
    Last Post: 09-13-2001, 08:23 AM
  5. Replies: 90
    Last Post: 04-17-2001, 01: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
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

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