Targeting 1.1 with VS 2005

Diposting oleh good reading on Selasa, 27 Februari 2007

To do this we setup a project in VS 2005 and added only 1.1 references. We created our test assembly with 2.0 components such as rhino mocks. Everything built and all tests were passing.

Now setting up only 1.1 references is one thing, but enforcing 2.0 supported features, such as generics, to cause build errors, will only happen when you build with 1.1. This is not supported by default with 2005. However, a nice group of people have created a tool to do just that!

The tool is called MSBee and you can download it here

MSBee creates a new build target for the 1.1 framework. You need to add this target to your vs project file in an import node:
<Import Project="$(MSBuildBinPath)\MSBee\MSBuildExtras.FX1_1.CSharp.targets" Condition=" '$(BuildingInsideVisualStudio)' == '' AND '$(TargetFX1_1)'=='true'" />

You can easily edit your project files in visual studio from the right click menu -- unload the project, then edit the file.

Tada! You now have a 1.1 build target in VS 2005!

But you want to integrate this with your build server and your NANT script?

Here is a snipet to execute the msbuild target:

<exec program="${msbuildLocation}">
<arg value="${csprojFile}" />
<arg value="/t:Rebuild" />
<arg value="/p:OutputPath=${buildDir}\" />
<arg value="/p:Configuration=${build.solution.config}" />
<arg value="/p:TargetFX1_1=true" />
</exec>

Enjoy!
More aboutTargeting 1.1 with VS 2005

Mandarin Orange Muffins

Diposting oleh good reading on Senin, 26 Februari 2007

I came to know about a food event known as, Muffin Monday Round Up, while surfing around for muffin creations. I decided to take part in this event, since I love baking muffins, and furthermore, it is hosted by Elena of Experiments, from Singapore.

Here's my entry for the event: Mandarin Orange Muffins.


I came across a blueberry muffin recipe from a Japanese-Chinese translated cookbook...Sweet Simple Dessert. I love the way the muffins look...very pretty, with nice and smooth domed tops. Most of the time, my muffins turned out to have very cracked tops :(

I followed the recipe but replaced the blueberries with mandarin oranges since I have been wanting to bake something with them. Instead of the usual "muffin" method where the wet ingredients are added to the dry ones, this recipe is based on the creaming method, i.e. cream butter with sugar.

I was rather satisfied with how the muffins turned out. The tops didn't crack that much as compared to my previous bakes. The texture is very soft and light, almost like cupcakes. The sweetness is also just right, with only a slight tang from the mandarin oranges.


Ingredients:
(makes 12 cupcakes)

200g plain flour
20g corn flour
2 teaspoon baking powder
50ml milk
2 tablespoon plain yogurt
1 teaspoon vanilla essence
110g butter, softened
160g caster sugar
1/4 teaspoon salt
2 large eggs, lightly beaten
2 mandarin oranges, cut into small chunks

Method:

  1. Preheat oven to 180 degC.

  2. Sift together plain flour, corn flour and baking powder. Set aside.

  3. Mix yogurt and milk together in a bowl. Set aside.

  4. Whisk butter still soft. Add in sugar and salt and continue to whisk till mixture turns light and fluffy.

  5. Add the eggs, one at a time, and whisk until combined. Mix in the vanilla.

  6. Add in half of the flour mixture, stir with a spatula until just combined. Add in half of the yogurt & milk mixture, stir until just combined. Continue to add in half of the remaining flour mixture, followed by the remaining yogurt mixture, and finally the remaining flour mixture. Stir until just combined between each addition.

  7. Fill muffin cups to half full with the batter. Distribute orange pieces evenly among the cups. Spoon remaining batter on top. Decorate with one slice of orange on top, if desired.

  8. Bake for 25 mins until a skewer inserted into the centre comes out clean.

More aboutMandarin Orange Muffins

First Group Ride Outside

Diposting oleh good reading on Minggu, 25 Februari 2007

26 Miles of Fun!

I learned something new:
My fancy running sneakers that provide excellent air circulation aren't so good for cold weather biking... my feet were like bricks... I didn't fall off the bike, I fell when I got off the bike because my feet were so numb!

Otherwise, I was a little slow, but I finished and it was fun :)

If you didn't already know, I'm training for 2 century rides as a fundraiser for the leukemia and lymphoma society in the memory of my father, who I lost in 2004 to leukemia -- please help my campaign here
More aboutFirst Group Ride Outside

Low-Fat Orange Yogurt Cake

Diposting oleh good reading

I am always skeptical when it comes to low-fat desserts and bakes. I really doubt they will taste as good. However, after the feasting and binging on Chinese New Year food and goodies, it's time that I try making something that's low-fat. Earlier this week, I made curry chicken with low-fat milk, after hearing good reviews from my friend. Indeed, the curry tasted as good, except that I missed the sweet aroma from the coconut milk.

I made a "loaf" of low-fat orange cake last night. I adapted a Cranberry Pecan Cake recipe from Alice Medrich's Chocolate and the Art of Low-Fat Desserts. As I just needed a simple cake, I omitted the cranberry and pecan, as well as the frosting. I used a wooden spoon instead of an electric mixer as I was too lazy to do the cleaning up. Although, on hind sight, I should have use a manual whisk instead. I think it would be easier to whisk the butter and sugar with it as it took me a quite a while to cream the butter mixture till pale & fluffy with the wooden spoon :(

The cake is meant to be baked in an 8-cup tube pan, since I don't have such kind of pan, I used a disposable foil loaf pan. Fortunately, the cake turned out to be very soft and light, unlike those moist and dense pound cake or butter cake. I believe the use of cake flour and yogurt helps to give the cake such a soft texture. This is meant to be a low-fat cake, but I think the sugar ought to be reduced further by at least 20 to 30%, I still find it a tad too sweet for me!


Ingredients:

250g cake flour
1 teaspoon baking powder
1/2 teaspoon baking soda
1/2 teaspoon salt
70g butter, soften at room temperature
zest of 1 orange
180g sugar (original recipe calls for 200g of sugar)
2 eggs, lightly beaten
1 cup plain, non-fat yogurt
1 teaspoon vanilla essence
2 tablespoon orange juice

Method:

  1. Preheat oven at 180 degC. Grease or line a 8" by 4" loaf pan.

  2. Sift together cake flour, baking powder, baking soda and salt. Set aside.

  3. In a bowl, mix together yogurt, vanilla essence and orange juice.

  4. With an electric mixer, beat butter and orange zest for 1 min. Add in sugar and beat on high speed for about 3 mins.

  5. Add in eggs gradually, about 1 tablespoon at a time, beat constantly for about 2 mins.

  6. On low speed, beat in 1/3 of the flour mixture. On medium-high speed, beat in 1/2 of the yogurt mixture. On low speed, beat in half of the remaining flour mixture. On high speed, beat in the remaining yogurt mixture. On low speed, beat in the rest of the flour mixture.

  7. Scrape into prepared pan and bake for 45 mins or until a toothpick inserted into the centre comes out clean.
More aboutLow-Fat Orange Yogurt Cake

Violets are blue

Diposting oleh good reading on Jumat, 23 Februari 2007

This post has got nothing to do with baking or cooking. Now, unless you like gardening and flowers, you can skip this posting ;)

I was pleasantly surprised when I watered my plants this morning. A flower bud has sprout out from my pot of african violet!!! I was so happy! This plant has stopped blooming ever since the first set of flowers were gone. The plant has been on my window sill for many months...and I must confess, I really didn't give it much attention or care. I just water it once or twice a week, without even giving it any fertiliser. It is really difficult to grow violets in this kind of weather in Singapore. I used to own several pots of violets while I was still working. I keep my plants in the office as they grow better in air-con environment.

I'm not sure whether it was a pure coincident...as I posted some photos of my "past" plants in flickr.com just a couple of days ago...including a photo of this pot.

Can you see the flower bud?

A closer look at the flower bud:

This was taken when I first bought this plant home, it was in full bloom then:

I hope I could find my green fingers back real soon!
More aboutViolets are blue

Quick & Easy Fried Vermicelli aka Fried Bee Hoon

Diposting oleh good reading on Kamis, 22 Februari 2007

I usually cook simple one-dish meals for lunch as there are only the 3 of us. I am really fortunate that my 2 boys are not picky eaters. They eat whatever I cook. A few weeks ago, I made them fried noodles which tasted like rubber-bands, and yet, without any complaints, they finished up whatever that were in their plates. I told myself I really have to brush up on my cooking soon.

This fried bee hoon with stewed pork ribs, is one of the few better dishes that I could manage. I once ate this dish at my MIL's place, and from the ingredients, I figured out my own version.


I know fried bee hoon is one of the simplest local asian dish that any good cook would not deem it fit to even mention it. However, for an inexperienced cook like me, it took me a few attempts before I got the taste right. Thanks to the encouragement and support from my two little ones!

This is a rather straight forward dish as you simply need to fry the bee hoon with cabbage, carrots and canned stewed pork ribs. It can be ready in 30mins. In fact, the preparation time could be shorter, if not for my poor cutting & chopping skills ;)

What you need:
(serves 3 ~ 4)

1/2 packet bee hoon/vermicelli
2 eggs, lightly beaten
1 carrot
1/2 chinese cabbage (small)
1 can stewed pork ribs
1 cup water
1/2 tsp salt
1 tbsp light soy sauce

Method:
  1. Soak bee hoon in cold water for about 10 to 15 mins.
  2. Peel carrot and rinse cabbage. Cut into shreds
  3. Remove any excess fat from the canned stewed pork ribs. Remove the bones and tear the pork ribs into shreds. Retain the sauce.
  4. Fry eggs till done. Cut into shreds and set aside.
  5. Heat 2 tablespoon of oil in a wok till hot. Stir fry carrot and cabbage till soft. Add in stewed pork ribs with the sauce, stir in salt, soy sauce and 1 cup of water. Bring to boil.
  6. Add in drained bee hoon. Toss and stir gently till sauce is fully absorbed by the bee hoon. Serve garnished with egg shreds.

More aboutQuick & Easy Fried Vermicelli aka Fried Bee Hoon

XNA Content Builder

Diposting oleh good reading on Rabu, 21 Februari 2007

Let's you build xna content w/o Game Studio Express!!
You can get it here

Thank you!! And thanks Kris for sending me this link :)
More aboutXNA Content Builder

losing to a girl

Diposting oleh good reading on Senin, 19 Februari 2007

Tonight I played gears with some women; it was the second time I got to play with women since I signed up for gamerchix.

I'm not so good at multi-player gears (I must say I do rock the single player campaign though!), I don't completely suck, but I like to play, laugh and have fun.

Although most of the guys I play with are cool, a lot can't control themselves and eventually say "you sound cute" or ask "are you hot?" Its flattering, but a reminder that even in this faceless video game, I am different.

Being hot isn't so bad, right?

Tonight was different. I was playing with chicks who were kicking ass. The guys we were playing with got mean, and it was different than anything I'd encountered.

