Search Results

Search found 5 results on 1 pages for 'skippy'.

Page 1/1 | 1 

  • Validating data to nest if or not within try and catch

    - by Skippy
    I am validating data, in this case I want one of three ints. I am asking this question, as it is the fundamental principle I'm interested in. This is a basic example, but I am developing best practices now, so when things become more complicated later, I am better equipped to manage them. Is it preferable to have the try and catch followed by the condition: public static int getProcType() { try { procType = getIntInput("Enter procedure type -\n" + " 1 for Exploratory,\n" + " 2 for Reconstructive, \n" + "3 for Follow up: \n"); } catch (NumberFormatException ex) { System.out.println("Error! Enter a valid option!"); getProcType(); } if (procType == 1 || procType == 2 || procType == 3) { hrlyRate = hrlyRate(procType); procedure = procedure(procType); } else { System.out.println("Error! Enter a valid option!"); getProcType(); } return procType; } Or is it better to put the if within the try and catch? public static int getProcType() { try { procType = getIntInput("Enter procedure type -\n" + " 1 for Exploratory,\n" + " 2 for Reconstructive, \n" + "3 for Follow up: \n"); if (procType == 1 || procType == 2 || procType == 3) { hrlyRate = hrlyRate(procType); procedure = procedure(procType); } else { System.out.println("Error! Enter a valid option!"); getProcType(); } } catch (NumberFormatException ex) { System.out.println("Error! Enter a valid option!"); getProcType(); } return procType; } I am thinking the if within the try, may be quicker, but also may be clumsy. Which would be better, as my programming becomes more advanced?

    Read the article

  • Whether to separate out methods or not

    - by Skippy
    I am new to java and want to learn best coding practices and understand why one method is better than another, in terms of efficiency and as the coding becomes more complicated. This is just an example, but I can take the principles from here to apply elsewhere. I have need an option to display stuff, and have put the method stuff separately from the method to ask if the user wants to display the stuff, as stuff has a lot of lines of code. For readability I have done this: public static void displayStuff () { String input = getInput ("Display stuff? Y/N \n"); if (input..equalsIgnoreCase ("Y")) { stuff (); } else if (input.equalsIgnoreCase ("N")) { //quit program } else { //throw error System.out.print("Error! Enter Y or N: \n"); } } private static String stuff () { //to lots of things here return stuff (); } Or public static void displayStuff () { String input = getInput ("Display stuff? Y/N \n"); if (input..equalsIgnoreCase ("Y")) { //to lots of things here stuff; } else if (input.equalsIgnoreCase ("N")) { //quit program } else { //throw error System.out.print("Error! Enter Y or N: \n"); } } Is it better to keep them together and why? Also, should the second method be private or public, if I am asking for data within the class? I am not sure if this is on topic for here. please advise.

    Read the article

  • The better way to ask for input?

    - by Skippy
    I am wondering which is the best way to go with java code. I need to create a class with simple prompts for input.. I have tried using both classes and cannot work out the particular benefits for each. Is this because I am still in the early stages of programming or are there situations that will occur as it becomes more complex?? import java.util.Scanner; public class myClass { Scanner stdin = new Scanner(System.in); public String getInput(String prompt) { System.out.print(prompt); return stdin.nextLine(); } ... or import java.io.*; public class myClass { public static void main(String[] args) throws IOException { BufferedReader stdin = new BufferedReader (new InputStreamReader (System.in)); System.out.print("Input something: "); String name = stdin.readLine(); I know these examples are showing different methods within these classes, but thought this might serve well for the discussion. I'm really not sure which site is the best to ask this on.

    Read the article

  • Move already (i.e. not new) completed files in rtorrent

    - by Skippy le Grand Gourou
    I've been using rtorrent for a while with a single directory. Now I figured out it was possible to use different directories and even to move completed downloads elsewhere, so according to the rtorrent wiki I edited my .rtorrent.rc as follow : # Download directory directory = /Medias/torrents/ # Watching directories schedule = watch_directory_1,5,60,"load_start=/path/to/dl/dir1/*.torrent,d.set_custom1=/path/to/done/dir1" schedule = watch_directory_2,5,60,"load_start=/path/to/dl/dir2/*.torrent,d.set_custom1=/path/to/done/dir2" # On completion, move the torrent to the directory from custom1. system.method.set_key = event.download.finished,move_complete,"d.set_directory=$d.get_custom1= ;execute=mv,-u,$d.get_base_path=,$d.get_custom1=" It seems to work for new torrents. However I have a bunch of completed files I have already downloaded before to split directories, and for them it does not work : if I delete their file in the session directory, rtorrent will check the hash but won't move them, and if I move them by myself rtorrent won't see them and will try to redownload them. So how can I tell rtorrent either to move them or that they are in another directory ? Thanks.

    Read the article

  • Are you ready to take a walk in the clouds?

    - by Steve Loethen
    Cloud computing is here, whether we want it or not.  When I say "a walk in the clouds” I am not talking about a pleasant romantic comedy, but a real alternative to hosting applications on-premise.  For years we have had the power to host our web sites on remote systems.  Sure, challenges existed.  Mostly web sites.  I could, with a few clicks, create a account at a myriad of web host sites, put my site in the hands of a remote hosting company, and boom, I was a site on the internet.  But choices, power, and management was limited. Now, we have a set of services to let us approach and power and control we love, but with scalability of the data center.  My personal web site is hosted on a laptop running hyperV in my basement.  I have to manage the machine, patch it, make sure it is powered up.  This is fine for the “hello, this is my dog skippy site” that I maintain. If the football pool I run has an issue, one of the 10 users I have calls or emails me and I go check it out.  All is well. But this falls well below the needs of even the simplest of enterprises.  A business needs a stronger datacenter, a better pipe to the world.  Do I really want to base my business on a dynamic dns and a dsl line from the local phone company? Cloud computing gives us most of what I value (control, a db of my own, updating my site from Visual Studio). Come learn how this technology can transform your business.  If you are a Microsoft shop, or are interested in Microsoft in the cloud, on April 8 and 9, a 2 day free Azure training class is being conducted in Kansas City.  http://www.azurebootcamp.com/city/kansascity Hope to see you there.  If you come, make sure you look me up.

    Read the article

1