Archive

Archive for the ‘Dotnet’ Category

GOF Series: Episode #2 [The Abstract Factory]

August 7th, 2008 Simon Segal No comments

The pattern a day keeps the doctor away series continues. In the last instalment of the series we looked at the Factory Method pattern, this time we look at the Abstract Factory Pattern. The abstract Factory Pattern is useful in creating groups of related object types without a requirement to create their concrete types explicitly and achieves this by using composition where a class delegates the role of object instantiation to another class. This pattern can be described in UML like this:

Click to see in full size

The tests included (as per below) are for the purpose of demonstrating the code and are not meant to be taken as complete unit tests.

   1:  [Test]
   2:  public void AbstractFactoryTest()
   3:  {
   4:      //set an earlier time to that 
   5:      //when the document is created
   6:      DateTime earlier = 
   7:          DateTime.Now.Subtract(new TimeSpan(0, 1, 0));
   8:      //create the mock of the AncillaryService
   9:      var mock = 
  10:          new Mock<AncillaryService>(new 
  11:              LitigationSupportFactory());
  12:      mock.Object.
  13:          SetupProject("My Test Lit Support Project");
  14:      //use the factory method that create a new document
  15:      //using the mock instance object.
  16:      Document litDoc = 
  17:          mock.Object.
  18:          NewDocument("Lit Support Test Document");
  19:      mock.Object.
  20:          PersistDocument(litDoc);
  21:      //perform the tests for 
  22:      //the Lit support factory
  23:      //and the client (AncillaryService) 
  24:      //that has it in its composite.
  25:      Assert.IsTrue(litDoc is LitigationSupportDocument);
  26:      Assert.IsTrue(litDoc.Name == "Lit Support Test Document");
  27:      Assert.That(litDoc.DateCreated.Value > earlier);
  28:      Assert.IsTrue(File.Exists
  29:          (@"C:\DevFileDrop\Lit Support Test Document.litdoc"));
  30:   
  31:      mock = 
  32:          new Mock<AncillaryService>(
  33:              new ImageWorkflowFactory());
  34:      mock.Object.SetupProject("My Test IW Project");
  35:      ImageWorkflowDocument iwDoc = 
  36:          mock.Object.
  37:          NewDocument("IW Test Document") 
  38:          as ImageWorkflowDocument;
  39:      mock.Object.PersistAll();
  40:      Assert.IsTrue(iwDoc != null);
  41:      Assert.IsTrue(iwDoc.Name == "IW Test Document");
  42:      Assert.That(iwDoc.DateCreated.Value > earlier);
  43:      Assert.IsTrue(File.Exists
  44:          (@"C:\DevFileDrop\IW Test Document.iwdoc"));
  45:  }

The code above assumes the AncillaryService, LitigationSupportFactory and ImageWorkflowFactory classes (which are indeed in the download code. The link to the FULL example code can be found here and comes with all previous modules in the series and the accompanying power point presentation to explain each pattern in detail, so I wont repeat that content here.

Share/Save/Bookmark

Smart Developers are not semi invested Developers!

July 20th, 2008 Simon Segal 1 comment

What do you look for when interviewing developers. It’s a question that every manager needs to consider when hiring new staff and there are always a number of questions to ask, on both the technical and cultural aspects. I am not going to talk about the ‘culture fit’ (gratuitous HR terminology) here at all and the only technical aspect under consideration in this post is to do with how much effort I can see the candidate putting into self improvement and what level of interest they have in their profession.

How it works.

The bored-cat idea behind ’semi invested’, revolves around only being interested enough to do the absolute (or close enough to) minimum in self development, or in harbouring a belief system that requires personal growth be the responsibility of the anyone else but yourself. I am not making excuses here for employers who do not invest in the their staff’s growth through training, but I don’t believe that it’s entirely the purview of the employer to be responsible for individual learning and growth.

So what is self development and how does it manifest? I usually start the quest in understanding how career invested developers are by asking, what was the last programming book you read? And quickly followed by when did you read the book? Here is a more complete list of questions that I ask (under interview and from time to time with staff) to get a feel for how much thought is going into self improvement.

How to find out.

  • What Technology or Development newsletters do you subscribe to?
  • Whose blogs do you follow?
  • What magazines do you buy?
  • Which Podcasts do you listen to?
  • Which Webcasts do you watch?
  • What user groups do attend?

brain When I get a positive answer to one of these questions, it can quite often lead to a good discussion as to where the perceived and or real value is in utilizing the content found on or in the method chosen and how each individual turns the exercise into a positive learning experience. If I get a negative response on all fronts and that is to say that the individual in question apparently has no interest and invests no time in the professional world around them (given that they proffer no alternatives), then it’s generally a pretty short interview.

Life wasn’t meant to be easy (who said that?)

Now if I sound as though I am being a little harsh on your average Joe or Joanne developer, well then so be it, I make no apologies. Its my goal to ensure that I have encouraged my teams to be as interested as possible in what they and their colleagues do for a living and my experience tells me that groups of ‘invested’ individuals flourish together and grow into great teams and this leads to great software.

Share/Save/Bookmark

The odd little "vote of no confidence".

June 27th, 2008 Simon Segal 1 comment

Well it looks like some members of the DotNet Community have decided to take a nutty very strange and unusual position of biting the hand that feeds, by posting a petition of signatories to a VOTE of NO Confidence in the Entity Framework (soon to be released).

Three questions arise from this:

Do I disagree with their main assertions?

Simply the answer is NO, I do NOT disagree with any of the points made in the assertions on the petition. In fact I believe their contribution, in dispensing opinion based on real world business experience to the development community is enormously valuable and to be considered seriously by developers where it’s appropriate. However I am not so sure about their skills in diplomacy.

Why do I think this is nuts strange?

mr_angryMicrosoft know very well what the position of this collection of people is and the thing that stuck out to me as being “off”, was the title of the exercise and even perhaps the method. Firstly, using a petition denotes a protest more than it does a community warning or announcement and secondly, the title of the petition “Vote of No Confidence”,  I think is less than diplomatic and sounds a little desperate.

What will the Founders think?

I will be interested to note how this plays out with the contribution of the Data Programmability Advisory Council (the fathers of DDD) who oddly enough are not signatories of the petition………

Share/Save/Bookmark

Creative Commons Attribution-ShareAlike 2.5 Australia
Creative Commons Attribution-ShareAlike 2.5 Australia