They were mad.

Their egos had been bruised.

They had the ultimate insult, they were beaten by a girl.

After a while, we mixed it up and I was on the team with the most outspoken guy.

When we started playing, he said that one of the other girls was an easy kill. I said "Considering its her first time playing, she's doing awesome."

He wasn't expecting that.

At the end of that round, he said "Hey this is your first time, you're doing really well, are you having fun?"

And she was really quiet and shy and said "ummm... yeah..."

When the game started he asked, "Why did she sound like this was the worst experience?"

My reply was simple, "because you're being so mean."

He was very surprised and asked how. I listed the insults he had been spitting for the past 30 minutes... and he said "I didn't say any of that."

But the conversation ended, the round was over.
More aboutlosing to a girl

Banana Blueberry Muffins

Diposting oleh good reading


Muffins again?!

Sorry, but I couldn't help but to bake muffins for breakfast today. As the CNY public holidays are still on, most of the stalls at the hawker centre or coffeeshops will not open for business until tomorrow. As such, we won't be able to have our breakfast outside, even though it is our usual routine to do so during public holidays.

I have left over bananas and blueberries, so I came up with this recipe of my own. I think I have been quite comfortable with making muffins, so much so that I could easily "mix and match" recipes and ingredients to make my own version ;)

Here's my version of banana blueberry muffins. The muffins are much better than the previous batch of blueberry muffins. They are more fragrant because of the bananas and the sweetness is just nice. The texture is rather fluffy and moist, although again, the appearance is not too pleasing to the eyes :(

I do hope I could made tasty and yet pretty muffins very soon!

Ingredients:
(makes 12 muffins)

210g plain flour
1 teaspoon baking powder
1 teaspoon baking soda
1 egg, lightly beaten
100g sugar
1/4 cup oil
1 teaspoon vanilla essence
2 medium sized bananas, mashed
1 cup fresh blueberries

Method:

  1. Mix flour, baking powder, baking soda in a bowl.
  2. Working over the bowl, toss the blueberries with about 1 ~ 2 teaspoon of flour mixture in a sieve, and set aside. Coating the blueberries with flour helps to keep them from sinking to the bottom of the muffins as they bake.
  3. Combine egg, sugar, oil, vanilla essence and mashed bananas in another bowl. Mix well.
  4. Add the wet ingredients to the flour mixture. Stir until just blended. Fold in blueberries gently.
  5. Fill muffin cups/liners till almost full. Bake in preheated oven at 200 degC for 20 to 25 mins.

More aboutBanana Blueberry Muffins

A Tower of Brownies

Diposting oleh good reading on Minggu, 18 Februari 2007

Made these brownies last night. I have refrained from baking anything with chocolate lately, as both my kids have been unwell for the past weeks. Upon their request, I baked these for their breakfast today.

I followed the recipe from Alice Medrich's Chocolate Holidays: Unforgettable Desserts for Every Season. It recommended a ice bath method...a special but simple technique to a perfect brownie. This involves baking the brownies at a high temperature of 200 degC for 20 mins, and once out of the oven, submerge the pan straight into an ice bath (a bigger pan filled 3/4 full with ice & water). Let the brownies cool in the ice bath before cutting into squares.

Cleaning up after the baking session was really easy. The main utensils I used were only a saucepan and a wooden spoon! I melted 4 oz butter and 4 oz unsweetened chocolate in the saucepan directly over low heat(although the instructions says to melt them in a bowl set over a pan of simmering water). Then, I simply stirred in the rest of the ingredients: 200g sugar, 1/4 tsp salt, 1 tsp vanilla essence , followed by 2 eggs (adding one at a time) and finally 70g of plain flour directly in the saucepan. I also lined the baking pan with foil, and if you are really not fussy, you don't even have to wash it ;]

The top half of the brownie is rather crispy while the bottom half has a softer texture. In fact, you could see a clear distinction of the 2 layers from the photo above. They are rather rich and a bit too sweet for my liking, although my kids find the taste just nice. Anyway, I'll definitely cut down the sugar next time.

Note: This recipe yelds 16 squares.
More aboutA Tower of Brownies

Oksana, where are you??

Diposting oleh good reading

Oksana, I'm looking at the War Room Crew links over there and its seriously lacking estrogen... Come on now, this is Oxygen, and we need to represent the women developers of the world!!! Where's your blog???
More aboutOksana, where are you??

Code Camp Registration is Now Open

Diposting oleh good reading

Register Here
Thanks for the link Luke!
More aboutCode Camp Registration is Now Open

Getting all the achievements in Madden 06

Diposting oleh good reading

Yes, I've done it... I've whored myself... stupid rewards... What I've learned is that I really do not enjoy playing a lot of video games and even with rewards, I still don't. But, I managed to pull myself through and figured I'd help some people out with Madden; its really easy.

Just to start -- you will not get game achievements until the game is completed, so don't get discouraged, they'll be there

Really freakin' easy:
Win the superbowl:
1. From main menu go to franchise mode, start a new franchise
2. Select every team
3. Simulate preseason
4. Simulate regular season
5. Simulate wildcard
6. Simulate superbowl
7. tada -- you won the superbowl!

Look at the history book
1. From the main menu, go to franchise mode
2. Select history book
3. Go to any page
4. tada -- you got an uber lame achievement!

In game achievements:
If you do the following, you will get all the game playing achievements, save win a franchise game Note, this will be the most cheesy video game experience of your life.

Notes:

