Closed Thread
Results 1 to 7 of 7

Thread: Java Ideas

  1. #1
    Hunter100 is offline Programming Professional
    Join Date
    Feb 2010
    Location
    Australia
    Posts
    289
    Rep Power
    0

    Question Java Ideas

    Hi everyone,

    I just made my first Hello World program in Eclipse (literally 10 minutes ago). I didn't know any code other than

    Code:
    public class HelloWorld {
     public static void main(String[] args) {
     system.out.println("Hello World"); 
      //TODO Auto generated method stub
     }
    }
    So I wanted to know more code so I could have more ideas and do more things.

    Also, In the tutorial it said the names in Java are really long...do they really have to be? Coming from C++ my names are generally small.

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Location
    Advertising world
    Posts
    Many

     
  3. #2
    R3.RyozKidz Guest

    Re: Java Ideas

    then you should continue to follow the java tutorial ... good start ..~

  4. #3
    Sinipull's Avatar
    Sinipull is offline Programming Expert
    Join Date
    Jun 2009
    Location
    Tallinn, Estonia, Estonia
    Posts
    382
    Rep Power
    13

    Re: Java Ideas

    Also, In the tutorial it said the names in Java are really long...do they really have to be?
    Yes, In java names are long and they should be long as the name should describe what the Class/Method/Field does. For example it's okay to write a test for you program, that sounds like this:

    public void isDogBarkingWhenStrangerIsAtTheDoorAndImNotHome(){
    }

    this method name is very good, as it is self-documenting and describes everything it does.

    That's why IDE's are very recommended when writing java, as they have the autocomplete and spellchecking functions. in Eclipse you can have autocomplete, when pressing ctrl+space.

  5. #4
    Join Date
    Mar 2008
    Posts
    7,145
    Rep Power
    86

    Re: Java Ideas

    Generally though I don't like having really long names because you will have to retype them later. That is a long name and is probably too descriptive. I'd rather go with a less descriptive name and add comments to be more descriptive as to what the function does.

  6. #5
    Join Date
    Apr 2009
    Location
    Trapped in my own little world.
    Posts
    2,487
    Rep Power
    33

    Re: Java Ideas

    Quote Originally Posted by Sinipull View Post
    Yes, In java names are long and they should be long as the name should describe what the Class/Method/Field does. For example it's okay to write a test for you program, that sounds like this:

    public void isDogBarkingWhenStrangerIsAtTheDoorAndImNotHome(){
    }

    this method name is very good, as it is self-documenting and describes everything it does.

    That's why IDE's are very recommended when writing java, as they have the autocomplete and spellchecking functions. in Eclipse you can have autocomplete, when pressing ctrl+space.
    I disagree, they do not have to be that long and I do not think they should.

    Yes some names are long... especially function calls since they look like "System.out.println" but that is more than one name and might be difficult to remember. I would not recommend using long names as you will forget them easily.

  7. #6
    Sinipull's Avatar
    Sinipull is offline Programming Expert
    Join Date
    Jun 2009
    Location
    Tallinn, Estonia, Estonia
    Posts
    382
    Rep Power
    13

    Re: Java Ideas

    Perhaps i explained myself a little bit wrong.
    The above example was a test-method(JUnit) name, as i said earlier(And probably a bad example to bring here), it should never be called manually anyway, and needs no additional documentation. I would never name a normal method that long myself either.
    When it's possible, it is always good idea to name the method as short as possible, but there is nothing wrong with long names if they justify themselves. Usually there's no need to have over two or three words to describe the method in a name. but there's no need to shorten the words if more words are used.

  8. #7
    Join Date
    Jul 2009
    Location
    Santa Clarita, CA
    Posts
    2,111
    Blog Entries
    47
    Rep Power
    31

    Re: Java Ideas

    In one sense, I'm going ot have to side with Sinipull on this one. Longer names are generally better than shorter names, despite the need to perform more typing to write one out if you're not using an IDE. However, I think it's far more important that methods be simple rather than descriptive. They should perform one task, or get a single piece of information. This task can in itself be very complicated (for example, splitting a string), but regardless it should be simple for a user to understand what's going on with two or three words. As such, instead of this:
    Code:
    public void isDogBarkingWhenStrangerIsAtTheDoorAndImNotHome(){
    }
    I'd prefer this:
    Code:
    public bool isDogBarking() {
    }
    public bool isStrangerAtDoor() {
    }
    public bool amIHome() {
    }
    //...
    if (status.isDogBarking && status.isStrangerAtDoor() && !status.amIHome()) {
        // Do something...
    }
    This is because the client can customize different conditions and utilize the code within the object better. I think it more important that objects be versatile than anything else, though.
    Wow I changed my sig!

Closed Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Need help/ideas with java app
    By Serialcek in forum Java Help
    Replies: 3
    Last Post: 10-26-2011, 12:59 PM
  2. Java Game Ideas
    By lor in forum Java Help
    Replies: 9
    Last Post: 08-30-2010, 12:49 AM
  3. Need ideas on java grid
    By code0 in forum Java Help
    Replies: 0
    Last Post: 10-24-2008, 11:42 AM
  4. Ideas for PPC
    By TcM in forum C# Programming
    Replies: 14
    Last Post: 06-14-2008, 11:59 AM
  5. java project ideas
    By trolls1234 in forum Java Help
    Replies: 2
    Last Post: 09-13-2007, 09:11 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts