May 10, 2008: Discovering the Hudson Valley

New York’s Hudson Valley has always been a strange place to me.  Being from western New York the lower Hudson Valley (south of Albany) is a place of immense history and importance but appears to serve as nothing more than a traffic corridor between the capital at Albany and New York City at the valley’s southern most extent.  All of New York’s large Upstate cities lie along an east-west corridor along the Erie and Barge Canals with Albany in the east as the capital and oldest city in the state, then Utica, Syracuse, Rochester and finally Buffalo when you reach the state’s western edge.  With the except of Utica, each city grows in size and importance as you head west as well.

The Hudson Valley has no significant cities.  In fact it’s cities are so small that they are actually smaller than New York’s southern tier corridor cities which are minuscule in comparison to the northern “canal” corridor cities.  Along the southern tier are Jamestown, Corning, Elmira, Ithaca and Binghamton.

What really sets the Hudson Valley apart from the bulk of Upstate New York are two things.  The first being that it serves simply as a suburban area for New York City so all traffic and “focus” are towards the south instead of being around local city centers.  The second is that there is no “open space” between the Hudson Valley towns.  Unlike New York farther north, the Hudson Valley is a continuous blanket of population – much like Long Island and Northern New Jersey.  Most of New York State is dense city centers separated by immense spans of countryside and agricultural land, but the Valley hides a large population without the obvious population centers.  The feel is completely unlike New York’s other population regions.

Today our goal is to go to the Hudson Valley and discover this region of our home state.  Dominica is leaving on the six o’clock in the morning flight to Houston tomorrow, flying out of Newark so today is our last day together for a whole week.  So this morning was packing and last minute laundry, flight check in and other miscellany.  Then a little after noon we hit the road north.

We drove up the Palisades Parkway through Bear Mountain State Park and crossed over to the eastern bank going over the Bear Mountain Bridge.  We took Route 9D north along the river through Manitou, Garrison, Cold Springs and up to Beacon.  The area was completely breathtaking.  Those communities are so nice.

We stopped in Beacon and explored its now rather famous main street.  Downtown Beacon is really nice with tons of food options and lots of crowds wandering about exploring the town like us.  We drove around and got a feel for the town and went down to the train station to get an idea of where that was located.  Then we went to the end of Main Street and ate at the Thai restaurant there.  We sat outside since the weather was so nice.  The food was really good too – although I accidentally ordered mine way too spicy.  Not that I couldn’t eat it but it wasn’t nearly as good as it would have been much less spicy.  I will know for next time.

After our dinner we went to the other end of main street to the Beacon Creamery and got ourselves some local Hudson Valley hard ice cream.  It was really good.  We got a small dish of vanilla for Oreo too.  He was really bored by this point having just sat in the car all afternoon.  He was very thankful for his dish of ice cream which he ate on the sidewalk while I held the dish for him.

After Beacon we drove to Fishkill.  Fishkill is one of my “old family” towns.  My mother’s mother’s family lived in Fishkill in the late 1600s into the early 1700s after having moved from Rensselaerwyck (Albany today) to Flat Bush in Brooklyn and then to Fishkill.  Lise Winans is from Fishkill as well.  We didn’t get to see anything but the trailer park and Rail Road Recovery operation on the outskirts of town, though, because they were having some “Rock Around the Clock Block Party” and had closed off the streets.  So we didn’t get to see Fishkill and drove away.  Not a good move for potential home owners since the only parts of town accessible easily from the outside were pretty sad.  We did get to see their impressive prison, though.

We drove back to Beacon and then took Route 9D down along the Hudson River back the way that we had come but instead of taking the Beat Mountain Bridge back to the west side of the river we instead took Route 6 / Route 202 to Peekskill (where furniture VidenovThe Facts of Life is set) and on down through Westchester County.  I have never really driven through Westchester before and Dominica has never seen it at all so it was very interesting to see the New York Metro’s competition for Beverly Hills.  Westchester is very impressive.  We really wish that we could afford to move someplace like Tarrytown.  The commute into the city wouldn’t be bad at all, and the area is just amazing.

