... all I'm offering is the truth. Nothing more. RSS 2.0
# Friday, January 08, 2010

I installed WinZip the other day, I was not ready to purchase a full copy yet but I was greeted with this message box …

image

Pretty harmless until I started to realize that they are switching the “Evaluation Version” button and the “Buy Now” every time you start it up.

 image

I decided to not purchase the software and uninstalled the whole thing on principal … shame on the developer that thought of this!

Technorati Tags: ,
Friday, January 08, 2010 10:34:33 AM (Eastern Standard Time, UTC-05:00)  #    Comments [1] - Trackback
Minutia
# Wednesday, January 06, 2010

I have been reviewing some code where a clear appreciation of the difference between ‘&’ and ‘&&’ is not fully realized. The humble ‘&’ provides a distinct way to provide a logical ‘AND’. Let us take this simple class with a single string array associated with it. Lets ignore the obvious lack of properties for a moment…

public class SimpleClass
{
    public string[] SimpleString;
}

Now when we go to use this class we would want to ensure that the SimpleString array is not null before actually performing any operations on it. One way could be to nest the if statement as follows:

if (foo.SimpleProperty != null)
{
    if (foo.SimpleProperty.Count() > 0)
    {
        MessageBox.Show("Success");
    }
}

This might negatively effect your Cyclomatic Complexity and we could not have such an offense ;) So a simple AND (‘&’) would be useful but as mentioned before this is a logical AND, as a result both values are always evaluated. So the following code would actually fail in the event of a SimplyProperty actually being null.

if (foo.SimpleProperty != null & foo.SimpleProperty.Count() > 0) //this could give you a null exception!!
{
    MessageBox.Show("Success");
}

So to the use of ‘&&’. With this technique the JIT compiler always checks the validity of the first expression and if it is false will not even evaluate the second (or subsequent) expressions in the if statement.

if (foo.SimpleString != null && foo.SimpleString.Count() > 0) //this is safe from null exceptions!! 
{
    MessageBox.Show("Success");
}

Simple, basic and true!!

Wednesday, January 06, 2010 7:59:56 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0] - Trackback
C# | Programming Note to Self
# Sunday, January 03, 2010

I have been on a real green\energy saving\eco friendly push recently. Last winter my energy cost went through the roof and I want to ensure that my house is better prepared. I started by simply placing weather stripping on all of the exterior doors, all the obvious stuff, then I happened to see a device that may help me. It is called the Ryobi IR001 non contact infrared thermometer, this hand held device shoots out a laser so you can accurately measure the temperature of very specific spots on your walls, windows, outlets, fireplace and vents. In fact this little device has already helped me eliminate two poorly insulated locations in my house and I am working on a third.

ryobiI am taking averages in the following location to see how effective the heating and insulation of the whole home is…

  • Average temperature of first floor register
  • Average temperature of second Floor register
  • Average north facing exterior wall temperature
  • Average south facing exterior wall temperature
  • Average north facing window temperature
  • Average south facing window temperature

If you want to do a comprehensive home energy audit (without the upfront cost) you can also sign up with Microsoft Hohm. You can see sample energy reports based on your area (where available) and see how your home stacks up. The initial questionnaire is kind of long but it is necessary to see what kind of home improvements you can do, and what improvements you may in fact need a professional to do.

My gas bill is already down significantly over last year so I am really happy with the device and my new green stance … oh and my wife and I bring our recyclable shopping bags with us everywhere we shop ;)

 

Technorati Tags:

Sunday, January 03, 2010 10:59:36 PM (Eastern Standard Time, UTC-05:00)  #    Comments [1] - Trackback
Energy Saving | House
# Wednesday, December 30, 2009

If you are working on a massive web project and the lead developer has no clue what Peter Blum controls are … pick up your ergonomic keyboard, mouse, and the spare monitor from home and get the heck out of Dodge!

Technorati Tags:
Wednesday, December 30, 2009 11:20:33 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0] - Trackback
Humor
# Sunday, December 13, 2009

I am a huge fan of WPF and more specifically Silverlight so when my wife took the opportunity to incorporate Expression Blend into a recent project I was eager for her to give the new Sketch Flow pattern a whirl. The Sketch Flow concept came across as the ability to mock up a complete application or website and transform that into a working production model. Effectively narrowing the gap between the client, designer and the developer. After working with my wife over the last couple of months it is clear that this particular idea was misrepresented.

My wife had created a prototype using the Sketch Flow concept and put together a very compelling, and partially functional, application. Unfortunately that fact that project was in fact Sketch Flow means that you just cannot simply open this application up in Visual Studio and start doing the complex software engineering work. In fact there a bunch of hoops (albeit well documented in Blends User Guide) that need to be followed in order to make this happen:

image 

It is just clear to me that the role of the Devigner (Designer and Developer amalgam) is not a cohesive as advertised.

Sunday, December 13, 2009 10:09:28 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0] - Trackback
.NET | Silverlight | Visual Studio | WPF
# Wednesday, December 09, 2009

On a recent project I was asked to provide a real easy way to zip multiple files and while I have seen this problem solved many moons ago in VB6 I have never really thought about this question from a managed framework standpoint. While navigating MSDN I came across GZipStream but this did not explicitly provide an interface for adding files to a zip archive. Several Bings later I came across a highly rated project on CodePlex called DotNetZip.

I must say this got straight to the point, with a intuitive API that was well documented and explained. Here is a code sample:

using (ZipFile zip = newZipFile()
{
    // add this map file into the "images" directory in the zip archive
   
zip.AddFile("c:\\images\\personal\\7440-N49th.png", "images");
    // add the report into a different directory in the archive
   
zip.AddFile("c:\\Reports\\2008-Regional-Sales-Report.pdf", "files");
    zip.AddFile("ReadMe.txt");
   zip.Save("MyZipFile.zip");
}

DotNetZip is packaged as a single DLL, a single assembly. It is fully managed code, written in C#, and provides support for reading and writing Zip archive files and streams. The main type is ZipFile, featuring methods like Add(), Extract() and Save(). There are string and int indexers for the entries of the ZipFile. There are properties for things like password protection, unicode and codepage support, and ZIP64 behavior. And there are progress events for Reading, Saving, and Extracting.

Technorati Tags:
Wednesday, December 09, 2009 9:53:09 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] - Trackback
C#
Blogroll
Statistics
Total Posts: 334
This Year: 22
This Month: 0
This Week: 0
Comments: 32
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2010
Mark Downie
Sign In
All Content © 2010, Mark Downie
DasBlog theme 'Business' created by Christoph De Baene (delarou)