Andre de Cavaignac

Let's blog it out...

September 2006 - Posts

Flyin' like an aeroplane!

Following up on Josh Einstein's "Loaded like a freight train" post...

Once again, I'm back to trying to team up with Josh Einstein to work on a side project called Nightrain.  Hopefully this will be the beginning of more collaboration on future projects (or companies) as well!

As unlikely it is, we hope this project will be a bit of a catalyst for future .NET ClickOnce applications as alternatives to HTML.  I'm not going to say too much more about the project.  As Josh mentioned, some people like to steal ideas, and we don't want that to happen with this.

Look for a demo (and perhaps a new website boasting this and other applications) soon!

Vista Tip: Bring Sidebar To Front Using Key Command
Want to bring your Sidebar gadgets to be the top-most window, but don't want to use the mouse?  I wasn't able to find this documented ANYWHERE, however, after fiddling around a bit, I found that "start + G" (think "start + Gadget") lets you "tab" through all the open gadgets like alt-tab, and will bring them to front if they are not already shown.  It will start with the sidebar, so anything on the sidebar will be immediately visible on top of your working windows!
Posted: Sep 13 2006, 05:14 AM by mrdecav | with no comments
Filed under:
Review: Asus V6X00J (V6J Series) Notebook -- (With Vista RC1!)

   So, desperately looking around for a laptop to buy (and with no time to order a custom build), I went to the store and found this Asus V6X00J with some very good specs for $1800 dollars.  It was attractive, and much thinner than my old clonker (Dell Inspiron 6400).  So after much hesitation, I decided to give it a try -- after all, the reviews were good and the machine felt solid.  Also, I figured that most of the components were made by other vendors (Intel, Nvidia, Samsung), so the only "Asus" thing I was buying was the case.

The specs on the machine I bought were the following:

  • Core Duo T2300 (1.66Ghz)
  • 15" SXGA (1400x1050)
  • DVD dual layer RW
  • Wifi and Bluetooth
  • 100 GB 5400RPM drive
  • 1024MB RAM (I upgraded to 2048)
  • NVidia GeForce Go 7400 (128MB dedicated, with the ability to steal from the system memory for up to 512MB)

These suited my needs for a high resolution, high performance laptop.  And weighing in at 6lbs and less than an inch thick, its featherweight for the specs.  One other nice thing about the laptop is its brushed metal enclosure with blue LED highlights for the status lights, which feels solid and looks more appealing than other notebooks.

Unpacking the device, the first thing I noticed was the weight.  The machine was much lighter than my old laptop, and the cool metal screen has nearly no branding on it.  The screen has a small border around it, and not much space is wasted.  I plugged it in and turned it on, and although initially the startup took longer than I had hoped, I was presented with a clean Windows desktop.  No shareware or bloatware, just a single Asus power utility and the standard windows settings.  This is a rarity in todays world, and it made me very happy to see at least one company (like Dell) keeps from fucking up Windows with junk.

Another notable aspect of this laptop is the screen.  The screen is incredibly bright and vivid, and has one of the most fine-grained brightness control's I've seen.  You can switch from nearly no light at all to a full brightness with great contrast.  One of the best laptop displays I've seen.

I promptly formatted the machine and installed the RC1 of Windows Vista.  Vista detected most of my drivers and installed promptly.  Sadly, it didn't get the NVidia driver from the start, but a quick look into the device manager allowed me to setup the NVidia card and get going with Aero (Glass).  I was pretty happy to see how beautifully Vista works on this machine.  It's fast, responsive and stable.  Even Flip3D works without a hitch.

