Results 1 to 3 of 3
  1. #1
    TimHuey is offline Member
    Join Date
    Aug 2009
    Posts
    50
    Rep Power
    0

    Default Use an internal Method or Make a class file?

    I have a simple math function that needs to be done several times in my program. When is it better to make it just a method to be called in the program and when is it better to make it a new class file to be included in the project? I am thinking that if its something you might like to use later in another program you would use a class. BUt is that the only logic for making that decision?

    Thanks, just basic low level java theory here. I'm trying to grasp the basics and good programming techniques for my foundation.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    For simple math functions, you may want to create a math library (a class) of static methods. While I abhor most static anything, if these are functions that take in parameters and return results, but don't have any persisting "state", then static methods may be the way to go. Think of Java's Math class as an example of the above.

  3. #3
    TimHuey is offline Member
    Join Date
    Aug 2009
    Posts
    50
    Rep Power
    0

Similar Threads

  1. Replies: 19
    Last Post: 11-27-2010, 12:31 AM
  2. how do i make java external/internal?
    By zoon81 in forum New To Java
    Replies: 2
    Last Post: 06-29-2009, 09:59 AM
  3. Replies: 4
    Last Post: 11-25-2008, 05:53 AM
  4. Replies: 29
    Last Post: 09-25-2008, 07:55 PM
  5. Calling a method on original class from created class
    By kpedersen in forum Advanced Java
    Replies: 4
    Last Post: 08-20-2008, 12:25 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
  •