Thread: Java - need some help

Page 2 of 2 FirstFirst 12
Results 11 to 13 of 13
  1. #11  
    Ex Rune-Scaper

    Join Date
    Jun 2008
    Posts
    3,534
    Thanks given
    457
    Thanks received
    1,257
    Rep Power
    990
    Attached image
    Reply With Quote  
     

  2. #12  
    fumant viriditas quotidiana

    saifix's Avatar
    Join Date
    Feb 2009
    Age
    30
    Posts
    1,237
    Thanks given
    275
    Thanks received
    957
    Rep Power
    3304
    static code is bad because dependency injection and unit testing.

    simple static utility methods (e.g., a deterministic function which runs some calculation and doesn't access external resrources) are fine. otherwise, they're really not.

    edit: contrary to what Swiffy said and backing up what HackerHearts said, static methods are (most of the time) bad.
    "Im so bluezd out of my box.
    Im so fkd i canr even sens makeas Smoke blunt 420hash e tizday" - A legendary guy (1993 - 2015)
    Quote Originally Posted by nmopal View Post
    I will be creating a grimy dubstep song using these lyrics and vocaloid please prepare your bodies
    Reply With Quote  
     

  3. #13  
    ???

    funkE's Avatar
    Join Date
    Feb 2008
    Posts
    2,612
    Thanks given
    255
    Thanks received
    989
    Rep Power
    1366
    Quote Originally Posted by saifix View Post
    static code is bad because dependency injection and unit testing.

    simple static utility methods (e.g., a deterministic function which runs some calculation and doesn't access external resrources) are fine. otherwise, they're really not.

    edit: contrary to what Swiffy said and backing up what HackerHearts said, static methods are (most of the time) bad.
    To follow up with a sort of example... if the method depends on state information of an instance of the same class, just make it a non-static method. Of course, if this method is used by other classes then go ahead and keep it static.

    Crazy example just so you (op) understand what I mean:

    Code:
    public int id = 0;
    
    // NO
    public static void setID(WhateverYourClassIs instance, int newID) {
        instance.id = newID;
    }
    that's ridiculous.

    Code:
    // YES
    public void setID(int newID) {
        id = newID;
    }

    As far as instances, I'd imagine you'd have something like a set of local entities relative to the instance. Quests, cutscenes, minigames, maybe the dorgeeshun tunnel?
    .
    Reply With Quote  
     

Page 2 of 2 FirstFirst 12

Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. Slayer.java, need some help.
    By xItsDanielx in forum Help
    Replies: 1
    Last Post: 01-19-2014, 06:52 PM
  2. Need some help with my Commands.Java class.
    By Mr Lennart in forum Help
    Replies: 8
    Last Post: 08-14-2011, 12:50 PM
  3. Need some help with my Commands.Java class.
    By Mr Lennart in forum Help
    Replies: 0
    Last Post: 08-13-2011, 10:31 PM
  4. Replies: 0
    Last Post: 04-23-2011, 07:12 PM
  5. need some help in client.java
    By lilchicken77 in forum Help
    Replies: 5
    Last Post: 02-25-2010, 09:34 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
  •