So far I have been very much enjoying the Vista experience.  The small things of the OS (changes to the way files are copied, filtered and searched are great aspects of the new OS, as are Windows Photo Gallery and the new "workflows".  Windows does a great job at predicting what you'd want to do based on an action, and walking you through it.  For example, connecting a camera now opens up a small import screen allowing you to add tags to the files and import them.  Very nice.

One of the other impressive things (probably greatly in part to the Core Duo processor) is the battery life.  Running this machine, which has a rather small battery, in normal use and second-to-lowest brightness (dim but comfortable), the machine commands a good 4-4.5 hours of continuous use.  Not bad for the machines specs, weight and size.

Overall, I've considered this machine a good purchase thus far and would encourage those looking at Asus laptops to consider them.  I have not, however, delt with support at this point, and it will be interesting to see what comes of that.  According to other reviews of Asus, support is reasonable.

Counting Money and Handling Currency in .NET (Money Value Types, Sample Code)

Sample VS.NET 2005 Solution For Download Here

One large missing piece I have found in the .NET Framework recently was any support for calculating money.  Money is not particularly difficult to calculate, seeing that it is merely a decimal value, however it is difficult to do properly, without making serious mistakes.  The use of multiple currencies in the same application could potentially lead to serious calculation errors (such as adding Euro and US Dollar together).  To avoid this, and make passing money around in an application easier, I created a Money struct that I thought I would share.

At the onset, this task seemed much easier than it actually was.  A simple struct to hold both currency and a decimal value.  Unfortunately, more complexities soon found their way into the mix, including formatting string, holding and validating currency codes, and (worse of all) comparison.  In the code sample supplied with this article, the below is implemented.  Also, I have included unit tests for all of these operatons, as dealing with money is a sensitive nature.

I will not be held liable for the use of these structs.  I do not ensure that all the structs or included classes innards work properly, however I am using them in production code so I feel confident about their use.

String Formatting

String formatting was a difficult problem to solve, and it is still not completely correct (but is usable) in my struct.  Currently, I use some primitive currency symbols (such as dollar sign, euro sign, yen sign, won sign, etc).  If a symbol is not available, the three-letter ISO code is used.  I have provided custom formatting options through a ToString(string format) overload, however it is limited.

Holding and Validating Currencies

After much debate, I decided to hardcode ISO standard currency-codes into the MoneyCurrency struct I created.  This will give you:

  • Three letter code
  • ISO numeric code
  • English name

You can access these currencies through readonly fields (MoneyCurrency.USDollar), or additionally there are lookup tables (MoneyCurrency.GetCurrency(isoCode)) to lookup the currencies you may require.

Operations (Addition, Subtraction, Etc.)

The Money struct supports various mathmatical functions such as addition, subtraction, division, multiplication, Min, Max and Absolute value functions.  These methods can be used like decimal values (operators are overloaded so "money1 + money2" is possible), and ensure currency-safe operatons.  A currency-safe operation is one that ensures two currencies cannot be operated on together (unless the scenario makes sense).  For example, you cannot add EUR10 + USD10, as an InvalidOperationException will be thrown.  This is very important for obvious reasons (data corruption).

If you wish to add or subtract values that are of different currencies, Money.ExchangeAndAdd and Money.ExchangeAndSubtract operations have been supplied.  These operations will use an ICurrencyExchanger (that you will need to supply yourself) to convert the currencies to a common currency and then add them.  If conversion is not necissary, the exchange will be ignored.

Comparison Operators

The comparison operators of the Money struct have been overloaded to allow comparisons between two Money.  The comparision operators are much more intelligent than you would expect, and ensure that a comparison can be made between the two values (sometimes two Money of different currencies should not logically be compared).  See the examples below:

Money eur10 = new Money(MoneyCurrency.Euro, 10);
Money eurNeg10 = new Money(MoneyCurrency.USDollar, -10);
Money usd10 = new Money(MoneyCurrency.USDollar, 10);
Money usdZero = new Money(MoneyCurrency.USDollar, 0);

bool result = (eur10 == usd10); // returns false;
bool result = (eur10 > usd10); // throws InvalidOperationException (comparison not valid)
bool result = (eur10 > Money.Zero); // returns true
bool result = (eur10 > usd0); // returns true
bool result = (usd10 > eurNeg10); // returns true (positive always greater than negative)

This will ensure that when comparisons can be made, they will occur, but comparisons that may not be possible will fail.  Note that equality comparisons do not throw exceptions if currencies are inequal, but rather return that they are not equal.

Unit Tests

The included unit tests were created with the VS.NET unit testing capabilities and run successfully.

Sample VS.NET 2005 Solution For Download Here

More Posts