a) At any time in the game, check your current status by pressing start, then clicking down on the right thumbstick, then pressing down on the right thumbstick -- this will give you passed and rushed yards. This gives you the activate RS card achievement.

b) Don't bother doing anything special or control players -- just select plays. The only exception is passing -- if you choose who to pass to, you'll complete passes better.

1. From the main menu, start a new regular game, make the quarters 9 minutes long to make sure you have enough time to get all the achievements. I had 5 minutes left in 4th quarter by the time they were done. Choose rookie difficulty.
2. Choose the Colts for your team -- they rock
3. Choose the Browns for your competitors -- they suck -- make sure the computer is driving or it doesn't count
4. Every time you are on defense, choose based on play type, man blitz -- any one, this will get you Four Sacks in One Game and it may take a while. Just keep at it.
5. In the beginning offense, choose based on play type, shotgun passes when you're far from the goal and then switch to quick pass. You will keep getting touch downs, very exciting. Do this until you reach 350 passing yards for the achievement.
6. After you get the 350 yards, now you need to focus on rushing. The colts aren't quite as good at rushing, but I found starting with Counter to get close to a down and getting the down with an inside hand off. worked most of the time. Since I was so far ahead in points, I never kicked on the forth down and just went for it, this worked most of the time. Do this until you reach 200 rushing yards in your stats and then you can spend the rest of the game loafing
7. Thats it, play until the clock runs out and you'll have 480 more achievements when its all done -- Enjoy.

More difficult:
30 Years of Franchise
This one is time consuming and basically you sit around and wait for simulation. You really only get this one if you have 3 hours to waste and an achievement whoring husband. I take full credit for the theory of getting this to work on simulation, but he gets credit for actually doing it...
1. Start a new franchise -- don't use the one from the superbowl -- it won't work for 30 years!!!
2. Select the worst team with the biggest cap -- he went with the Titans, but didn't look through the list that well. If you choose someone like the colts, after a few years, you'll have to start doing some manual labor cause salaries will get too high and it sucks.
3. put on some good music
4. get a laptop, ds, split screen tv, another xbox....
5. Simulate, repeat
6. Yay, you're done

Win a Franchise Game
1. Start a franchise, select the Colts
2. Simulate the franchise week by week until you play the Browns
3. Use coaches pick for defense and offense, but use passing plays for offense, unless you have less than 3 yards, then you can use a rush.
4. This will be a little more tricky cause franchise is Pro mode only

To completely cheese out, you can adjust the AI during the Pro game. Its under the game play settings when you press "start" during the game. Use the right trigger to select between offense and defense and between you and the computer. Bump your attributes up to 100 and the cpus down to 0. This will make you win the game easily -- doesn't matter what plays you use.

Good luck and don't get too bored!
More aboutGetting all the achievements in Madden 06

Back to training

Diposting oleh good reading on Sabtu, 17 Februari 2007

I went to the gym today for the first time since I had to postpone training and it felt really great! I was suppose to bike 10 miles or for 30 minutes, I think whichever came first. I worked really hard, hoping to finish the 10 miles in 25 minutes; my cadence was about 110 the whole time on level 8 (do the levels even mean anything?)

I felt like I was speeding along, but it took exactly 28 minutes to complete the 10 miles. Not quite as fast as I wanted to go...

The last two minutes I slowed down and cooled off... but the bike was tricky... it seemed that in those 2 minutes, I went .7 miles... sneaky bike, moving just as far even though I was pedaling half as much.

I wonder how far I really went?
More aboutBack to training

Xna, graphics and team edition, oh my

Diposting oleh good reading

The next step in my quest to only code my xna games in team edition was working with graphics. This proved to be a little more difficult because graphics need to be built inside Xna projects.

So, I needed to break my rules a little...
New rule:
Graphics can live in an Xna library, that is neither living in the main game solution or the GameShell exe assembly.

In Xna, graphics are just content loaded from disk built as "xnb" files, so they only need to be in the TitleLocation of the StorageContainer when your game is running (this is where the ContentManager Loads). If you look at a project containing pipeline content, you'll see an ItemGroup node:

<ItemGroup>
<Content Include="Image.jpg">
<XNAUseContentPipeline>true</XNAUseContentPipeline>
<Importer>TextureImporter</Importer>
<Processor>SpriteTextureProcessor</Processor>
<Name>spriteImage</Name>
</Content>
</ItemGroup>

So, if you wanted to, you could create an Xna library project and then just add content to it manually by copying images into a child directory and adding xml to the project file. Or, you can keep Express edition open for your graphics and build them as you need them.

So, now I have a graphics library with all my assets. Once it builds, I need to put these files in my debug directory if I want to use them, but as one of my stipulations, I didn't want to have any post build steps, so I made the following modifications to my Program.cs class in GameShell:


for (int i = argIndex; i < args.Length; i++)
{
string graphicsPath =
Path.Combine(args[i], @"bin\x86\Debug");
if (Path.IsPathRooted(graphicsPath) == false)
{
graphicsPath = Path.Combine(projectPath, graphicsPath);
}
foreach (string file in Directory.GetFiles(graphicsPath))
{
File.Copy(file, Path.Combine(debugDirectory,
Path.GetFileName(file)),
true);
}
}

Basically, I added the logic to the GameShell that any additional parameters to the application are graphic resources. If the resources aren't rooted, there are libraries inside the main project directory. So, this just goes through all those folders and copies all the files -- simple.

Still with me? This is a long one... BTW -- I have never even tried to run this on my xbox, I do all my coding on my laptop on my long ass ride home on the train so I take no responsibility for your boxes :P Also, if someone came up with a better solution, please tell me cause I'm without internet on this long ass train ride!

