Wednesday, March 31, 2010

Comparison of Creational Patterns

According to my experience, you may use each pattern as follow:

1- The Builder pattern is concerned with building a single complex object
(by including the concept of a director that depending on different factories).

2-
The Abstract Factory pattern is concerned with building families of related products (where there are many product hierarchies and a factory for each family of products).

3-
The Factory Method pattern is concerned with instantiating a subclass
of one class hierarchy (where there is a specific reason why one subclass would be chosen over another).

Saturday, March 27, 2010

C# implementation of Builder pattern

The builder pattern Separates the construction of a complex object from its representation.

The players in this pattern are:
1. Product (Room)
Represents the complex object which includes many classes(parts)
2. Builder (RoomBuilder)
Specifies an abstract class or an interface for creating parts of a Product object
3. ConcreteBuilder (WoodBuilder, GlassBuilder)
  • Constructs parts of the product by implementing the Builder class/interface
  • provides a way for retrieving the product
4. Director (House)
Constructs an object (room) using the Builder class/interface

So, you use the Builder pattern when:

  • the object to be constructed has many parts and might have different representations.
  • you need control over the construction process.

Monday, March 22, 2010

C# implementation of Abstract Factory pattern

The Abstract Factory pattern takes Factory Method Pattern step further, creating families of related products.
The abstract factory can be refined to concrete factories,
each of which can create different products of different types.

The pattern isolates the product definitions and their class names from the
client so that the only way to get one of them is through a factory. For this reason,
product families can easily be interchanged or updated without upsetting the structure
of the client.
An interesting aspect of the Abstract Factory pattern is that the whole product family
can be changed while the application is running.


Friday, March 19, 2010

Easy ArcGIS Library is now on Code Plex

Hi All, I moved my project Easy ArcGIS Library to code plex
http://eagl.codeplex.com/

Download the recent version with docs there.

Sunday, March 14, 2010

Java vs C# Performance Benchmarking

I'm a Java fan, but I use C# 99% in my job, so yesterday I was looking at a good EJB book (EJB 3 in action) while enjoying my coffee (the real one not the Java one ;).
I had a look at some EJB vs .NET benchmarks and I was shocked to see that .NET is much more faster than Java in the enterprise wild, so I decided to do some SIMPLE benchmarking myself.

Benchmarking Tests
I've wrote 3 really simple tests in both Java and C#, the first tests simply loops over an array 1000,000 times while doing some multiplication math, the second test loops over an array 1000,000 times too but while doing some more complex math, and finally the final tests that creates 1000,000 objects and saves them in an array.

I repeated each test 100 times, took the average of them as a final result, so I can be sure of the accuracy.

Friday, March 5, 2010

Programming ArcObjects is now easy

Have a look at the new version of EAGL, new namepace for graphics is added.
EAGL is open source C# .net library that facilitate programming with ArcObjects.

http://code.google.com/p/easyarcgislib/

Wednesday, March 3, 2010

C# Implementation of Factory Method Pattern

Factory Methods encapsulates the creation of related objects
(the Productes) by letting a class (the Creator) deciding which class to instantiate depending on a specific reason.
For example, in case that the creation process depends on user input .

In the world of GIS, there is a map which includes many various layers.
The client chooses what kind of Layers to be added to a given map .