The Lehman Brothers Experience…

I originally published this article on my personal blog “Just another stream of random bits…”, back in September 2008, a few days after the now famous Bankruptcy of Lehman Brothers. Today being the 7th anniversary of the bankruptcy, I was thinking about how great it was to work for Lehman, and how sad it still is today to have lost an American company started in 1850, and I thought I would share this article once again. The original text of my 2008 article is below:

The Lehman Brothers Experience…

To my friends and family,

As you all know, I work for Lehman Brothers. And I’m pretty sure by now, you all have heard that the company filled for Bankruptcy earlier this week.

I have worked at Lehman for my entire professional career. Starting as a lowly summer intern in June 1998. Working my way up to a part-time hourly employee during my undergraduate studies at Polytechnic University, starting in May 1999. And finally being hired as a full time employee in May 2001. I have been employed at Lehman uninterrupted since May 1999.

Lehman has been more than a place where I go to work everyday. It is a place were I have made many friends on the professional level, and some of those relationships have grown beyond the office. My three managers I have had since I started working at Lehman all attended Paula and my wedding back in 2005, and I have attended their weddings, Christmas parties at their homes, and even Chinese New Year celebrations.

I knew it would always be hard to finally say goodbye when the time came for me to leave this chapter of my life behind. At this point, it looks like me and along with probably a good 95% of the rest of the firms employees will be forced to leave before most of us were ready to.

What’s worse is that there are many people who have spend the bulk of their professional careers at Lehman and as they are approaching retirement, they are in bad shape and I ask each of you to keep them in your prays. Lehman was the last bank on Wall Street to have a pension plan, which most of the long time employees are depending on for a significant portion of their retirement incomes. I know many individuals from my department who have been affected in this way. As of today, we still do not know what will happen with the pensions, so please let’s all hope and pray for the best. Us, younger employees will be ok, but those old-timers will really be feeling the pain regarding this issue in particular!

The Lehman Brothers culture, good or bad, was one of Pride and Family. There was a sense that we are all in this thing together and that we are all contributing to making the firm a direct competitor to the likes of Goldman Sachs. When I first started at Lehman, people told me, “Why are you joining that company!” “Come on Rob, you can do better than Lehman.” In fact no one besides myself, from my graduating class from Poly joined Lehman (although some did have offers and some were even interns along with me), They all thought they could do better.

The funny thing was, they all changed their tune after a few short months. Most of them lost their jobs do to the slowing economy and 9-11. Lehman although displaced from it’s global headquarters (World Financial Center – Tower 3 / The American Express Tower) which was heavily damaged during the terrorist attacks, was committed to rebuilding a strong firm than ever. They soon succeeded; we purchased a new Headquarters in midtown Manhattan, just north of Times Square, 745 7th Ave. We got a new building in Jersey City to replace our outdated and overcrowded 101 Hudson IT and Operations Jersey City building. We began expanding both domestically and internationally. Every week we would receive multiple internal communications on new acquisitions and deals being made across the global. They started rebranding the company, and we went from logos that were just gold letter of the words “Lehman Brothers” on a plain and solid dark green back drop to “Lehman Brothers – Where Vision Gets Built…” flashing on full color, jumbo screens on the sides of the new 745 building in Times Square. Each of our regional headquarters in both London and Tokyo were also being upgraded. A few short years after 9-11 which everyone predicted would be the end for Lehman, we purchased the Asset Manager Neuberger Berman. This marked a turning point in Lehman’s history. We started to risk among the ranks of the Wall Street Power Houses, and instead of being comparing to companies like Bear Stearns, we were being compared up against Goldman and Morgan Stanley.

When I would visit Paula up at Syracuse University when she was studying for her MBA, her classmates would approach me asking how is it to work at Lehman. That is the company they want to work for. Could I give them any tips on how to get their resume in front of the right people to be hired by the firm. And it wasn’t limited to Syracuse and a bunch of young and hungry MBA students. Everywhere I went, when someone heard I worked for Lehman, they wanted to speak with me about the company and if I would mind taking a look at their resume.

I was so proud to work for Lehman. In just a couple of years, it went from a company of only 7000 employees worldwide to over 25,000. It went from the company where people told me is run as far away from as possible, to the company where everyone wanted to work for.

Lehman was not a 9 to 5 shop, most managers, especially in the IT side, supported flex time and result oriented management. Meaning they didn’t care if you worked from home, or came in an hour late so long as the deliverables were completed ahead of schedule and with high production quality. Of course, as my wife Paula can tell you, this also means, you are on call 24 by 7. You not only carry a company Blackberry, but a pager as well. They have no problem calling up all the hotels in Las Vegas to find you and get you working on vacation. Trust me, it actually happened to me. But it all balanced out for the most part…

Lehman was known for treating their people right. Salaries were definitely comparable to the rest of the industry. Bonuses were great. Year End Parties were fun with Town Cars for each employee to go home in. The flexibility to work from home when needed was amazing and will truly be missed. Departments so long as they were “successful” were given many perks. My department for example always had up to date Computers and dual 19in flat panel monitors for just about everyone. Office Supplies were readily available in draws in front of the department admins. Free lunches at all large or long meetings. And we even went on a boat trip on a chartered NY Waterway Ferry with free beer and wine last year as a “team building” trip for the entire department. Training classes both technical and soft skills were made available to ALL employees freely. These classes would cost anywhere between $1500-3000 for a single day course to $5000-7000 for a five day training class. You potentially could have taken as many of these courses as you wanted to, so long as your direct manager approved. Being a manager myself, I have never seen an employee abuse the privilege and I always approved all request for these courses. If you could find a PC that wasn’t in use, in most cases the company and your managers would allow you to take it one along with Flat Panel Monitors to help with night support and working from home!