Yay, so now I have all the assets I need :)

Or so I thought...

I couldn't load any of these xnb resources. The content.Load was only working with resources in the bin directory GameShell :(

Reflector to the rescue...

I found this bit of code, used to determine where to find graphics:

public static string TitleLocation
{
get
{
string text1 = string.Empty;
Assembly assembly1 = Assembly.GetEntryAssembly();
if (assembly1 == null)
{
assembly1 = Assembly.GetCallingAssembly();
}
if (assembly1 != null)
{
text1 = Path.GetDirectoryName(
new
Uri(assembly1.EscapedCodeBase).LocalPath);
}
return text1;
}
}

As you can see, its using the entry assembly (or calling assembly) to determine the location of content...

So, back to my original solution with the app domains... oooo I was being clever :P

A few minutes of hacking in some appdomain code and voila, the game will only execute in the main appdomain... d'oh -- wasn't being clever after all, but I think I got that out of my system.

Returning back to my graphics copying code, I decided the simplest approach is copying the assets into the TitleLocation in Program.cs. A slight modification to the file and finally, I'm debugging my Game in Team Edition with Graphics!!!

And there was much rejoicing... yay.

I think I've put off writing some games long enough :P
More aboutXna, graphics and team edition, oh my

Chinese New Year Cookies Part II

Diposting oleh good reading on Kamis, 15 Februari 2007

I was crazy enough to try making 2 types of Chinese New Year cookies this morning!

A few weeks ago, I was telling myself that I should not be making any CNY cookies as store-bought ones are so easily available, and most of them taste quite ok. Little did I know that I found myself caught in the baking craze over these cookies in the past week! It didn't help that most of the local food bloggers that I visit have all their delicious and yummy CNY cookies splashed all over their posts, be it pineapple tarts, kueh bangkit, cornflakes cookies, peanut cookies and so on. I was so inspired and couldn't resist myself but to try baking one or two of them, otherwise I might regret it as I won't bake them till next year.


I attempted to make peanut cookies and kueh bangkit this morning. I try out with another recipe for the kueh bangkit. This time round, the dough is softer and easier to roll and cut out. The only problem is the baking time and temperature. The cookies took quite a long while for the centre to dry out completely. I had to test taste and adjust the oven temperature a few times to ensure that they don't get burnt. As a result, most of the cookies were a little over-browned :(

I compared the cookies made from the two different recipes, and came to the conclusion that I should "marry" the two of them. The cookies from the 1st recipe are more crispy but plain, while those from the 2nd one are sweeter and more fragrant.

Making the peanut cookies was a breeze. I followed the recipe from Florence's blog. The only difference is that I omitted the coarsely chopped peanut bits. I have the dough in the oven in less than 20 mins. Again, they took a much longer time to brown as compared to the stated time of 20mins. Taste wise, they are very good and really melts in your mouth :)





More aboutChinese New Year Cookies Part II

They forgot about me...

Diposting oleh good reading

I'm busy writing today... too many meeting distractions...

