Skip to content

Noobness Revealed

Post examples of Noobness in this thread.

Example 1: Not understand how to use NOT logic (aka, the ‘!’)

if ((expDate!=null && expDate.isPast(null)) ||
(effDate!=null && effDate.isFuture(null)) ||
id.getRank() == null) {
//Do Nothing
}
else
return id;

Example 2: Hard-coding Array indices

if(person[i][3].equals("Sam") && person[i][1].equals("17"))
   name = person[i][3] + " " + person[i][4] + " " person[i][5];

This is just so much more readable than:

if(person[i][FIRST_NAME].equals("Sam") && person[i][AGE].equals("17"))
   name = person[i][FIRST_NAME] + " " + person[i][MIDDLE_NAME] + " " person[i][LAST_NAME];

Example 3: Excessive or unnecessary imports

import java.lang.*;
import java.io.*;
import java.awt.*;
import javax.sql.*;

public class MyGreatClass {
   public static void main(String[] args) {
      System.out.println("My first Java class is so great!  I am such a noob!");
      System.exit(0);

   }
}
[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

One Comment

  1. jeff wrote:

    I personally hate long nested conditional statements:

    if(conditionOne()){
    
    //  Write 100 lines of code here
      if(conditionTwo()){
    // add 100 more lines of code
      } else {
    // add 100 more lines of code
        if(conditionThree()) {
         [...]
        } else {
         [...]
        }
      }
    } else {
    
    [...]
    
    }
    

    And prefer either achieving the same effect with methods instead of the long code blocks, or where possible using a switch statement for clarity:

    if(conditionOne()){
    
      methodToDoConditionOneWork();
    
      if(conditionTwo()){
        methodForConditionTwo();
      } else {
        methodForConditionTwoB();
        if(conditionThree()) {
         [...]
        } else {
         [...]
        }
      }
    } else {
    
    [...]
    
    }
    
    Friday, March 7, 2008 at 12:03 am | Permalink

Post a Comment

Your email is never published nor shared. Required fields are marked *
*
*