Tech Tock

Time is of the essence.

And Now For Something Completely Different

Here’s a blog post on MSDN that will answer all those other nagging questions.

September 29, 2010 Posted by | Uncategorized | | Leave a comment

WPF MetUp

I had a great time presenting at the .Net Meetup last week.  It was a lively discussion thanks to everyone who showed up.  David Barnhill gave me great support and his extensive knowledge and experience really added depth to the conversation.  Everyone’s feedback and prompting was just great and it was very interactive.

Thanks everybody.

Some of what we covered:

WPF is not the same old system.  Some older ways of doing things in WinForms are just alien to the WPF paradigm.  Extensive use of UI inheritance is out.  Use of templates and Prism is in.

WPF is 4 years old and still early in the adoption cycle.  Paradoxically, this is because its so good.  Its entirely revolutionary (at least compared to WinForms) and so different from what came before that in some ways its like starting over.  This leads to learning curves, staffing and project delivery issues during adoption.

The question is what does it really do for business?  The main thing is that you can do more.  Many things you may not have attempted in WinForms are done simply in WPF.

But how do you get started with WPF?  Same as any new technology I suppose:

  • Read the books.  WPF Unleashed is the top recommendation.
  • The videos on Channel9 are great.
  • There’s more videos from Microsoft here and here.
  • Jason Dolinger’s MVVM video is a classic.
  • Take training.
  • Hire an experienced WPF developer to join the team or bring in a consultant to help out on your first project.  A mentor is invaluable when starting out.
  • You can use WPF simply to start.  Don’t try to use every feature, just get the basics. At its most simple its not so different from WinForms.
  • You can have WPF controls, modules and/or pages in a WinForms app and vice versa so it can come slowly into an organization even with a legacy application.

September 27, 2010 Posted by | Uncategorized | , , , | Leave a comment

Linq to SQL – Not Dead Yet?

Is Linq to SQL Dead?  Microsoft says no in this cute Visual Studio Features vs. imageMyths applet.

Damien Guard (MS L2S/EF team member), on the other hand, tells how the framework will die slowly:

We said we would improve the core of it and add customer requests where it makes sense but that Entity Framework would be the primary focus.

If you heard otherwise it certainly wasn’t from this team.

Seems to be on life support, with the family just arguing if the tax situation is right to pull the plug this year or next.

Read all about the bug fixes, ahem, new features in L2S in .Net 4.0 here.

I wouldn’t mind its demise as long as something so simple and easy exists in EF when it goes.  I’m thrilled the ThreadPool is Dead and I hope I can be just as excited when Linq2SQL finally kicks.

September 18, 2010 Posted by | Uncategorized | | 2 Comments

If a Tornado Falls in Queens Does Anybody Hear It

Very few people seemed to be aware that Queens was hit by an actual tornado.  Since most of the houses are brick, people were mostly safe, but a lot of cars were totalled and trees overturned.

This is the Con-Ed outage map from Friday night, the day after the storm:

image

The NY Times has tons of fallen tree pictrues and an interactive map.

September 17, 2010 Posted by | Uncategorized | , , , | Leave a comment

INotify Snippet Update

Here’s an update to my INotify snippet.  The only change is that I took out an unnecessary ref from the CheckPropertyChanged signature.  Now I’m hosting the code at google so its easier to keep updated.

protected bool CheckPropertyChanged<T>(string propertyName, ref T oldValue, (no ref here)  T newValue)

September 15, 2010 Posted by | Uncategorized | , , , , | Leave a comment

Oh, The Things You Can Do With WPF

Here’s an animation I made for my upcoming WPF presentation.

You can download the code here, but you might want to wait till after the presentation when it will be finished.

September 13, 2010 Posted by | Uncategorized | , , | 3 Comments

Freakin’ Moq

While I, like many developers,  appreciate Moq immensely, its not perfect.

Here’s an interesting way to freak out Moq 3.1:

It seems that if you use a 2 dimensional array as a parameter (a common scenario in fixed income) Moq will throw an error when accessing the Moq’d object.

This code:

public interface IFreakOutMoq { void FooBar(string[,] Strings); }

var badMock = new Mock<IFreakOutMoq>();
var badMockObj = badMock.Object;   //exception here

Will throw one of these exceptions (I’ve seen both on different systems):

System.TypeLoadException: System.TypeLoadException: Signature of the body and declaration in a method implementation do not match.

System.TypeLoadException: Method ‘FooBar’ does not have an implementation..

A simple solution is to use a Moq friendly object instead of the 2D array:

public class TwoDArray<T> {
private readonly T[,] _array;

public TwoDArray(T[,] array)     {    _array = array;     }

public T this[int x, int y]     {         get { return _array[x, y]; }     }
public T[,] Array     {         get { return _array; }     }   }
}

Here’s a test class that shows a working and failing example:

using System; using System.Text; using System.Collections.Generic; using System.Linq; using Microsoft.VisualStudio.TestTools.UnitTesting; using Moq; using TestProject;   namespace TestProject {   /// <summary> /// an array implementation that doesn't ///     freak Moq out on MockObj.Obj /// /// if you put a 2d array as a param and call mockedObj.Object /// moq will throw exception: ///     System.TypeLoadException: System.TypeLoadException: ///             Signature of the body and declaration ///             in a method implementation do not match. ///     or  System.TypeLoadException: Method 'FooBar' ///             does not have an implementation.. /// /// this object can be used instead and moq is fine /// </summary> /// <typeparam name="T"></typeparam> public class TwoDArray<T> {
private readonly T[,] _array;       public TwoDArray(T[,] array)     {         _array = array;     }
public T this[int x, int y]     {         get { return _array[x, y]; }     }
public T[,] Array     {         get { return _array; }     }
}   }
/// <summary> /// mocking this interface causes: /// System.TypeLoadException: ///         Method 'FooBar' in type ///         'IFreakOutMoqProxy2dec23fc008646958fc3bae70cbe067b' ///         does not have an implementation.. /// </summary> public interface IFreakOutMoq { void FooBar(string[,] Strings); }     public interface IMoqOK { void FooBar(TwoDArray<string> Strings); }   /// <summary> /// Summary description for UnitTest1 /// </summary> [TestClass] public class UnitTest1 {   [TestMethod] public void TestMethod1() {
var goodMock = new Mock<IMoqOK>();
var mockObj = goodMock.Object;
var badMock = new Mock<IFreakOutMoq>();
var badMockObj = badMock.Object; //exception will be thrown here
Assert.IsNotNull(mockObj);
Assert.IsNotNull(badMockObj);   } }

September 9, 2010 Posted by | Uncategorized | , , , | Leave a comment

Channel9 Slurpy Update

I discovered a couple things since I posted the Channel9 Video Slurper instructions.

It seems that HTTrack doesn’t like pound signs in URLs, so the examples in my original post would only download the first page.  So I changed the #’s to ?’s and its working just fine.

I found a way to increase the speed.  Normally it seems throttled at 25K, but if you enter 999999 in Options/Limits/Max Transfer Rate, it will go to 100K.

Hopefully the redesign of Channel9 doesn’t break the setup.

September 7, 2010 Posted by | Uncategorized | , , | Leave a comment

Moq Does That

I just needed to Mock multiple interfaces for the first time and it was there and super easy to use.

Thank you Moq.

September 2, 2010 Posted by | Uncategorized | , | Leave a comment

   

Follow

Get every new post delivered to your Inbox.