As you can see, it was an easy place to fall in love with, in terms of a place of business. Which is why there are so many employees who are having such a hard time saying good bye. I’m one of those employees. What has happened to Lehman over the past year has taken a toll on me in so many different dimensions. Financially (the obvious one), emotionally, mentally, and physically. Over the past two years, I have been working extremely hard on “self betterment.” I have been meditating, attempting to resolve my stresses through open communications and relaxation, listening to soothing New Age music, dieting, exercising, resolving my medical issues such as my Ulcerative Colitis, etc…

I feel that I have taken many steps in this process, but now with the stress and due to the “unknown” with the Lehman situation I definitely feel like I have take a few steps back.

I am extremely saddened by the down fall of Lehman. I feel like it is the end of an era. I have given Lehman so much, but they have also given back to me so much, in a world that depends upon money. I can’t imaging a world without Lehman. I did not know if I would be at Lehman for my entire career and in fact, I felt that most probably I would not be. However, I thought, I might eventually return to Lehman as so many employees who have worked for the company do, and possibly retire there. It literally brings tears to my eyes to think that this is no long an option. To think about walking by 745 7th ave, and reminiscing about all the meetings and presentations I gave there to Managing Directors for the Trader Portal project. To remember the feeling of pride as I walked through the doors of the building of my company; a company that was 30-33% owned by the employees.

Thank You for your time in reading this,

Robert Ilardi (Sept. 2008)
Vice President
Enterprise Account Management
Lehman Brothers, Inc.
70 Hudson St., 9th Floor
Jersey City, NJ 07302

Posted in Personal | Leave a comment

Another Class In the JAR, Part 1

Another Class In the JAR, Part 1

I wrote this back when I was a lowly Senior Developer at Lehman Brothers. When I write code, both, now and back then, I listen to music, usually Metallica or Pink Floyd, and sometimes SiriusXM’s Octane (Yes, I had an Air Card for my laptop since 2005)…

Written By: Robert C. Ilardi Date: March 1, 2005 Obviously a parody of Pink Floyd’s “Another Brick in the Wall” (Technically it’s a parody of Part II) –

———————————————————————————————–

We don’t need no Project Management

We don’t need no Source Control

No Code sarcasm in the Cubicle

Managers leave them Programmers alone

Hey! Managers! Leave them Programmers alone!

All in all you’re just another Class in the JAR…

All in all you’re just another Class in the JAR…

———————————————————————————————–

For you non-Java Programmers out there, here’s some definitions for ya!

Class in general

Specifically a Java Class File

JAR in Java

Code or Source Code

Definition of Source Control

So to sum it up: Programmers write Code or “Source Code” in Cubicles, that Source Code is organized into Classes, and in Java, lots of classes are stored within a JAR File. Programmers do not like Project Management, and Project Managers like to make sarcastic remarks about programmers codes when standing above them in their Cubicles, while reminding them that all their source code changes better be in the Source Control System such as SVN or CVS!

Just Another Stream of Random Bits…

– Robert C. Ilardi
 
Posted in Randomness | Leave a comment

How to Share your Starbucks Smart Phone Bar Code with your Significant Other

It’s pretty simple. Since the Bar Code is just a representation of your gift cards Serial Number, all you need to do is take a Screen Capture from your phone of the generated Starbucks Card Bar Code.

If you do not know how to take a screen capture with your particular smart phone, just google it. But here’s the iPhone instructions: Press the Home button and the Power/Sleep Button at the same time: Here’s a link: http://www.wikihow.com/Take-a-Screenshot-With-an-iPhone or this one on the Apple Forum: https://discussions.apple.com/thread/3739872?tstart=0

Then you can email it to your wife/husband/boyfriend/girlfriend, or whoever else you want to use your card.

Screen Cap Like So (Obviously I removed the real bar code and numbers from this picture):

starbucks_app_screen_cap

PLEASE NOTE: This does not fool the system into giving you free Starbucks! Nor was this an attempt to try to circumvent the system.

Also, DO NOT Send this to anyone who you do not want to use your Starbucks card and your money, treat this screen capture as if it was your real Starbucks card, because it is! Your balance will decrease each and every time someone scans the photo on their own smart phone at the Starbucks register.

Also, what’s cool about this method, is you do not need to share your password, and the person you share the photo with doesn’t even need the Starbucks App installed on their phone!

Just Another Stream of Random Bits…
– Robert C. Ilardi
Posted in Randomness | Leave a comment

You’re Not Thinking Fourth Dimensionally

This is a quote from the textbook we used in the Programming Languages course I took in college: “It is widely believed that the depth at which we can think is influenced by the expressive power of the language in which we communicate our thoughts. Those with a limited grasp of natural language are limited in the complexity of their thoughts particularly in depth of abstraction. In other words, it is difficult for people to conceptualize structures they cannot describe, verbally or in writing.” – From: Concepts of Programming Languages; by: Robert W. Sebesta

