January 2009 Entries
In november 2007 our old desktop finally passed away. In the midst of our grief we were faced with the need for a new machine. To support my wife's mobile lifestyle we decided to get a notebook. In our hurry we purchased a 15" MSI notebook and upgraded the memory. All told the cost was about AUD $1400 .
By february I needed a new notebook myself. I bought a
Dell Inspiron 6400 - probably the ugliest notebook on the market at the time. The Dell cost me AUD $998.
The MSI was expensive, has been unreliable and has an awful compressed keyboard with a full numeric keypad. The Dell has been an indispensable business tool; fast and rock solid.
So maybe you can't judge a notebook by it's cover?
Very occassionally I need to mock a service that must do something more than just returning a value. Consider the contrived example of a Worker object that has a property called Count. During the execution of the function under test the Worker object is passed to an IIncrementer service to increment its Count property by one.
[Test]
public void DoStuffTest()
{
var incrementer = new Mock<IIncrementer>();
WOrker worker = new Worker(incrementer);
incrementer.Expect(i => Increment(worker));
worker.DoStuff();
Assert.AreEqual(1, worker.Count);
}
The test will fail because the IIncrementer mock didn't increment the count as expected. We can fake the required behaviour using Moq's Callback feature.
[Test]
public void DoStuffTest()
{
var incrementer = new Mock<IIncrementer>();
WOrker worker = new Worker(incrementer)
incrementer.Expect(i => Increment(worker)).Callback((Worker w) => w.Count+= 1);
worker.DoStuff();
Assert.AreEqual(1, worker.Count);
}
And now the test passes. This feature is extremely useful for services that do their work by changing the state of an object that is passed in, rather than returning a new object.
Presentation models, or
screen-bound DTOs, are are lightweight classes tailored to the needs of the screens on which they are used. The obvious benefit is that they remove some of the work required to translate between domain model objects and user interface elements. Work that is usually performed by the view and controller in an MVC context.
A secondary benefit of presentation models is that they explicity define what can be bound to domain model objects. Automatic binding such as Asp.net MVC's ComplexModelBinder and UpdateModel method can potentially allow a malicious user to bind data to properties that the developer didnt intent. For example when saving their profile they could add an extra form parameter called 'Role' and set its value to 'SuperUser'. If the controller is using ComplexModelBinder or UpdateModel and the domain model object has a property called 'Role' then it could well receive the unintended 'SuperUser' value. Because the presentation model would not have a writable property called 'Role' it would prevent this exploit.
In the pursuit of simplified views and controllers I am starting to use presentation models more often. The security benefit is just another justification to overcome the extra work.
I finally feel I have a setup that works. The window provides natural light and a long-range focal point. Three screens are just awesome. Behringer powered monitors for cranking the tunes.
For anyone contemplating a triple monitor setup here are some points to keep in mind:
- try to get screens that have similar hight and resolution
- you will need a second video card and therefore a motherboard with two pci express slots
- the two video cards must have the same architecture. ie you cannot mix nvidia and ati chipsets.
- Never use a metaphor, simile, or other figure of speech which you are used to seeing in print.
- Never use a long word where a short one will do.
- If it is possible to cut a word out, always cut it out.
- Never use the passive voice where you can use the active.
- Never use a foreign phrase, a scientific word, or a jargon word if you can think of an everyday English equivalent.
- Break any of these rules sooner than say anything outright barbarous.
Could not load file or assembly 'antlr.runtime' or one of its dependencies. The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))
All of a sudden I started to get assembly load errors for antlr. Process monitor showed me a BUFFER OVERFLOW was occuring in the Asp.net temporary folder (C:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files).
So I deleted the Temporary ASP.NET Files folder and got a different error:
The current identity (NT AUTHORITY\NETWORK SERVICE) does not have write access to 'C:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files
I then recreated the Temporary folder and gave NETWORK SERVICE write permission, and now it works.
For me, this error was caused by MvcContrib and Castle binaries being out of sync. So the fix is to make sure you have corresponding versions.