Posts

The Pragmatic Programmer

My copy of this book has just turned up. I am book hungry these days, can't wait to read it :-)

Connascence

I’ve just finished reading What every programmer should know about object oriented design . The first couple of sections are a bit useless really, but the 3rd section is very good. I particularly liked the section on the difference types of connascence in software. There’s some basic information about it here if you fancy a brief overview of what it is about. It’s a really good book, I recommend you read it! Should only take a day if you only read the 3rd section.

I've just ordered a Java book

Image
http://java.sun.com/blueprints/corej2eepatterns/index.html It was only $0.41 used in the USA, came to about £6 with posting to the UK. I don't write Java and at the moment have no interest in learning it, but I expect I will be able to read it without problems (never really looked at it). So why did I buy this book? Because it is about this... That's why :-)

Prism - Invariants, and pre/post conditions - update

Just found out that I can do this too public invariants   Overdraft >= 0 : ’OverdraftGreaterThanOrEqualToZero’;   Balance + Overdraft >= 0 : ’BalancePlusOverDraftGreaterThanOrEqualToZero’; end; Then in my handler routine I get that message! if not IsValid then   throw new Exception(ErrorMessage); Excellent :-)

Prism - Invariants, and pre/post conditions

I’ve been looking at Prism some more recently. I’m a bit annoyed with myself really because someone has been telling me to look at it for years but I wanted to concentrate on C#. Now that I am looking at it I see things in there which I really like. Recently I am looking at invariants, pre-conditions, and post-conditions. First let me show you the invariant support. An invariant is like a class constraint, it specifies a condition which must be true but when must it be true? type   BankAccount = public class   public     property Balance : Decimal read write;   public invariants     Balance >= 0;   end; The invariant is enforced each time a public method exits. Actually it is enforced after the post-conditions of a public method exits but we don’t have any post conditions yet. class method ConsoleApp.Main; begin   var account : BankAccount := new BankAccount();   //The next line throws an assertion error   account.Balance := -1; end; Property getters and setters are considered

Injecting into the ECO cache

In my previous post I showed an interface ILockable. The actual interface is public interface ILockable {   Guid GetLockID();   Type GetLockObjectType(); } Any lockable resource implements this interface. In its constructor it creates an instance of a class which descends from LockObject, a Document class for example would create an instance of DocumentLockObject which descends from LockObject. The "Document" class would store away the ID of the DocumentLockObject in a private attribute. Now when my LockingService is asked to lock multiple (un-related) instances which implement ILockable I want to do this 1: Create a new EcoSpace 2: Load objects efficiently 3: Get locks 4: Update the DB 5: Dispose of the EcoSpace If I experience an OptimisticLockingException then loop and try again. The item I would like to discuss is #2, "Load objects efficiently". In my model a LockObject has a *--1 association to Session identifying which session has locked it, I want to en

Setting the ID of an ECO object before it is saved

This might seem like a bit of an odd requirement. I am currently implementing an offline pessimistic locking service in an ECO app. This will mean that I can use a LockingService to place read/write locks on objects. As usual I have gone for an interface approach (ILockable) rather than making all my lockable classes descend from a base Lockable class. Remember, it's what I DO , not what I AM . The idea is that I have a Lockable object which holds a list of Sessions. These Sessions indicate who has a read lock, and who has a write lock on the object. Each ILockable business entity will create its own private instance of Lockable when it is created. The thing is, this application will at times need to lock thousands of objects in as little time as possible. As there is no common ancester for these ILockable classes I can't just use EnsureRelatedObjects to traverse an association name and load all LockObject instances in a single select. I decided that what I needed was to