Java Experts: Will you check my 'sample code' for my interview tomorrow?

Discussion in 'OT Technology' started by zanyspy_dude, Feb 3, 2009.

  1. zanyspy_dude

    zanyspy_dude King of teh n00bz

    Joined:
    Aug 29, 2002
    Messages:
    4,473
    Likes Received:
    0
    Location:
    Indianapolis, IN
    They wanted a sample of java code from me so I whipped this up. Let me know your thoughts.

    I'd like to add some threading in to show that I can do that, but I"m not sure that it would make any sense. Maybe have a thread for each check for the winner? Seems overly complex though...

    Runs as an applet. www.davidmcoe.com/FourInARow.jar

    Do you see anything that could be improved? Thank you!

    Edit:

    Get it here as jar www.davidmcoe.com/FourInARow.jar
    or here as zip www.davidmcoe.com/FourInARow.zip
     
    Last edited: Feb 3, 2009
  2. GOGZILLA

    GOGZILLA Double-Uranium Member

    Joined:
    Jan 16, 2003
    Messages:
    10,760
    Likes Received:
    3
    Location:
    Plantation, FL
    looks pretty good. im not a java programmer but pretty easy to read and seems well put together. dont do anything more complicated than necessary, thats a habit you don't want to show on the interview. if you feel insecure about the program not being more complicated think of something more complex that would actually need threading to demonstrate your knowledge. also theres no comments but its a connect four game and all the functions, variables are labeled pretty clearly so im not sure theres any need. maybe just a big general one in the main file.
     
  3. ge0

    ge0 New Member

    Joined:
    Oct 31, 2005
    Messages:
    8,398
    Likes Received:
    0
    Location:
    JERSEY
    first of all... APPLETS = depricated java technology. If you want to show off, make a Client and Server application. Its pretty easy and it will show you know how to use the Java.net tools.
     
  4. zanyspy_dude

    zanyspy_dude King of teh n00bz

    Joined:
    Aug 29, 2002
    Messages:
    4,473
    Likes Received:
    0
    Location:
    Indianapolis, IN
    It was a surprise. I only had a bit of time to get it done. You think like a chat program would be more impressive?
     
  5. antiyou

    antiyou OT Supporter

    Joined:
    Jul 13, 2005
    Messages:
    25,295
    Likes Received:
    0
    Location:
    in ur base
    I just looked at the FourInARow.java file and see that your constants aren't declared as final :ugh:
     
  6. antiyou

    antiyou OT Supporter

    Joined:
    Jul 13, 2005
    Messages:
    25,295
    Likes Received:
    0
    Location:
    in ur base
    and as a coding practice in general I think all methods should have at most one exit point.
     
  7. zanyspy_dude

    zanyspy_dude King of teh n00bz

    Joined:
    Aug 29, 2002
    Messages:
    4,473
    Likes Received:
    0
    Location:
    Indianapolis, IN
    woops, totally missed that. Thanks! What do you mean about one exit point?
     
  8. ge0

    ge0 New Member

    Joined:
    Oct 31, 2005
    Messages:
    8,398
    Likes Received:
    0
    Location:
    JERSEY
    means a return at the very end probably. yeh a chat program would be HUGE
     
  9. antiyou

    antiyou OT Supporter

    Joined:
    Jul 13, 2005
    Messages:
    25,295
    Likes Received:
    0
    Location:
    in ur base
    yeah defining a return variable and using conditions to determine a return value and not just returning each time a condition is met...
     
  10. zanyspy_dude

    zanyspy_dude King of teh n00bz

    Joined:
    Aug 29, 2002
    Messages:
    4,473
    Likes Received:
    0
    Location:
    Indianapolis, IN

    isn't it much faster to return rather than continue? Some of those returns are 'safty' so it doesn't check the entire board when it's found a problem...
     
  11. D1G1T4L

    D1G1T4L Active Member

    Joined:
    May 4, 2001
    Messages:
    16,489
    Likes Received:
    0
    Location:
    Bay Area
    that's considered a bad oo programming style..
    the only thing that should have more than 1 return point is switches with breaks....
    this is not BASIC with goto with labels... :squint:
     
  12. Dwight Schrute

    Dwight Schrute New Member

    Joined:
    Oct 11, 2003
    Messages:
    8,616
    Likes Received:
    0
    1. Multiple exit points.

    2. Your code isn't commented / documented at all and is hard to read. You're really going to turn the company off if you can pump out lots of code but don't document it.
     
    Last edited: Feb 8, 2009
  13. zanyspy_dude

    zanyspy_dude King of teh n00bz

    Joined:
    Aug 29, 2002
    Messages:
    4,473
    Likes Received:
    0
    Location:
    Indianapolis, IN

    The version I have is fully commented. I didn't want to give everything away!

    What is the solution to multiple exit points? I just scan the entire puzzle anyway?
     
  14. red

    red New Member

    Joined:
    Jun 30, 2005
    Messages:
    87,095
    Likes Received:
    0
    Just as a piece of advice: first, I almost never use just a letter as a variable. Even in the rare cases that I do (which is usually a counter in a for loop), I'll use, for instance, 'ii' instead of 'i', because it's a lot easier to search for.
     

Share This Page