All UTC Time are NOT the Same

A friend pointed out that all UTC Time is not the same. When he told me, I responded with “What!?! What are you talking about? It’s the same.” “No it’s not” he said. He explained, that yes using UTC will allot you an agreed upon time format but that does not guarantee that both server’s clocks are synchronized.

For example, Sever A calls server B for updates. Both Servers use UTC Time. Server A sends over a timestamp, how do we know that the two servers clocks are synchronized and that the two times match, we don’t. The odds are they are not. How can they be? Absolute time does not exist. It’s all relative. By using a timestamp to retrieve data from another server you are making an assumption that both servers have the same time.

*photo reference

Posted in Data | Leave a comment

Quick and Dirty on Migrating Data

I had a great talk with my friend Dave today. He’s a Data Scientist. He knows his stuff, for sure.

We talked about a number of things, but one that really stuck out was data migration. He says never to migrate via code, use a tool. You are reinventing the wheel. You are locked into your solution. All the risk is in your court. And the solution is not flexible. With that said. He went on to say the most efficient way to move data is with a primary key and a hash.

The destination side will request all the primary key and row hash. Taking the primary key it will check if the row exists. If it does exist it will compare the hash of the source to the hash of the destination row. If they match then the process is repeated for the next row. If they don’t match, then the primary key is added to a list of rows to request from the source. If the primary key does not exist then the primary key is added to the list of rows to be retrieved from the source. When the row comparison is completed all the rows that are stale or do not exist are requested from the source and persisted to the destination.

Grunt

If you enjoy grunt work you’ll do the above. If you are a developer who enjoys building robust applications you’ll leave the grunt work to the tools.

*Image reference

Posted in Data | Tagged | Leave a comment

Understanding the Problem

A recent discussion at work got me thinking…

A bug was reported in one of our products. A co-worker was tasked with finding and fixing the problem. His approach was to deploy new code from development into qa. The reasoning was that many bugs had been fixed since the issue was first reported. We might have already fixed it.

At first blush this makes perfect sense. Why worry about something when it could already be fixed. If we can’t reproduce it, then there is no issue.

But had we really fixed the bug? It reminded me of a phrase from the Pragmatic Programmer, called “Coding by coincidence.”

Had we really fixed the bug? Until we witnessed the bug and tracked down its cause we don’t know. Maybe we had, maybe we hadn’t.

If we could not witness the bug in action and then made a change to the code and then witnessed the bug not occurring we would not know it was fixed. Even if the newly deployed code did not exhibit the symptoms we don’t know if the bug was actually fixed or the symptoms simply suppressed.

my ladybug turned black...........:D

Posted in Architecture, Lesson Learned | Tagged | Leave a comment

ASP.NET MVC Routing Shortcoming

Recently I’ve been working with ASP.Net Routing. It has some cool features. I particularly like how the RouteValueDictiontionary works. Give it any type and it will reduce the type to a key/value pair. Awesome! The tokenized routes are another lovely feature, so are the default values.

A pain point I’ve encountered is route evaluation.

For example if you have 10 routes:

  1. mq/s
  2. mq/t
  3. mc/e
  4. mt/t
  5. mt/r
  6. ms/s
  7. tr/r
  8. kl/d
  9. kl/c
  10. kl/x

The routes are evaluated in the order they appear. This is logical. Evaluating a route consists of processing the incoming url and attempting to extract data from it. If no data exists a null is returned to the Routing Engine and the next route is tried. The issue I have is there is no smarts built into the route evaluation. It iterates over the route collection. For example if my route is the last one “kl/x” the first 9 have to be checked before it reaches the correct one. I’m assuming all the routes are relative to the root of the site. Why couldn’t there be a pre-evaluation to eliminate the routes? For example, I’ve requested kl/x. First 9 will be processed before kl/x. Why can’t the routing framework determine that 8, 9, 10 are the closes possible matches? Instead processing 9 routes we process 3.

This gets bigger when custom constraints are added. Say, for each route there is a constraint that looks up a user in the database then the database will be hit 10 times for the same data! Sure you can throw in caching, but that’s not the point.

Wrapping this up, Routing works great for 80 percent of the cases. It’s a good little framework with a few tweaks it could go from good to great.

Posted in Architecture | Tagged | Leave a comment

What Happens When…