It was pretty late by the time that we made it back to Newark.  Dominica had some more packing to do and some things that she needed to do to get ready for her week away in Texas.  So the evening was pretty busy.  Eventually she was able to work on stuff in our bedroom so we watched The Love Boat and then it was time for bed.  It ended up being almost midnight by the time that we actually went to sleep.  The alarm is set for three thirty in the morning so that she will have time to get up and get ready and be to the airport by five.  Her flight leaves at six and the airport opens at five.  So it is a short night for us.

May 9, 2008: Blustery Day

I was up until one thirty in the morning or later programming last night. There is much to be done and only a week to do it in. No time to waste.

I was up at my usual time on for a Friday. I logged in and got some work done and paid the bills.  I discovered this morning that Dominica’s college loans (from long, long ago) have been put into deferment again.  We thought that this would be a problem since it makes it more difficult for us to pay them so she called to have them removed from deferment.  But it turns out that there is no additional interest accruing on the loans while they are in deferment – part of a government plan to support continued education.  That’s awesome.  So instead of paying them off we are putting the money for them into a savings account.  It isn’t much but it gives us a two or three percent advantage on those funds until the deferment ends, and then we can just pay them.  Very cool.  That helps since we are paying for both of our continuing educations right now as well 🙁

The work today was actually a little light for a Friday.  But the bad news is that I got scheduled for work at seven thirty tomorrow morning.  The idea of having a Saturday off from “office” work has pretty much vanished.  I think that I only get one Saturday off a month.

I started heading into the office this morning but the rain and wind really picked up and I decided that it was going to be very foolish to continue on to the office in weather like this.  I like walking in the rain but three miles in heavy winds means that I would be soaked from head to toe and would be stuck sitting in the office attempting to dry out all day.  Best to stay home and actually get some work done.

No Oreo today since I was attempting to go into the office so he is at daycare.  That is best, though, since Dominica is going to be gone all next week and I don’t have any good way to take Oreo to daycare.  So he is going to be at home for nine straight days.  That is a lot for a little dog.  He is going to be bouncing off of the walls by the end of the week.

When Dominica and Oreo got home I was just wrapping up the main portion of my work for the day.  We ordered dinner from downstairs and watched Family Guy: Stewie the Untold Story or whatever it’s called.  It is the final three episodes of the fourth season packaged separately from the rest of the season.  Then we watched some The Love Boat and The Cosby Show. Then I was back into the living room to work on my homework while Min watched some of The Brady Bunch and headed to bed.  I worked on homework until two in the morning.

Tomorrow we are thinking about maybe taking a drive up the Hudson Valley to get a feel for the area.  We are very interested in the area around Beacon, New York.  But we will see when we get there.  We have no idea which areas are nice or not and which ones we are likely to be interested in.

Singleton Pattern in C#

Implementing the Gang of Four Singleton Pattern in Microsoft’s C# .NET language is nearly identical to its Java implementation. The Singleton Pattern (as definied by the Gang of Four in 1995) is to “ensure a class only has one instance, and provide a global point of access to it.”

The idea behind the Singleton pattern is that there can only be one unique object of the class in existence at any one time. To make this possible we must make the constructor private and instead create a public “get” accessor for the Instance reference that controls access to the constructor, returning a new object if none exists or returning the already instantiated object if one does.

Here we have an example of the simplest possible Singleton class which I call, Singleton. It has only those methods absolutely necessary for the pattern and one console print statement in the constructor so that we can easily see when the constructor is called. I have opted to include Singleton and TestSingleton, its testing harness, in a single file. This allows me to easily demonstrate how to create the Singleton pattern and how to instantiate a Singleton object from outside the class.

TestSingleton.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace SingletonPattern
{
    class TestSingleton
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Calling First Instance: ");
            Singleton mySingleton = Singleton.Instance;
            Console.WriteLine("Calling Second Instance: ");
            Singleton myOtherSingleton = Singleton.Instance;
        }
    }
    public class Singleton
    {
        private static Singleton instance;
        private Singleton()
        {
            Console.WriteLine("Singleton Constructor Called");
        }
        public static Singleton Instance
        {
            get
            {
                if (instance == null)
                {
                    instance = new Singleton();
                }
                return instance;
            }
        }
    }
}

Microsoft has a great article discussing the Singleton Pattern and its common variations as they pertain to the C# language in the MSDN Patterns and Practices Developers Center – Implementing Singleton in C#.