I believe that has we progress in our professional careers as software engineers, system architects, and development managers, we learn certain patterns, and no matter how creative we are, we slowly start to normalize into a recognizable pattern of designs, coding concepts, languages, and project management techniques, that peers can look at and say, “Yes that has the mark of [INSERT YOUR NAME HERE] evilgrin“.

It’s not that we get lazy, or lose our creativity, I just believe it’s human nature to fall back and lean on what we have learned “works”. And there’s really nothing wrong with that in itself (we obviously fall back on our education and values we have picked up from our family, friends, churches, and cultures, constantly over our lifetimes), however I believe as creative individuals, programmers and people who are at their heart programmers, need to stay creative, not only for their jobs but for their own sanity.

As Robert Sebesta has said, our thought processes are limited by the language we know. I believe it’s not only written language but also visual representations as well, and how we can use those “thought elements” or our vocabulary both in the written/spoke language sense and visualized elements to create new and amazing designs, systems and applications. Although in programming, eventually we need to describe these designs using words and math. Especially if we are working in teams, and need to produce readable, reusable, and maintainable code. See my article on “SFEMS – Stable, Flexible, Extensible, Maintainable, Scalable“. As good programming citizens we aren’t supposed to start naming everything a, b, c, a1, i2, j, k, etc… evilgrin

So how do we stay fresh? Is it merely a matter of reading new books and watching the same types of movies we always have? No, I think this is the trap. We need to Expand our Minds. We need to “Free our Minds”, yes, from the Matrix. If our creative thought processes are limited to the language elements we know and understand, then, if we limit our input of new data, vocabulary, stories, music, and visual imagery to those same basic genres, that we always watch, read, and otherwise consumed, then we really aren’t going to expand our base knowledge stores that our creative parts of our brain randomly and so naturally pull from to create new and interesting ideas, designs, and in the case of programmers, new systems and applications.

I love the quote from Doc Brown in the Favorite movies of all time “Back to the Future“, where he tells Marty “You’re Not Thinking Fourth Dimensionally.” (Although he doesn’t say this until Part III. Check out FuturePedia on the Fourth Dimension.) While he of course is referring to time as the fourth dimension, I’m thinking of this quote more generally, to mean, we aren’t thinking outside of our normal frame of thought. We aren’t considering new and different ideas, movies, music, art, books, and other information sources during our programming down time in order to expand our “thought element vocabulary”. Again what I mean by thought element vocabulary, is our knowledge base of ideas and concepts that we use to create and design and express ourselves in programming.

I believe the exposure to information sources that we already enjoy does not expand our minds after a few decades of consuming these books, comics, movies, etc, instead we need to look to other genres, and even activities to further expand our minds.

If you are a sci-fi fan, how predictable are the plot elements to you? Here and there, you will find something absolutely surprising, but for the most part, after a couple of decades of consuming all the sci-fi you can, you probably will see patterns in the storylines, and I’m pretty sure you make comparisons how one movie just ripped off half the story from another, or complain how there’s really nothing new out there and Hollywood just sucks (while I don’t disagree here evilgrin).

So what I started to do, is started reading and watch different genres of books, comics, and movies. I have also started to try to pick up new activities as well. Example: If you are a gamer, how long have you been playing games? In my case it’s since the mid-1980’s. While I’m not saying to stop playing games, all I’m saying is to try something new. For example, recently, I pick up drawing and reading up and practicing meditation.

I believe learning these new activities and consuming these new genres will help me to expand my mind, and keep my creativity fresh and exciting. While I’m not saying or encouraging you to pick up something that you feel you would never like, I’m sure their other genres and activities out there that you haven’t tried yet, and would find enjoyable.

I also want to encourage you to day dream a little more. I remember as a child I would love to day dream about new inventions, and space adventures, saving the world, etc. I think half of my ideas have some correlation to my childhood day dreaming. I now see it as some sort of meditation. Of course as adults, we can’t day dream at work like we may have done in the classroom from time to time, or can we? evilgrin

Just Another Stream of Random Bits…
– Robert C. Ilardi
 
 
Posted in Personal | Leave a comment

Singletons and Factories of Singletons

A Singleton is a design pattern that allows for a One and ONLY One Object instance of a class  to be instantiated within the memory of a process using object oriented programming concepts.

Maybe people will ask, well why can’t I use a Static instance of a class in my program as a field or data member? Well, you can, however in larger scale programs, you may not want to have to pass around the static instance of this class from class to class or method to method. This often will over complicate your code and make it harder to maintain.

Or, can’t I just use all static fields/data members and methods/functions in my class to accomplish the same thing? Again, you can, however you lose a lot of the benefits of having an true SINGLE instance of an Object. You are now dealing with a object that is less flexible than if you made a Singleton instance of that class.

There is some debate on this between programmers whether you could just use all static methods and fields verses a singleton, but a singleton’s behavior is more predictable across languages, because the design and ordering of creation is controlled by the programmer instead of the system. So my own preference is not to use a class with all static members and go with a Singleton.

I also personally feel, that a class with all static methods, should be restricted to classes that only contain helper methods, such as a class that contains String manipulation helper methods. I usually have this type of class in my systems, called “StringUtils”. All methods are public static, and stateless. They are used to perform a common string manipulation function and return.

