snoofle

After surviving 35 years, dozens of languages, hundreds of projects, thousands of meetings and millions of LOC, I now teach the basics to the computer-phobic

Apr 2014

Left Hand, Meet Right Hand

by in Feature Articles on

You have to love the folly of big companies. Bear Stearns. Lehman. Tyco. Enron. MF Global. MegaCorp. WTF Inc. They always put out advertisements telling us how soft and gentle their products are for us, our children and the planet. They cajole us with ads extolling the virtues of their products, and how we can't live without them. Of course, you know that they use the strictest rules and procedures to guaranty the safety of our personal data, and take every conceivable measure to make sure that things are done correctly. In short, we can trust them. There are rules for how to do everything. Protocols to be implemented. Procedures will be followed. Period.

Phone companies, especially, take extreme precautions when releasing software because the communications grid simply cannot be allowed to go down. Ever. I mean, it's critical that you be able to get important messages through, like: I'm on my way, or Pick up milk.


Desert Packet Storm

by in Feature Articles on

Jonathan D. was the system administrator for a school nestled in a war-ravaged city somewhere in the middle of the desert. What with bombings here, explosions there, and the odd RPG whizzing by, dealing with a converted bathroom as an office/datacenter just didn't seem to be all that big of a deal.

The school had roughly 100 computers split between two buildings, along with the laptops everyone used. His office, ...erm... converted bathroom housed all of the servers, and the main computer room for the high school/middle school (grades 6 and up) building was located right outside the door.


I Had My Reasons

by in CodeSOD on

Trevor spent a huge amount of time writing a 2,000,000+ PHP/JavaScript/HTML system for an e-commerce company. Like a few other I'm-Special geniuses in our field, he believed that he could do it better than everyone else. For this reason, he came up with his own way of doing things. Database queries. Date-time logic. You name it.


This Round Robin Laid an Egg

by in CodeSOD on

One of the The Architect's developers laid the egg that is this round-robin connection pooling code. He discovered this when he noticed that his connection was getting incorrect responses under load.

public class RoundRobinConnectionContainer { 
  private static final Logger LOG = Logger.getLogger( RoundRobinConnectionContainer.class ); 
 
  private int useNext = 0; 
  private List<BehaviorEngineConnection> connections = 
               Collections.synchronizedList(new ArrayList<BehaviorEngineConnection>()); 
 
  // Find the index of the next connection to try

  public int getNextIndex() { 
    if (useNext > this.connections.size() - 1) { 
       useNext = 0; 
    } 
    return( this.useNext++ ); 
  } 
 
  public void addConnection(BehaviorEngineConnection connection) { 
    connections.add(connection); 
  } 
 
  public BehaviorEngineConnection getConnectedConnection() { 
    int size = this.connections.size(); 
    while (size-- > 0) { 
      BehaviorEngineConnection conn = connections.get(getNextIndex()); 
      if (conn.isConnected()) {
         return conn; 
      } 
      LOG.error("No connected connection available!"); 
      return null; 
    } 
  }
}