Also see: Sheep Guarding Llama Singleton Pattern in Java

Singleton Pattern in Java

Implementing a Singleton Class Pattern in Java is a common and easy task. The Singleton Pattern (as definied by the Gang of Four in 1995) is to “ensure a class only has one instance, and provide a global point of access to it.”

The idea behind the Singleton pattern is that there can only be one unique object of the class in existence at any one time. To make this possible we must make the constructor private and instead create a public getInstance() method that controls access to the constructor, returning a new object if none exists or returning the already instantiated object if one does. We must also override the clone() method from the Object superclass as this oft forgotten method will provide a workaround to our Singleton protection.

Here we have an example of the simplest possible Singleton class which I call, Singleton. It has only those methods absolutely necessary for the pattern and one console print statement in the constructor so that we can easily see when the constructor is called.

Singleton.java

public class Singleton {
     private static Singleton instance;
     private Singleton() {
          System.out.println("Singleton Constructor Called");
     }
     public static synchronized Singleton getInstance() {
          if (instance == null)
               instance = new Singleton();
          return instance;
     }
     public Object clone() throws CloneNotSupportedException {
          throw new CloneNotSupportedException();
     }
}

Now that we have a working Singleton class we need to make a simple test harness to see how we can call it and how it behaves. In our test we will simply create two objects, mySingleton and myOtherSingleton and we will see when the constructor method is called.

TestSingleton.java

public class TestSingleton {
        public static void main (String[] args) {
                System.out.print("Calling First Instance: ");
                Singleton mySingleton = Singleton.getInstance();
                System.out.print("Attempting to Call Again: ");
                Singleton myOtherSingleton = Singleton.getInstance();
        }
}

Hopefully this will help you write quick and easy Singleton pattern classes in the future.

See also: Sheep Guarding Llama Singleton Pattern in C#

May 8, 2008: Beginning My Programming Project

I had to play catch-up with the SGL posts today. I was running a little bit behind. I didn’t have a chance to even open the editor yesterday and May 5th was still sitting in my “drafts”. But I got caught up. Now that my huge Red Hat exam project is over I am able to focus on more things and get caught back up.

Brass Plaque of 1180 Raymond Boulevard, Newark

Today is a doggy-daddy day. The weather has turned dark and threatening. Not like the warm summer days we have had the last few days. It is still pretty warm but very humid and overcast.

Oreo insisted on another walk in the park today. This is his third this week taking one on Sunday, another on Tuesday and one more today. The temperature was perfect and the clouds and humidity were perfect for making the city seem almost silent. I always find it strange walking Oreo in the park in the heart of a major city, surrounded by skyscrapers, and having the world be so quiet and still. There was just the slightest drizzle as we walked through Military Park.

I forgot to mention yesterday that another Amazon order arrived. We got a pack of Rock Hudson movies and a pack of the Bob Hope & Bing Crosby classic “On the Road” movies like Road to Morocco. Classic stuff. We also got the three final episodes of the fourth season of Family Guy which are sold separately from the rest of the season. Another eBay computer arrived today as well. This one is an ultra-small form factor HP Compaq d530. Nothing special but I love these tiny form factor machines. They are just so easy to deal with.

Dominica did some light shopping on her lunch break yesterday and decided that we needed the first season of The Brady Bunch which is pretty funny to own. I suppose it will be interesting to see the show starting from the beginning. It is such a quintessential piece of the childhoods of just about anyone anywhere near my age that it is hard to think of it as being like a normal television show. And it only existed as reruns which were shown disconnected and out of order. So to many of us there was no flow whatsoever in the show. It was just a serious of vignettes. So now we will see it as an actual show and see if that improves it in any way. I think that she was thinking about The Brady Bunch as we recently saw two of the actors show up in the first season of The Love Boat and we also saw two who did a guest appearance on the final season of That 70s Show.

I wasn’t as tired today as you might think that I would be having worked so late last night. I feel so much better having so much work completed and out of the way that I really have a lot more energy.

Dominica got home and we just got simple food from the deli downstairs.  We ate and watched and episode of The Love Boat. Then Min was off to bed and I went to work on my Java project.  I am attempting to properly incorporate some basic design patterns into my project like the Model-View-Controller and Singleton patterns.  So far this project is moving along while still being quite educational.