I decided to check in with the Leukemia and Lymphoma Society today since I haven't heard about when training for my century ride was starting. And it turns out it started 2 weeks ago! I'm 20 miles behind :(

I'm a little bummed, but am ready to start and really don't want this to keep me from accomplishing my goal of riding a bike 100 miles and raising money for the Leukemia and Lymphoma society.

You can help me reach my goals here.

Wish me luck!!
More aboutThey forgot about me...

Code Camp 2007

Diposting oleh good reading

Looks like I'll be giving 2 presentations at Code Camp 2007 in NYC with a fellow developer from Oxygen, Oksana Udovitska. We're hosting two talks, The Gentle Art of Pair Programming and Testing in C# with RhinoMocks. Hopefully, people will learn something or at least be entertained. I'm thinking a code session taught by two hot chicks will be enough! hahaha

Code camp is in midtown on March 3rd, which is a Saturday (yeah, totally sucks, no?) and its from 9 - 6 or something like that...

Luke Melia -- another excellent developer on our team is also hosting a chat about leveraging the WPF command pattern with dependency injection. It should be good!
More aboutCode Camp 2007

base test class

Diposting oleh good reading

one thing that can make your tests real messy, real fast is duplicated code. however, with mocks, its really hard to get rid of duplication and keep your code readable.

a simple first step to uniform tests is a base test class that you inherit from in all your classes. use this class to setup your mock repository, replay, verify, tear down and do any custom setup your application needs for all your tests.



[TestFixture]
public void BaseTest
{
protected MockRepository _mocks;


[SetUp]
public virtual void Setup()
{
_mocks = new MockRepository();
}

[TearDown]
public virtual void TearDown()
{
}

protected virtual void FinalizeAll()
{
_mocks.ReplayAll();
}

protected void CreateMock<T>()
{
return _mocks.CreateMock<T>();
}

protected T XamlSerializeAndDeserialize<T>(T original)
{
using (MemoryStream stream = new MemoryStream())
{
XamlWriter.Save(original, stream);
stream.Position = 0;
return (T)XamlReader.Load(stream);
}
}
}


We keep the MockRepository protected because there are so many methods on it that inheritors may want to use, but use the base tests methods usages of _mocks when they exist. Also, we call the method that ReplaysAll "FinalizeAll" because methods that override often do more than just replay the mocks, they finalize the state of the other objects in the test. However, this may not be the best name, considering what "finalize" means in the c# world...

If you use an object management framework, logging or other common mocks, the base class can take the responsibility of setting those up.

As you can see, we added a method, "XamlSerializeAndDeserialize," since we test this in many of our classes, you could put this in a separate Assert class too, but it really depends on how often its used and what your team likes.

As your tests evolve, factories to create common mock objects and classes to do custom Asserts are also really helpful. One test class we've found really helpful is a PropertyChangedEventTester that will hook into any class that implements INotifyPropertyChanged and keep track of events.
More aboutbase test class

all about the mocks

Diposting oleh good reading

i love mocks. i really do. if i could, i would marry mocks, have lots of mock babies, be a grandmock; you get the idea...

the top reasons i love mocks:
1. focus only on what you are testing
2. other classes won't break your tests
3. create new interfaces and use them before they exist
4. use functionality without knowledge
5. i hate math
6. keep the file system, networks and other real resources out of your unit tests

i'll post examples of each of these reasons

a lot of black box testers have valid reasons for disliking mocks, but the benefits surpass any downside i have ever read or encountered. i use rhino mocks, which uses reflection, so some major downsides of mocks, such as difficult refactoring and type casting are completely avoided.

did i mention i love mocks?

thank you rhino mocks!!!

One other must with mocks is dependency injection. In the past I've written my own object management framework to handle injection, but we've been using the castle framework and its totally excellent, i love this too!!! It takes away all the thinking of dependency injection and lets you focus only on your tests and interfaces. An absolute must!!
More aboutall about the mocks

Oyakudon

Diposting oleh good reading on Rabu, 14 Februari 2007

Oyakudon is one of the easiest and simplest dinner that I cook for my family. It is one of the Japanese donburi dishes or rice bowl dishes that have meat and vegetables simmered together over rice. It is made of chicken and eggs...and that's how the name "Oyaku" was derived (mother & child in Japanese). I used to think that it means a dish prepared by a mother for her child ;)


I happened to come across this oyakudon ready-made seasoning at the supermarket a few months ago. The cooking instructions are in Japanese...somehow, from the pictures printed at the back of the box, I managed to figure out how to made this dish. It turns out to be a very simple and delicious meal. I topped the oyakudon with some furikake rice seasoning that comes in these cute Cinnamoroll packaging. This is great for busy mummies who want to cook a quick and simple meal for the family.


Ingredients:
(serves 3 ~ 4)

2 chicken drumsticks, de-boned and cut into bite sizes
2 onions, sliced
3 eggs
cooked rice

Here's how you do it:

  1. Stir fry onions with some oil in a saucepan. Add in the chicken and stir fry till the meat turns white.
  2. Add in 1 cup of water and 2 or 3 packets of oyakudon seasoning (one packet is for 1 serving). Let it simmer till chicken is done.
  3. Add in lightly beaten eggs gradually. Once the eggs begin to solidify, turn off the heat and cover the saucepan. The remaining heat will ensure the eggs are just done.
  4. Pour over cooked rice and serve immediately. Top with furikake rice seasoning, or seaweed as desired.

    Here's my version of a simple and yummy oyakudon.


More aboutOyakudon

if you don't need the exception...

Diposting oleh good reading on Selasa, 13 Februari 2007

don't declare a variable...

try
{
some code...
}
catch (ExceptionIWantToCatch)
{
}

No warnings, no cheesy statements to get rid of warnings...

If you don't care about the exception type, just catch{}
More aboutif you don't need the exception...

Chinese New Year Cookies

Diposting oleh good reading on Senin, 12 Februari 2007


I finally made one of those Chinese New Year must have...Kueh Bangkit. These are biscuits made with tapioca flour and coconut milk. The tapioca flour has to be fried with pandan leaves before it can be used. This is one of the main reasons that I have been putting off the idea to make them. With my sub-standard stir-frying skills, I may over fry the flour and very likely spatter flour all over the kitchen.

The other problem is, there are too many different recipes to choose from. It would be difficult to choose one which would yield the best result...crispy and yet melt-in-the mouth. Even with the same recipe, different people may achieve different results. If you are unlucky, you may even end up with trays of rock-hard cookies!

By chance, I came upon this recipe that does not require the tapioca flour to be pan-fried, it can be done by heating in a convection or a microwave oven. I guess the main purpose of frying the flour is to get rid of the moisture and add fragrance with the pandan leaves. With moisture eliminated from the flour, the biscuits will turn out very crispy. With the assurance that I will unlikely get flour all over the place, I went ahead with the recipe. I "bake" the flour the night before and cool them overnight. Making the dough was rather straight forward. The only difficult part was rolling out the dough as it was rather dry and hard. I had to roll the dough with a piece of parchment paper covered on it to prevent it from sticking to the rolling pin. My younger boy volunteered his assistance and we had a fun time cutting out the biscuits. I left him to finish up the last tray while I cleaned up the mess. He really did a good job! The biscuits turn out to be very nice and crispy. However, I could hardly tell whether they are really good, as the last time I had these biscuits was a year ago.

More aboutChinese New Year Cookies

i just can't do it...

Diposting oleh good reading

Code without resharper and visual assist that is...

After 10 minutes of my first Xna tutorial, I decided my first task would be to do all my developing in team edition.

Being my own customer, I made up the following criteria:
1. I can create a new c# library in vs team edition that contains a Game class which can be debugged/run from vs team edition
2. No post build copying of project output
3. No need for maintaining 2 separate solutions for each game
4. No dependencies between my game projects

In order to fulfill these, I created a new Xna solution called GameShell. I deleted the Game class, leaving Program.cs which I filled in with this code:
static void Main(string[] args)
{
string assemblyFilename = args[0];
string path = args[1];

Environment.CurrentDirectory = path;
Assembly assembly = Assembly.LoadFile(Path.Combine(path, assemblyFilename));
string typeName = args[2];
Game game = (Game)assembly.CreateInstance(typeName);
game.Run();
}

I used Assembly.LoadFile, because using Type.GetType(gameTypeName) was returning null... I don't think anything was spelled wrong, but I was feeling lazy, so I used the code above...

Its sad to admit, but before I thought to set Environment.CurrentDirectory, I had created a new appdomain that was rooted in the other directory and had a lovely class, GameStarter : MarshalByRef, that created and ran the game, which I thought was very clever, but completely unnecessary)


