Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. Java
  4. Best Practice?

Best Practice?

Scheduled Pinned Locked Moved Java
questiondiscussion
3 Posts 2 Posters 13 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    MallardsReach
    wrote on last edited by
    #1

    I have created a method

    void getSecond(int secondNum)

    and in each of my radio buttons I have the following two pieces of code to return a number to the method both work fine but just wondered which is better practice? First

    getSecond(11);

    Second

       getSecond(Integer.parseInt(times12.getName()));
    
    L 1 Reply Last reply
    0
    • M MallardsReach

      I have created a method

      void getSecond(int secondNum)

      and in each of my radio buttons I have the following two pieces of code to return a number to the method both work fine but just wondered which is better practice? First

      getSecond(11);

      Second

         getSecond(Integer.parseInt(times12.getName()));
      
      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      There is no "better"; and if you can't explain how the statements differ, then the answer is "11", or "42".

      Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^] "If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.

      M 1 Reply Last reply
      0
      • L Lost User

        There is no "better"; and if you can't explain how the statements differ, then the answer is "11", or "42".

        Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^] "If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.

        M Offline
        M Offline
        MallardsReach
        wrote on last edited by
        #3

        Thanks for the reply Eddy, Glad to hear there is no 'Better' that's good to know. Of course I can explain how they differ, both return a number to the method one returns the name of the radio button it refers to the other returns the number placed in the buttons event. So I will use the one that returns the name of the button as it can eliminate the mistake of returning a number for a different button. But as there is no 'Better' way, then I guess it's how ever the programmer feels on the day.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups