On 10 May, we had our “second wedding” in Australia! It was awesome and we had a really good time with friends and family 🙂
More photos here:
http://flickr.com/photos/soosun_and_james/sets/72157605121741281/
On 10 May, we had our “second wedding” in Australia! It was awesome and we had a really good time with friends and family 🙂
More photos here:
http://flickr.com/photos/soosun_and_james/sets/72157605121741281/
Just finished reading “The Long Tail – How Endless Choice is Creating Unlimited Demand” by Chris Anderson. In summary, the long tail is about selling small volumes of a vast variety of items instead of large volumes of a small number of “hits”. This possible when the cost of distribution to geographically distant customers is low and the cost of storage for stock is not a concern (eg, intellectual property in electronic format, JIT manufacture). Popular companies capitalising on the long tail include eBay, Amazon, Google Adwords and Lulu.
The book has a lot of interesting stories and statistics but tends to repeat itself often. The long tail idea is probably not new to most readers these days, and I think if you’re familiar with Amazon, there’s little that comes as a surprise. However, I did find an interesting section in the book about the tyranny of choice. Anderson suggests that choice is good, customers want choice, and choice is only a problem if you don’t know what to choose to suit your taste. Hence, an important part of a long tail business is helping people find what they want (ie, filter out noise) in all the vast array of choices. He suggests using user reviews, rankings, sorting etc as means to help people find the “best” choice for them. I also hadn’t come across Lulu before – looks worth checking out, a site for mini self-publishing.
Home made ginger beer is awesome, and not hard to do at all. It takes a few hours to prepare all the ingredients, then several days fermentation, then another hour or two for bottling. Usually I make about 8 or 9 1L bottles of ginger beer in a batch, and I like to make it less sweet than the commercial stuff. It is slightly alcoholic (1-2% approximately) and has a really nice gingery bite the goes well with pizza, spicy food or just about anything else! I use a recipe adapted from the Ye Olde Ginger Beer Recipe. It is as follows:
Ingredients
Method
1. Fill pot with water and put on to boil
2. While the water is coming to the boil…
3. When the water has boiled ….
4. Use the jug to pour the mixture into the carboy and top up to 9L with boiled water (cooled to blood temperature)
5. Seal the demijohn with the bubble seal (I use salt in the water to sterilize the seal)
6. Stand the demijohn in a warm place for 48 hrs or for several days in a cool place
7. After 48 hrs pour the mixture through the sieve into the jug and fill the bottles leaving an air gap for the pressure to build up in (1L into each bottle). Screw the caps tightly onto the bottles
8. Leave the bottles at room temperature for 24 hrs (to generate the C02 fizz)
9. Put the bottles in the fridge for 2-3 days to allow the yeast to settle
10. Drink and enjoy 🙂
Notes
If you ferment the mixture in the carboy for longer before bottling, it will be less sweet and more alcoholic.
In .NET 2, it was all the rage to make hand-crafted, clever IDisposables that let you do a bounded action with clean up. Eg,
void SomeMethod() { using (new SetCursorToWaitEggTimer()) { VerySlowOperation(); } } void VerySlowOperation() { ... etc ... }
This was kind of cute – you could make sure that, even if an exception was thrown, your clean up (eg, changing cursor back to normal) would occur. Implementing the IDisposable was a bit ugly but consuming it wasn’t bad.
Now, with the sexy C# 3 syntax, you can do something similar much more elegantly. Eg,
void SomeMethod() { DoWithWaitEggTimer(VerySlowOperation); } void DoWithWaitEggTimer(Action action) { try { Mouse.OverrideCursor = Cursors.Wait; action(); } finally { Mouse.OverrideCursor = null; } }
If you’re feeling like more adventures, you can also start passing these delegates around and injecting them. For example:
class SomeClass { public ActionRunSlowCode { get { return runSlowCode ?? new Action (a => a.Invoke()); } set { runSlowCode = value; } } Action runSlowCode; void DoSomethingSlow() { RunSlowCode(PullDataFromExternalSystem); } }
This approach allows you to inject the delegate for what happens when slow code is run. So you could inject DoWithWaitEggTimer() or something new like DoWithWaitMessageDisplayedToUser(). Similarly, it could be used for unit testing or injecting between layers in your application.
The default access modifier for the members of a C# class (eg, fields, methods, and properties) is ‘private’. As such, I recommend never using the redundant ‘private’ keyword for class members. Leaving off the private nicely separates your privates from your public/inheritable interface in syntax highlighting. It also saves people having to read redundant code – you wouldn’t want your code to be full of un-needed casts, or redundant ‘this.’ references, would you?
Working in WPF is quite exciting – there’s a lot of new possibilities, especially with easy control composition, much improved binding and Expression Blend to make sexy interfaces. One of the things you’re likely to want to do though, when writing anything more than a toy application, is to have a base class for your UserControls or Windows, to share common functionality. It is also quite likely you will want to use generics in conjunction with control inheritance. With both the code behind, and the XAML, it’s not immediately obvious how to do generic inheritance. It is a bit fiddly to get going, and sometimes the errors are not helpful. Here’s a simple example that outlines how to bring it together.
The base control
namespace WpfGenericsDemo { public class BaseUserControl<T> : UserControl where T : IPresenter { public BaseUserControl() { ... various configurations ... } ... Awesome functionality to share ... } }
The child control code-behind
namespace WpfGenericsDemo { public partial class ChildUserControl : BaseUserControl<ChildPresenter> { public ChildUserControl() { InitializeComponent(); } ... More code ... } }
The child control XAML
<WpfGenericsDemo:BaseUserControl x:Class="WpfGenericsDemo.ChildUserControl" x:TypeArguments="WpfGenericsDemo:ChildPresenter" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:WpfGenericsDemo="clr-namespace:WpfGenericsDemo"> ... The rest of your awesome XAML ... </WpfGenericsDemo:BaseUserControl>
Notes
Recently, I’ve been disappointed to find my Treo 650 turning off the phone radio by itself. If I was lucky, I heard the melodic sound that means “radio now off”, and then I manually turned the radio back on. If I was unlucky, I didn’t hear it, and missed phone calls and messages.
It seems that the cause is that the Treo 650 SIM case gets looser with wear, and any break in connection between the SIM and the phone causes the phone radio to be deactivated. The solution is pretty easy, and described at the end of a FAQ I came across. In summary, take out the SIM tray from the phone, remove the SIM. Put several layers of paper (cut small to fit) in the SIM tray, and then clip the SIM back on top. When you put the SIM tray back into your phone, it should work reliably again, with no more random turn-offs!
Wondering if your loan repayment calculations have been performed correctly this month, taking into account interest rate rises and extra repayments? You might be interested in giving my monthly loan calculator a go.
As my home loan provider doesn’t show balances online, and only sends statements every 6 months, I like to ring up every month or two to make sure things are on track. I used to calculate interest, new balances etc in a spreadsheet / calculator but spent an afternoon writing a little Rails app to calculate it for me. Hopefully my little monthly loan calculator is of some use to you too.
NUnit tests can be run using a variety of different runners. Some common ones are:
The NUnit GUI and Test Driven create a new instance of the test class for each test run. This leads to more isolation but potentially slower performance.
Resharper and NUnit MSBuild Task re-use the same instance of the test class when running each test in the class. This can lead to unintended interaction between tests. Using these runners, it is vital to to assign initial values to instance variables in SetUp, rather than when they are defined or in the constructor.
If you use a mix of different test runners, you can end up with tests that pass on some machines and fail on others (eg, Test Driven locally works fine, but you use NUnit MSBuild Task on your build box and get intermittent failures).
Powered by WordPress & Theme by Anders Norén