Posts

Showing posts from 2009

codepaste.net

Following on the example of @gblock I decided to tryout codepaste.net. Maybe this will be the answer to pasting snippets instead of pasting them in code here.

sample

Difference Between Adapter and Bridge Design Patterns

As I was preparing for an upcoming presentation on the topic of Design Patterns, I was studying through the different patterns and could not differentiate between the Bridge Pattern and the Adapter Pattern. Right off the bat both of those patterns fall into the category of structural patterns. Both of those patterns allow us to take advantage of the Liskov Substitution principle. Both patterns allow us to swap out implementations.

It seems that I am not alone in getting confused in the disctintion between these two patterns. A simple google search with the phrase "bridge and adapter pattern" returns quite a few results. Here is an article in code project that illustrates the difference to a certain degree.

What came to mind in trying to determine the pattern required is the forces at work. This something that Steve Tockey pointed out when determining what pattern to use. He said basically that an engineer does not wake up one day and say "I think I will build a suspension…

The Boy Scout Principle

Earlier this week I helped out a junior colleague to solve a problem. I really just told him the quick fix. The fix involved overloading a method and accessing a property through reflection. Why reflection you ask? Well the code was written that way. All we had to do was follow suit and use reflection to access the property that we needed. The use of reflection made the code extremelly ugly and difficult to read. I didn't pay much attention to it so I provided the answer on how to access the property and went on my merry way.

When I got home I was going through my tweets and found the following link in a re-tweet by Uncle Bob (@unclebobmartin):

http://www.se-radio.net/podcast/2009-11/episode-150-software-craftsmanship-bob-martin

I listened to this podcast in it's entirety. In it Bob Martin talks about the different disciplines related to software craftsmanship; TDD, CI, etc. In particular one thing caught my attention. That was the concept which he refers to as "the boyscout…
Recently there's been a number of performance complaints amongst my team of developers. While we are looking at certain options for future procurement, here are some simple steps that you can take to improve your systems performance.

1. Defrag often
2. Delete or archive files that you haven't used in the last two months
3. Run disk clean-up

Also here is a good article on improving your computers performance

http://support.microsoft.com/kb/308417


You may already have the functionality to go directly to your system settings

1. My Computer-Properties
2. Navigate to the Advanced Tab

3. Select the settings for the Performance

4. There is a number of options you can set there. Rather that going over all the different options please visit the link provided above.


Visual Effects alone seem to have improved performance significantly in my case.

Remote Access to Your Home Desktop Using No-IP

In the last few weeks a co-worker introduce me to www.NO-IP.com. At the time I was looking for a way that I could access my home computer from work. With NO-IP.com you can do just that.

NO-IP.com provides a way to connect to your home computer, or any other computer for that matter, from anywhere as long as you have access to the web. The connection is established by normal means through Remote Desktop. Under normal circumstances you can configure your computer and access it through the router's IP. The problem with that is that your router's IP is Dynamic. Meaning that it changes frequently. So while you may be able to access it one moment you will not be able to access it the next.

To solve dynamic IP address problem NO-IP.com provides you with a way to connect to it through a web address and it handles the connection and IP mapping for you.

Before you begin to connect to your home computer there is a series of steps that you must complete. No-Ip has the complete instr…

When you buy a house don't pass on the downpayment

A while back I had a conversation with a friend. This friend told me the calculations of putting 20% down versus not putting the 20% down towards a new house revealed that the monthly payment would not go down by much.

I thought about it and did my own calculations. Let's take as an example a calculation with the following characteristics.

Price: $100,000
Down Payment: 0%
Term: 30 Years
Interest Rate: 6%
Payment: $599.55

If instead you put the 20% down, you end up with a payment of 479.64. That doesn't seem like much. So let's say that instead you went with a 15 year fixed mortgage. Your payment would now be $632. That's assuming that your interest rate went down to 5% because you took a 15 year mortage instead.

Ok, so you still end up paying a bigger payment with a 15 year mortgage. That's true, but that's only $32 more dollars for 15 years instead of $599 for 15 years (only counting first 15 years of both mortgages). The former is equal to $5,760. The latte…

The Token Anti-pattern

Over the last several years or so, I have observed something that I refer to as "The Token Anti-pattern". I have seen this pattern rear its ugly head as a way of passing parameters from one class to the next. The parameters are neatly wrapped up as properties of a class.

In the worst case that I've seen the Token had about 20 properties that were not cohesive, making the token class itself non-cohesive. It was a scenario where the process was basically a work flow. The workflow stepped it's way through many steps. Many of the steps branched out to different paths, calling out other objects. The token was passed to these other objects. The different paths required different pieces of information as preconditions. These pieces of data were attached to the "Token" along the way. The token for one path would have property1, property2 filled but property3 null. Whereas for a different path property1 would be null and property2 and property3 would be fille…

IoC Container Vs. Service Locator

I had a conversation over the weekend with one of my colleagues because I didn't understand the difference between an Inversion of Control (IoC) container and a Service Locator. After our twitter conversation, I had to go back and read the article by Martin Fowler on the topic. Although the article is dated, it provides some valuable information. That information along with my colleague's information clarified the difference.

The confusion was mostly because both tools provide similar services, both provide run time resolution of dependencies. Also when improperly used, an IoC container can be used in the same fashion as a Service Locator can- as was the case in one of my former projects.

Before I get going too far, let me explain what I mean when I say "run time resolution of dependencies". In order to write testable code in OO we have to write classes that are loosely coupled. No coupling at all would be optimal (for testability), but as any programmer knows, that is…

Using KISS with Demos

I recently prototyped a simple application to see how the simplest form of posting and receiving messages using MSMQ worked. The prototype was a simple WinForms application with two buttons - one for post and one for receive - and a rich textbox to log the activity. All of the logic for the process was in the event handlers for the two buttons. There was no MVP, no separation of layers, no unit testing. The whole form file was no longer than maybe 80 lines of code.

I showed the demo to one of my colleagues and he shook his head in disappointment. Being that we have recently paying attention to the craftsmanship movement on DDD, BDD and the like he asked "Where is the MVP? Where are the unit tests?". I proceeded to explain to him that it was all a simple test that I wanted to perform and I didn't want to clutter my code with unnecessary complexity. Besides, the code was very straight forward and did nothing useful other than demonstrate how to post and receive trivia…

Reasons to Stay Away from CSLA

We've been using CSLA - Component-based Scalable Logical Architecture in a product for approximately one year and while it solves quite a few problems it violates some major good practices.

No Clear Separation of Layers

While at the time that we chose CSLAwe knew very little about domain driven design, it is no excuse for the framework to possess the data access layer within the business object. This makes it extremely difficult to separate the concerns. As a result, it is difficult to mock the data-access layer creating many problems when attempting to perform unit tests. This also puts the additional responsibility of data access on the business object class, violating the Single Responsibility Principle(SRP). Data access layer should be totally separated from the business object period. Having the data access within the within the BO class is not the only additional responsibility placed on the class but is the most significant one I can think of.


No Context Validation

In the CS…