By using a Singleton, you have more freedom to design the true behavior of your class, including how the class is created and initialized. This where the Factory of Singletons comes into play a well. I usually like to create a Factory which itself is a Singleton, that creates a Singleton. This factory than can be used to return an implementation of a interface which a range of Singletons could define the implementations of. The factory can also be used to correctly call the initialization methods after the “GetInstance()” static (and atomic aka synchronized) method is called to obtain the instance of the Singleton. This is perfect in case you need to call a specific initialization function or set root parameters ton the Singleton that you don’t want the user of your singleton code to have to deal with.

The single most important factor that makes a class a Singleton is a “private constructor”.

By having a private constructor, there is NO other Class except for itself that can create an Object instance of that class.

The private constructor is not by itself how a Singleton is built, technically, I could have a private constructor and still have a static method that returns unlimited new and distinct instances of the class, so we need a “Get Instance” method, basically a Factory method, that ensures that One and Only One instance of the class we are trying to make a singleton is created in memory for a particular process. Because the constructor is private, the only way to access this Get Instance method is to make it public and Static. (I recently read a post of Java’s facebook page asking for a one line explanation why I would use the static keyword to modify a method signature. Well, simply: We use the static modifier on a method to make that method available at the Class level. This means that there’s only one instance of that method in memory for all object instances. This also works to our advance for the singleton implementation, because I can’t create a object instance of the singleton class myself, so calling public static methods is the only way to interact with the Singleton, before I call the Get Instance method which will return the one and only Object instance of the singleton class.)

This is usually done by using lazy instantiation in the Get Instance Method. Lazy Instantiation or Lazy Initialization is when in programming, we do not “pre-create” or pre-initialize an Object or other structure or section of code until the first invocation of usage of that object, structure, or code is required. This is a great concept, when working with limited resources such as Memory, or when perhaps, we don’t know if we ever need a instance of something, and why bother wasting processing cycles and RAM on creating that object.

The third and final component that makes a class a singleton, is a private static field whose data type is the Singleton’s class itself. This field would be set by the lazy instantiation code of the Get Instance method. And is used in the lazy instantiation check, if it is NULL, call the private constructor and set the private static field. Then simply always return the private static instance of the singleton class. This causes our class to be a singleton. The only object instance that exists, and will ever exist while the process is running is the private static instance of that class.

The Get Instance method also needs to be atomic or synchronized, to make sure it’s thread safe. If not, technically two methods calls to the Get Instance by two separate threads could potentially create two or objects of the singleton, and all of those objects would eventually be lost once the threads stop referring to them, and only the last one that set the static instance field of the Singleton class instance itself would survive, and this potentially could cause data corruption or other weird runtime related issues, because we are assuming you need a single instance of an object globally for some critical reason, not just for fun… evilgrin

Perfect example of a simple Singleton: “GlobalMap” –

/*
 * Created on March 1, 2004
 */

package com.roguelogic.util;

import java.util.HashMap;

/**
 * @author Robert C. Ilardi
 */

public class GlobalMap {

  private HashMap<Object, Object> cache;
  private static GlobalMap globalSpace = null;

  private GlobalMap() {
    cache = new HashMap<Object, Object>();
  }

  public static synchronized GlobalMap getInstance() {
    if (globalSpace == null) {
      globalSpace = new GlobalMap();
    }

    return globalSpace;
  }

  public synchronized void clear() {
    cache.clear();
  }

  public synchronized void store(Object key, Object value) {
    cache.put(key, value);
  }

  public synchronized Object retrieve(Object key) {
    return cache.get(key);
  }

  public synchronized Object remove(Object key) {
    return cache.remove(key);
  }

  public synchronized boolean containsKey(Object key) {
    return cache.containsKey(key);
  }

}

syntax highlighted by Code2HTML, v. 0.9.1

As you can see from the simple class above “Global Map”, the idea was to create a Singleton Hash Map, so that we could share the HashMap through a java process without having to pass it from class to class. And in large programs with 100’s or even 1000’s of classes this would not only be impractical, but bad coding practice. The Global Map uses the 3 root concepts of the singleton design pattern:

1. Private Constructor: Line 18 –

private GlobalMap() {
cache = new HashMap<Object, Object>();
}

2. Private Static Singleton Class Data Type Data Member: Line 16 –

private static GlobalMap globalSpace = null;

3. A thread safe Public Static Get Instance (factory method), which uses lazy instantiation to create and initialize the private static singleton class data type data member: Line 22 –