What happens when there is a single standalone class.

A need arises for a second, slightly difference class. A base class is created. Both classes now inherit from the base. All is in harmony.

In testing it is discovered that some of the internal functionality of the base class is need to test the two implementations. How do you handle this? Expose the internal method as public? Move the internal method off to another class and make it public static? How about a re-implementing it?


image reference

Posted in Architecture, Code | Leave a comment

PST file size versus Sql Server file size

I’m a bit of a pack rat — I don’t throw anything away, including emails.

In 1998 I started using Microsoft Outlook. For the time it was a great program. The best feature was the integrated MS Word support as the editor. Now that is common place, but back then it’s was the cats meow.

Over the years I’ve saved my PST files into an archive, it has grown to over 10 gigs. It was time to extract the messages and store them in a more searchable medium. I’ll be posting more on what I’m doing later. To my point, I am blown away with the size difference between the PST file format and the Sql Server.


*Image Reference

Stats

Emails: 51574
Attachments: 8637 (yes, I have saved everyone of the attachments to the database)

PST: 8.9 gigs
Sql Server: 368 MB

I don’t know the inner workings of either product. Sql Server is optimized for data storage, Outlook is apparently not. I’m not surprised that SQL Server has a much smaller footprint. I’m surprised by the degree of which SQL Server is smaller.

Posted in Uncategorized | Leave a comment

Unit Testing ASP.NET Routes

We are implementing routes. There are specific requirements around the tokens. We have 10 to 12 scenarios to test. Getting them wrong is not an option.

Using FakeItEasy (check it out if you have not, it’s a kick ass little mocking framework) here is the code I used to mock the routing.

Phil Haack has a great article on the subject.

    public abstract class RouteTestBase
    {
        ///

        /// Gets the route data. Only pass in relative urls: ~/t/r/HeroRocksf9173ed1c882481fbe9681e8236fc98cu15zc4e3mhm/50006/42006_42006
        /// 

        ///
The URL.
        /// 
        public RouteData GetRouteData(string url)
        {
            var virtualPathProvider = A.Fake();
            A.CallTo(() => virtualPathProvider.FileExists(A.Ignored)).Returns(false);

            var routes = new RouteCollection(virtualPathProvider);
            routes.Add(new Route(...));

            var contextBase = A.Fake();
            var request = contextBase.Request;

            A.CallTo(() => request.AppRelativeCurrentExecutionFilePath).Returns(url);

            return routes.GetRouteData(contextBase);
        }
    }
Posted in Code | Leave a comment

Random Characters in C#

A coworker devised a clever way of creating a random set of characters:

			string channelExternalId = string.Format("EID{0}", Path.GetRandomFileName());
			string adExternalId = string.Format("EID{0}", Path.GetRandomFileName());
			string commissionableActionExternalId = string.Format("EID{0}", Path.GetRandomFileName());
Posted in Code | Leave a comment

Programming is Much Like Riding a Bike

One can study the laws of gravity, understand the mechanics of a bicycle and explain in detail how to ride a bike. This information will not teach someone how to ride a bike. To learn how to ride a bike one must ride the bike.

Software programming is much the same. Learning theories, patterns and getting certifications don’t teach someone how to program. It must be learned through experience.

Posted in Uncategorized | Leave a comment

Ditching the Laptop, Moving to the Tablet

I sold my laptop and replaced it with a tablet. The biggest challenge to moving to a tablet is to maintain the ability to code C# on the road.

A text editor is always an option, but that does not solve the compiling problem. Looking around I discovered that most tablets support Bluetooth mice and keyboards. I’ve concluded that there will not be a visual studio android app anytime in the future. This means I have to get into an environment where I can code and compile C#. I have one option: to remote desktop into a machine.

There are a number of remote desktop apps for the android. I settled on the WYSE Pocket Cloud app. It’s a full screen solution that runs over the remote desktop protocol. It works similar to other web based solutions such as logmein. Logmein does have an app, but it’s twice the cost and lacks some of the features of the WYSE PocketCloud app.

My tablet setup looks like this: A Samsung 32gig 10.1 tablet, a Logitech Bluetooth keyboard for the android and a Bluetooth mouse. This gives me the flexibility of a laptop and the benefits of a tablet.

Posted in Uncategorized | Tagged | Leave a comment