Now that I had GameShell to execute my game, I needed a game to run. I created a c# library in Team Edition, added references to Microsoft.Xna.Framework and Microsoft.Xna.Game and then added a game class to the project. Actually its Game1 from the first tutorial from the documentation (very exciting). Now that the project was ready to debug/run, I went into the project properties and changed the Debug settings so that it ran GameShell.exe with the proper command line arguments (AgileSolutions.GameLib.dll, FullPathToDebugDirectory, AgileSolutions.GameLib.Game1)

Viola! The game ran and I can now write any game library with my favorite tools and run it without any headaches... one minor issue though, graphics... you know, not the most important part of the video game, right?

For this first project, I cheated and put my graphics in the GameShell assembly, a big no no, but I'm gonna do some reading and learn more about content pipeline assets and we'll see what happens. Any ideas?
More abouti just can't do it...

Blueberry Muffins

Diposting oleh good reading on Minggu, 11 Februari 2007


This is the first time I bought blueberries from the supermarket. It has never occurred to me to eat this fruit as it is not as common as strawberries or even cherries. I bought them specially to bake blueberry muffins. I've came across several blueberry muffin recipes but have never had the chance to try it.

I made this batch of muffins for breakfast this morning. The recipe is adapted from Annie Bell's Gorgeous Cakes, Plum Muffins. I took this recipe as it's the only recipe where I have all the ingredients on hand. The muffins lack the fragrance and sweetness as compared to the banana-raisin oat bran muffins I made the other day. They tasted rather "plain and simple", if not for the vanilla essence I added. The blueberries were sweet, and although they were rather small berries, they were quite juicy. Judging from the "nil" comments or lack of enthusiaism from my kids, I believe I'll have to try out other recipes. Nevertheless, these muffins are certainly soft and moist and went very well with a cup of coffee.

Ingredients:
(makes 6 big muffins)

225g flour
75g sugar
2 teaspoon baking powder
1/2 teaspoon salt
30g butter, melted
1 egg
200ml milk
1 teaspoon vanilla essence
1 cup fresh blueberries

Method:
  1. Preheat oven to 200 degC.
  2. In a large bowl, stir together flour, sugar, baking powder and salt.
  3. In another bowl, whisk the egg, then add in the milk and butter. Mix well.
  4. Add the wet ingredients to the flour mixture and stir until just incorporated. Do not over mix.
  5. Fold in the blueberries. Spoon the batter into muffin cups/liners and bake for 20 to 25mins, or until risen and lightly browned.
More aboutBlueberry Muffins

Banana-raisin Oat Bran Muffins

Diposting oleh good reading on Kamis, 08 Februari 2007


George Bernard Shaw once said,
"You don't get tired of muffins, but you don't find inspiration in them."


I certainly agreed with the first part of the sentence, but not the second...maybe, during those days, there were only a few types of muffins around?? Anyway, I like muffins...they are usually easy to make, with simple ingredients, always with fruits added, and are more healthy as compared to cupcakes. Thanks to my friend, who passed me some oat bran, I baked a batch of oat bran muffins last night. It was my first attempt to bake wholesome muffins. As a novice, I was not even able to differentiate between oat bran, rolled oats or whole bran!

While I was preparing the ingredients, my little one came along and eagerly offered his help. We had a good time baking the muffins together...just the 2 of us. It was really easy and quick...we took less than 15 mins to pop the muffins into the oven. I was a bit worried when the batter appeared to be rather dry and lumpy. I was only a little at ease half way thru the baking, when my whole kitchen was filled with this wonderful aroma of the sweet fragrance from the bananas.

The muffins were golden brown when they were ready. I was surprised at the coarsely texture...if not for the sweet aroma they were emitting, they certainly look ugly and unappetizing, sitting on the cooling rack. I couldn't wait for them to cool completely before biting into one. Well, the saying, "don't judge a book by its cover" applies to these muffins too. They tasted really good despite their look, the top maybe coarse, the centre was really soft, moist and fluffy. I shared it with my little one, and he asked for another one to go with his bedtime milk. My elder boy who missed out on all the actions, told me over breakfast this morning, "These muffins look really ugly, but they taste really yummy!"

I used to try out recipes based on the appealing photos of the bakes. I have now learnt not to judge a muffin by it's look.


Ingredients:
(makes 12 muffins)

120g plain flour
94g oat bran
1 teaspoon baking powder
1 teaspoon baking soda
1 box (net wt. 42.5g) Sun.Maid raisins
1 egg, lightly beaten
100g sugar
1/4 cup oil
1 teaspoon vanilla essence
3 medium sized bananas, mashed

Method:

  1. Mix flour, oat bran, baking powder, baking soda and raisins in a bowl.
  2. Combine egg, sugar, oil, vanilla essence and mashed bananas in another bowl.
  3. Add the wet ingredients to the flour mixture. Stir until just blended.
  4. Fill muffin cups/liners till almost full. Bake in preheated oven at 200 degC for 20 to 25 mins.