public static synchronized GlobalMap getInstance() {
if (globalSpace == null) {
globalSpace = new GlobalMap();
}

Factories of singletons are simply Factories that return instances of singleton implementations. A factory of singletons could simply always return the same singleton implementation or it could based on criteria return different singleton implementations.

The advantage of using a Factory that creates the singleton, is that the factory could contain additional logic outside of the singleton that calls certain initialization methods and sets configuration settings on the singleton at the first call to the “create” method in the factory so that the singleton is initialized once and only once. This abstracts the responsibilities for initializing the singleton correctly on the first call to the Get Instance method on the singleton itself, away from the end users of your singleton class.

Technically you could put the responsibility of calling certain initialization methods on the singleton after the first call to the Get Instance method on the singleton in the hands of your users, but then they would have to put counter or flags to indicate when the first call of Get Instance was called. This in a sense negates some of the direct benefits of a singleton, and therefore wrapping this logic yourself in a Factory if a much better choice.

However a Factory of Singletons should only be used if you need a complex initialization routine after the call to the private constructor of the singleton that requires a lot of outside input or parameters to be set on the Singleton that is too cumbersome to be done within the singleton itself.

There’s also a neat trick I have used in the passed when combining Factories and singletons. Sometimes I remove the Get Instance method from the singleton itself, and instead create a “Protected Constructor” instead of a private one. Although this technically means it’s not a true singleton, and in a language like Java, this allows “friends” or classes that exist in the same package to invoke the constructor directly. If you put the Factory of the Protected Constructor Singleton in the same java Package, it can then be responsible for creating the singleton object instance instead of the singleton itself.

Also, within a Get instance method in the singleton class itself, this basically forces the users of your code to ensure they go through your Singleton Factory always instead of trying to construct the singleton themselves and possibly messing up the initialization procedure which should be done by calling the create method on the Factory instead.

I think this shows the real power of design patterns, they are more guidelines than anything else, and you can use them in combination or modify them to suit your needs.

My posts on design patterns seem to be the most popular posts on my blog to date (besides my Tesla Coil post evilgrin), so I’m definitely going to write a post on Factories and Abstract Factories in the near future. Please stay tuned for that! In the mean while, please feel free to check out my design pattern post on Adapter Factories.

Just Another Stream of Random Bits…
– Robert C. Ilardi
 
 
Posted in Architecture | 1 Comment

The Classic Producer – Consumer Problem

One of the main questions that my team ask potential candidates during technical interviews, is the Producer – Consumer Problem. We have found over the years that this problem is one of the main issues we have with potential new hires. Many a programmer has been tripped up by this problem, and the related questions that follow.

Producer – Consumer problems are a set of problems with the domain of Multi-Threading.

The concept is simple, we have one of more threads that are “Producers” of something, usually data (Events, Structures or Objects are data) in the case of computers and programming.

“Consumers” are other threads that receive and use the data produced by the “Producers”.

Many different threading concepts are used when creating a Producer-Consumer scenario and it is a great real-world mechanism that we use to solve multi-threaded problems on a day to day basis; and therefore it is an extremely useful to test potential new hires.

For illustration in this blog post, I have created three separate Java classes, which are below. First is the “Test Driver”, this is the main program used the test and potentially debug the Producer and Consumer threads. The second is the Producer. This of course is the Producer thread implementation. And finally the Consumer, which like it’s counterpart the Producer is the Consumer thread implementation.

In my example code below, the Producer and Consumer will run forever (until the user sends the interrupt signal ie. Cltr-C or otherwises kills the process). The Producer will create 10 random Long objects every time is obtains the lock on the “listLock” object monitor, and will than wait while the “sharedList” ArrayList object is NOT empty. The Producer will also Notify ALL other threads waiting on the listLock Object. There is an important difference between the notify() and notifyAll() methods on the java base Object. Both are used to notify waiting threads that are blocked on the same object monitor that it’s time to wake up, but the notify all will wake up ALL threads that are blocked on that object monitor, and based on the OS implementation that threads will compete for object monitor lock, before continuing execution. This is good for situations where you have multiple consumers blocked on the same Object Monitor lock and you want any of them to potentially being processing once that lock becomes available. The rest will block due to the synchronization of the critical section of code which they originally were in the waiting state for. This is of course assuming you wrote your code correctly.

Once the consumer wakes up from the waiting step and obtains the lock on the Object Monitor “listLock”, the example code I have written will consume all data within the ArrayList safely, before notifying the Producer (technically any other threads synchronized and waiting on the listLock) to wake up. In this case the Producer will wake from the waiting state, but it is still blocked because the Consumer has not yet released the lock on the listLock object. Once the Consumer’s loop enters the while sharedList isEmpty check, the Consumer will execute listLock.wait(), entering itself into the wait state, and releasing the lock on the listLock object monitor. This will now allow the Producer to finally being executing, and the process will repeat, with the Producer producing 10 random objects into the shared list. The process will run forever like this, passing data between Producer and Consumer safely, without either thread corrupting the shared memory space, in this case the sharedList ArrayList object. Please note that I did not use any Collection synchronization mechanisms, other than my own. This is perfect for the purpose of testing the Producer-Consumer problem. To use any of Java’s facilities to create thread-safe collections would be defeating the purpose of trying to demonstrate an understanding of multi-thread programming.

Test Driver:

/**
 * File: PCTester.java
 * Creation Date: June 24, 2013
 * Author: Robert C. Ilardi
 * 
 * Here we have a Test Driver for our Producer-Consumer example.
 * 
 */
package com.roguelogic.tests;

import java.util.ArrayList;

public class PCTester {
  public static void main(String[] args) {
    try {
      // This creates a Object Monitor or "lock"
      // that can be shared between threads.
      // Technically in Java, any Object
      // instance of any class
      // can be used as an Object Monitor.
      // As a matter of convenience, most
      // programmers,
      // simply use an instance of the
      // class Object to represent the
      // lock.
      Object listLock = new Object();

      // This ArrayList will become our
      // Shared resource that both the
      // "consumer" threads and the
      // "producer" threads will
      // use to pass data back and
      // forth. On specifically in
      // this case, it's one
      // directionally from the
      // Producer to the Consumer.
      ArrayList<Object> sharedList = new ArrayList<Object>();

      // Here we are creating the Producer
      // It is an object which I have extended
      // the Thread class from. This makes the
      // Producer itself a thread.
      Producer p = new Producer();

      // As you can see I'm passing the listLock object monitor.
      p.setListLock(listLock);

      // I'm also passing the Shared List ArrayList to this Producer.
      p.setSharedList(sharedList);

      // We are now going to create a Consumer Thread.
      // Like the Producer, it also extends from the Thread class
      // and I have also set it up to receive references of
      // both the listLock Object Monitor and the sharedList ArrayList.
      Consumer c = new Consumer();
      c.setListLock(listLock);
      c.setSharedList(sharedList);

      p.start(); // We are going to start the Producer Thread.
      c.start(); // We are going to start the Consumer Thread.

      // The next two lines of code
      // Simply ensures that the main method
      // waits on the producer and consumer thread
      // to exit before continuing.
      p.join();
      c.join();
    }
    catch (InterruptedException e) {
      e.printStackTrace();
    }
  }
}

syntax highlighted by Code2HTML, v. 0.9.1

Producer:

/**
 * File: Producer.java
 * Creation Date: June 24, 2013
 * Author: Robert C. Ilardi
 * 
 * This is the Producer example thread class.
 * 
 */
package com.roguelogic.tests;

import java.security.SecureRandom;
import java.util.ArrayList;

public class Producer extends Thread {

  private ArrayList<Object> sharedList;
  private Object listLock;

  public Producer() {
    super();
  }

  public void setListLock(Object listLock) {
    this.listLock = listLock;
  }

  public void setSharedList(ArrayList<Object> sharedList) {
    this.sharedList = sharedList;
  }

  public void run() {
    // We are using Secure Random, because the regular Random is boring.
    SecureRandom srnd = new SecureRandom();

    // Here we have the synchronized block
    // which is on the listLock Object monitor.
    // This creates the critical section of code
    // that marks the block of code within it
    // that the operations are atomic.
    // However listLock.wait will cause the thread
    // to stop processing and allow other threads
    // to obtain the lock on the Object Monitor.
    synchronized (listLock) {
      try {
        // Run forever
        while (true) {

          // Add 10 random numbers into the shared queue.
          for (int i = 1; i <= 10; i++) {
            Long nxtLng = srnd.nextLong();
            sharedList.add(nxtLng);
          }

          listLock.notifyAll(); // Notify ALL other threads to wake up

          // Wait while the Shared List had data in it
          while (!sharedList.isEmpty()) {
            listLock.wait();
          }
        }
      }
      catch (InterruptedException e) {
        e.printStackTrace();
      }
    }
  }
}

Consumer:

/**
 * File: Consumer.java
 * Creation Date: June 24, 2013
 * Author: Robert C. Ilardi
 * 
 * This is the Consumer example thread class.
 * 
 */
package com.roguelogic.tests;

import java.util.ArrayList;

public class Consumer extends Thread {

  private ArrayList<Object> sharedList;
  private Object listLock;

  public Consumer() {
    super();
  }

  public void setListLock(Object listLock) {
    this.listLock = listLock;
  }

  public void setSharedList(ArrayList<Object> sharedList) {
    this.sharedList = sharedList;
  }

  public void run() {
    int slSz;
    Object obj;

    // Just like the Producer class
    // the synchronized block creates
    // a block of atomic code also
    // know as the critical section
    // as it potentially interacts with
    // other threads.
    synchronized (listLock) {
      try {
        // Loop forever
        while (true) {

          // Wait while the list of empty.
          // Technically this means we can
          // wake up as soon as a single
          // object is populated in the shared list
          // however since our producer implementation
          // does not notify until 10 items are added
          // to the list, we won't really wake up
          // until all 10 are added.
          while (sharedList.isEmpty()) {
            listLock.wait();
          }

          // Note: even if the listLock.wait()
          // receives the notification, it doesn't
          // mean the code will start running,
          // because we are synchronized on the listLock
          // therefore until the lock is released by
          // the thread that has the lock, we will still wait.

          // Loop until the sharedList is empty.
          while (!sharedList.isEmpty()) {
            slSz = sharedList.size();
            obj = sharedList.remove(0);

            System.out.println("Consumer(" + super.getId() + ")>  Shared List Size = " + slSz + " ; Object = " + obj);
          }

          // When we are done make sure to notify other threads
          // This is extremely important if the Producer is in the waiting
          // state. However this thread still holds the lock
          // until the listLock.wait() is invoked in the next iteration
          // of the while loop. If we forget to notify, both threads
          // simply wait forever. Give it a try. Comment it out.
          listLock.notifyAll();
        }
      }
      catch (InterruptedException e) {
        e.printStackTrace();
      }
    }
  }

}

Although, technically I am giving away a partial question and definitely a topic that I have my teams’ test potential new hires on their technical interviews, I think it is important for students of computer science, and programming in general to have a solid understanding of the Producer-Consumer problem. I have found that in all complex systems, and definitely systems that are multi-tier, 3-tier or more distributed systems, a lack of understanding of the Producer-Consumer problem, severely curtails the ability of programmers to produce reliable systems. Again, I hope this post has been helpful!

Just Another Stream of Random Bits…
– Robert C. Ilardi
 
Posted in Development | Tagged , , | 1 Comment

SFEMS – Stable, Flexible, Extensible, Maintainable, Scalable

For the last 8 years that I have been giving my architects, tech leads, and developers their yearly performance reviews, I have been using the acronym “SFEMS”.

Arguably you can say I should just be telling my architects and maybe tech leads that they need to design and ensure their team’s implementations follow the SFEMS (Stable, Flexible, Extensible, Maintainable, Scalable) mantra.

However I feel that every person in my development groups should eat, drink, sleep, and *CODE* evilgrin with SFEMS always on their minds.

Everyone in my group is required to ensure they design and write code that meets this the SFEMS Standards. I don’t care how junior a developer is, we preach it to them from their first day on the job, even if they are just one day out of school.

When I have my town halls and other group meetings, I always remind my developers that the expectation is Quality over Quantity (in terms of how much code they can write in any given day), and that refactoring their code to ensure it meets SFEMS standards is the norm.

It doesn’t matter how small or large of a component a developer or team of developers are writing, it is always important that the code is first of all STABLE – that is the code should be as close to bullet proof as possible; although I make it understood that everyone and anyone can write code that contains a bug or two. Code should be expected to be used in a one off API where the objects containing your code is used once than discarded or the same classes could be used in a Daemon process where the objects may live for hours or even days to weeks without the process being restarted. This is where unstable code usually becomes a problem because it may work by contain a memory leak or a database connection leak, or other resource utilization issue, and it is why the same code may work if it’s only used once in a while in a process and it causes weird behavior or even crashes in long running processes, or short running processes that use the same code in a loop with thousands or even millions of iterations.

Second and Third, their code needs to be Flexible and Extensible. You may say, well what’s the difference? Well to me, code can make an application be flexible if it can be helps the broader application or system which it is part of work under a range of circumstance. Think of it like a person being flexible in their abilities to handle multiple situations or to be able to come up with solutions and work-around automatically to a problem set within the same knowledge domain. In software this is when for example, I am writing a ETL (Extraction, Transformation, Loading) loader and my code should be able to contend with small variances in the data without failing the overall process. More specifically if the loader code encounters one or two records with incorrect Country Codes, the loader should be able to be configured to have a threshold of corrupt records in the source data while still completing the process if that threshold is not met and perhaps report the error records to the development team automatically via email or some other more complex method such as a error queue processing table. We can configure the threshold to be ZERO or ONE and therefore as soon as any error is encountered with fail out the process. But this is where Flexibility comes into the picture, and the threshold can be dictated to us by the business or users.

In terms of Extensibility, I expect all of my programmers to follow good OOP / OOD so that their code can be reused and extended to help us cut down on our time to market. For years I have used the approach of creating an “Internal SDK” (Software Development Kit) at the start of a project when I take over as the manager or architect. We usually create a module in our source code repository called “commons” which contains our groups SDK. It contains all the frameworks, wrappers, and useful utilities that are common across our Middleware, Batch, and Standalone processes. In the case where the User Interface is written in the same language as the rest of the system, the UI is expected to use commons as well. Over the lifetime of the systems I own and develop, we have a process of “Promoting to Commons” as objects and other code become so useful they become “common” within our system, and the code will be refactored and moved from whatever source code repository module it was originally in to the Commons module. We use this same principal for non-object oriented languages or components, such as scripts. Even though common scripting languages we use such as Perl and Python either have the capabilities to create Objects and use OOP concepts or are Object Oriented themselves, most times I find that we treat scripting languages as procedural languages, but this doesn’t mean we can’t have reuse. We enforce the same strategies we do in Java or C#. We always programming forward thinking, so if we feel a subset of functions a script that we write can be useful for future scripts, we create a library of common scripts of functions or objects. So I always tell my team ensure that whenever possible if you even just have a feeling that your code or parts of your code can be useful to someone else, ensure that it written so that it can be reused as much as possible. Or if you notice that you are going to be writing the same thing over again, stop and go back to where you wrote something similar before and refactor the code so that the original becomes reusable two both the original component and the new component, or at least extract the common functions into a base class or utility package.

Fourth, we must ensure that whatever we write is Maintainable, and that means maintainable by other developers. I am very straight forward in telling everyone that we write systems to last 20 years at least, no matter if we or others will replace it sooner, the assumption must be at least 2 decades. And therefore we cannot afford to assume the same people will be on the same project to work on the code they personally wrote or helped to write over that long of a period. Therefore we need to put ego aside for the team’s sake and write code that is clean and clear, and simply for other members of the team to read and make enhancements to. As managers, architect, and leads, we need to watch over our developers to ensure they are not writing code that only a small subset of people or only one person can maintain. If we allow this in our system, we are setting ourselves up for failure in the medium to long term. Maintainability encompasses Extensibility and the next and final word in the SFEMS mantra Scalability. For systems to be Extensible and Scalable, they MUST be easily maintainable. Otherwise, they really can’t be considered build to be forward looking and therefore are not easily extensible and possibly not scalable as well, if we can’t change the code within reasonable cost to handle changes to the business, system load, and user requested enhancements.

The Fifth and final component to the SFEMS mantra is ensuring the code and systems we develop are Scalable. Writing systems to be scalable is not an easy task. We often write code to solve a specific problem. Perhaps we have to write a middleware which will be used by a front-end that will have only 1000 users today. We can do that, because that’s the requirement and we will buy the hardware we need and architect the system to handle this user load. But how will the system perform if we add another couple of hundred users? How about a thousand more? Will it even allow that may users to be online at the same time? How do we build a system within cost that can scale in the future when we don’t even know what the upper limit will be (if there even is one)? It’s definitely not easy, and building scalable systems is an entire topic all to itself worth many volumes of books and articles. However if we followed the first 4 components of SFEMS (Stable, Flexible, Extensible, Maintainable), our systems should be able to scale if we are given the proper resources to enhance it. In my mind we should always build our systems to expect between 1.5 and 2 times the expected user or data load on the system that the original requirements state. If we can do this, we have already bought us enough time to work on ensure the system is Stable, Flexible, and Extensible to scale beyond 2 times the original load. There’s really no way to make a system handle unlimited system loads. Eventually it will come down to a physical limit of the computing platform your code is running on, so we must build systems with Scalability in mind through the first 4 components of the SFEMS mantra so that with the right investment in extending the system to handle the new system loads, we can within reasonable cost models and time to market accomplish the required enhancements.

Each of the five components of SFEMS deserve at least a separate post all to their own. However I hope this article will help everyone from junior developers all the way up to senior technology managers on their journey when building large scale enterprise class systems that are expected to write a multi-decade lifespan.

So just remember “SFEMS”! – Stable, Flexible, Extensible, Maintainable, Scalable

Just Another Stream of Random Bits…
– Robert C. Ilardi
 
Posted in Architecture, Development, Software Management | 4 Comments

So, if you had your own t-shirt, what would your catch phrase say?

I recently participated in a company sponsored people strategy event, where I was part of a panel of leaders at various levels within my department.

One of the questions posed to the Panel which we didn’t have an opportunity to answer was “So, if you had your own t-shirt, what would your catch phrase say?”

Unfortunately, we ran overtime and we did not have a chance to answer this question to the forum, so I figured I post my answer here and perhaps even send this link to my teams.

Being one for dramatic presentations, I actually brought in my own T-Shirt to the event, to hold up and show, that not only “would I” have a T-shirt that has my catch phrase, I actually DO have a T-Shirt with my “catch phrase” on it, and I wear it regularly. I also have a Polo Shirt with the RogueLogic logo on it!

It is a simply white T-Shirt with the RogueLogic Logo on it. RogueLogic as you might already know from reading my Blog, is own my personal web site as well as the web site for the Software Company I tried to start while in College.

Here is the actual T-Shirt:

IMG_2180

So what does the “catch phrase” or really the moniker “RogueLogic” really mean?

Well back in 1999 when I was starting my own Software company, I was trying to come up with a name that represented the Revolutionary ideas my company was going to build products upon. I always thought of myself as someone that not only thinks out side of the box, but actually is a “Rogue” Thinker. Therefore RogueLogic was born! I also liked the fact that both my name “Robert” and “RogueLogic” starts with the same letter… evilgrin

How does this apply to me today in my professional career? And why would I choose to share this at a professional company sponsored discussion panel, that was video conferenced with over 1000 viewers around the globe? Well, because thinking so differently, that it way beyond “thinking outside of the box”, to the point where it’s Mad, Ludacris, any even “Rogue” is exactly how I achieve so much in my professional career in such a short time, and it is what I rely on to get me through the toughest software engineering problems my team and I face on a daily basis. It’s what separates us from the rest of the Wall Street Software Development Pack.

Check out the Evolution of the RogueLogic Logo… Or how about a little “They Use RogueLogic!”

Here’s me wearing my T-Shirt:

IMG_2183

Just Another Stream of Random Bits…
– Robert C. Ilardi
 
Posted in Personal | Leave a comment

The Evolution of RogueLogic Logos

This is actually a blog entry I posted on RogueLogic.com back in 2009:

With the 10th anniversary of RogueLogic coming up, I thought it would be nice to quickly go over the evolution of the RogueLogic logos since the birth of my moniker in 1999:

1. The original RogueLogic Logo created back in 1999 when I founded the company…

roguelogic_orig

2. This is the second version of the logo. I used this version, when I briefly changed the background color of the website from white to black.

rllogo_lightning

3. This is the current version of the RogueLogic Logo. I originally created this version back in 2001, when I was taking a Web Design Class.

rlLogo

 

Just Another Stream of Random Bits…
– Robert C. Ilardi
 
Posted in Randomness | 2 Comments

They Use Roguelogic

Back in 1997, US Robotics had a small banner advertisement on AOL for their 56K X2 modem, which I happened to own at the time, so I took a screen capture and cropped out just the logo. After many searches using Google Image Search, I have yet to find anyone else to has a copy of this Image. Please let it be known that I do not own the Image below nor to I claim any ownership or any other rights to it. Instead I have posted it here for Internet Posterity.

Original US Robotics “They Use X2”

theyuse_x2

Check out US Robotics which as of 2013 still produces 56K modems!

Base on the implication which this image tries to portray, at least my interpretation, that Advanced Alien Civilizations use “X2” 56K technology, I created in Parody (Fair Use in Copyright Terms) my own version which Implies “Advanced Alien Civilizations use RogueLogic Technology!”, which I have done  for use as my Personal Instant Messaging Buddy Icons:

2013 RogueLogic Edition “They Use RogueLogic”:

theyuse_rl2007a

Lastly: Check out the Evolution of the RogueLogic Logo

Just Another Stream of Random Bits…
– Robert C. Ilardi
 
Posted in Randomness | 1 Comment