This recipe is adapted from "The 250 Best Muffin Recipes, by Esther Brody".



More aboutBanana-raisin Oat Bran Muffins

Curry Chicken

Diposting oleh good reading on Rabu, 07 Februari 2007

I have decided that I will add in a category "Simple Dishes" to my postings here. I am not a good cook, in fact I can't really cook! I have been cooking for the family for almost a year, but till now, I can only make simple dishes such as porridge, fried rice, fried noodles and claypot chicken rice. My family members are not fussy eaters...that's probably why I can't improve ;)


This curry chicken will be the first post for this category. I have not cooked this dish for months. Simply because I have ran out of my sis' homemade chili paste. She finally found time to make the paste 2 weeks ago.

It's really a simple and easy dish, especially, if you have ready-made chili paste. Here are the steps:

Step 1:
Mix 1 ~ 2 tablespoon of chili paste with the chicken pieces (half a chicken).

Step 2:
Stir fry the chicken and potatoes a little, and add in 1 packet of coconut water and simmer for 20mins.

Step 3:
Mix 2 tablespoon of curry powder with a little bit of water to form a paste and add into the curry.

Step 4:
Add in 1 packet of coconut milk and simmer for another 5 to 10 mins. Ready to serve!
More aboutCurry Chicken

XNA

Diposting oleh good reading

In addition to this very exciting blog, another goal for the year is to experiment with a new technology. Originally I was going to play around with Ruby, but I've decided to try out XNA instead. I was all psyched and ready to embark on the journey to creating my first xbox game when I discovered the following:

1. XNA development is only supported in VS Express addition!!! This is most upsetting because I cannot work without resharper and visual assist. Really, I can't. I keep doing things like ctrl-b, ctrl-alt-F7, ctrl-alt-v, shift F6, the list goes on... And intellisense without the ability to misspell just does not work well for me... I need colored listboxes!!!

2. No xbox live support :( this wasn't as much of a downer as #1, but I was looking forward to making up some clever achievements

3. How am I to test drive without add-ins? This really goes with #1, but this isn't about making development easier, this is about how I develop.

Despite the above, I'm still excited about my game idea and I hope its fun!

Wish me luck
More aboutXNA

Piano Cake

Diposting oleh good reading on Selasa, 06 Februari 2007

I finally picked up the courage to make this cake.

Saw this video clip from youtube while searching for sanrio products. My 5 yr old is a fan of Cinnamoroll, one of the many sanrio characters. We were watching a video clip of Cinnamoroll when I came across the Sugar Bunnies, another sanrio character. After viewing the clip, I told my boys that someday, I will make them this cake, just like the sugar bunnies. If you like baking, do spent less than 4 mins of your time to watch the clip, I am sure you will find it very cute and interesting. It is in French (I think), but it is really self-explanatory.


Since this is my first real attempt to frost a cake, the result is very very very far from the one shown in the video clip. It took me a while to convince myself to post it here, haha!

The cake itself was quite easy, as I used a simple sponge cake recipe. I used peach slices and whipping cream for the filling, but then I realised there wasn't enough cream for me to decorate the cake, in fact, it wasn't even enough to cover the entire cake!


My younger boy helped me with the filling, and, as usual, he helped himself with the left over peaches. The elder one guided me on the correct position of the "black keys". They were actually chocolate wafers from Meiji. Too bad they weren't exactly black...they were dark brown. They were the closest I could get. My son asked me whether we could just paint them black ;)

I really lack the skills to assemble a 3-layer cake. The cake was not really flat and sharp at the edges. I ended up with a bulging keyboard. Well, although the cake didn't look what it's suppose to be, at least the taste is still alright. I guess I have to practise many more times, if not will have to go for a formal baking class, before I could make a decent looking cake!

More aboutPiano Cake

Korean Fare

Diposting oleh good reading on Minggu, 04 Februari 2007

We had a little gathering at my friend's place over the weekend. We had a full spread of Korean food for dinner. One of my friends cooked the Korean dishes...there were spicy rice cakes, kimchi soup, jajian mien (Korean style), and a few side dishes, such as simmered lotus root, cold tofu, etc. She even prepared cinnamon & ginger tea, though it was not very well received, sorry Ah M, I guess not many people like the taste of cinnamon...including myself ;) I like the spicy rice cake and lotus root most.


I brought these Strawberry Jellyhearts for dessert. It was my 2nd attempt in making these, and I was very happy with the result this time.

The jelly layer is so much better as compared to the 1st attempt. I made the biscuit base and cheese layer in the morning, and made the jelly layer only at night. The cheese layer was fully set by then, as such, there were no bits of cheese floating around, and when set, the jelly layer was almost crystal clear. It gave a very nice reflection when I was trying to take the photos:)

I was also able to achieve nice clean cuts without having to heat up the knife. The only problem was the biscuit base...it was a bit too crumbly...either I didn't use enough butter or I didn't press them firmly enough in the cake pan? By the way, I used an ordinary square pan...I don't own any loose-bottom pans or springform ones. I improvised by lining my square pan with a layer of foil...once the jellyhearts are ready, I simply lift it out of the pan with the foil.


Made a batch of Horlicks Doggies Cookies for my friend. Her kids can't take too much chocolate, so I omitted the chocolate chips that were supposed to be wrapped in the cookies. Nevertheless, the cookies are still as tasty, but they are not sweet at all, as no sugar or eggs are used. I hope her kids will like them :)

More aboutKorean Fare