I’ve owned a Windows Mobile for some time, currently the HTC Tytn which sure is up for replacement. But I’m really waiting for the HTC Touch Pro 2 or the HTC Hero or something. With internet on it, it’s great to have the ability to check your email, search the internet when you’re waiting or be able to find customer addresses or something. And of course the ability to tweet about what you’re doing.
For that I’ve been using Twikini for some time, and I love its features. It’s really fast, as it’s written in Native C++ for maximum performance. The menu is also laid out very well and you have the ability to create a tweet and add a twitpic with your camera while you’re at it. This ability makes it wonderful to tweet about special events with family or friends and when you see something exciting happening on the road.
Trinket Software, creator of Twikini also has some other great applications. When you buy Twikini for only $ 4.95 you’ll get an additional application for free. Or, if you blog about Twikini like I just did, you get it for free! :)
More info and downloads right here : http://www.trinketsoftware.com/Twikini
Last week at the SDN Event in Houten, I presented a session on Windows Azure and how you can develop applications on it. How it differs from developing for servers that run on premises. After the presentation, the question was asked if developing for Azure was a wise idea, as some stuff did not seem production ready.
After thinking a bit more about this, I believe the person based his question on the fact that I talked about two subjects
I’ve talked about this and perhaps because of this (or me) people got the impression Azure is not production ready. Maybe these issues will be solved, maybe not. These are all API related issues though and have nothing directly to due with Azure being production ready.
From what I’m observing, the Azure team is working really hard to get Azure working and perhaps spends less time on tooling and API. I’m very sure these will come in the near future, but we can already develop for Azure and it’s less important than getting a complex technology like Azure ready for release. And that’s what I am sure of, that the team is making sure Azure will work.
Is Windows Azure production ready? The short and simple answer is probably no, because Windows Azure has not been officially released yet. But in my opinion it’s definitely worth checking out, because –as I said during the presentation- Microsoft is investing heavily on it. Invest in Azure now and reap the benefits of it sooner or later. It is expected that cloud computing will be as common in usage, as plugging in an electric device and instantly getting power is common right now.
Yesterday was a great day as the SDN Event took place in Houten. The location was really great and the food never has been better. The poll on the website shows others agree with me. Thanks to those who attended my sessions. Sorry to those who wanted to know more about SQL Data Services, but know that all I demoed yesterday in Silverlight 3 and .NET Ria Services should be (almost) immediately be transportable to Azure and SQL Data Services in the near future. I included scripts to generate the database for the Silverlight demo.
I have uploaded the slides and demos to the media section on BloggingAbout.NET.
If you have questions about Azure, Azure Storage, .NET Services, Silverlight or anything else, don’t hesitate to contact me. And know that we give courses about all these subjects as well at Class-A! :-)
Now this got me puzzled today for some time. I started up Visual Studio 2008 and opened a solution I had been working on for some time. But when trying to debug the application, it threw an error on Unity and the SerivceLocator trying to get an instance of a class. Not an interface, a class. It had no constructor nor dependency properties or anything weird, but I used Unity because it was supposed to in the future.
Anyway, I got an error from Unity and some inner exception said
Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Now that was super weird of course. Weirder even was that all tests, also using Unity, still all succeeded. So I replaced the line of code to instantiate the class by hand and it worked. A few lines further LINQ was used and the same error occurred. So I tried everything from running other applications and opening other VS2008 solutions, doing memory tests, etc, etc. Everything worked fine, but just this one project I was supposed to work on.
I Googled and even Blinged for some time, without finding anything relevant. Until I stumbled upon this thread in the Microsoft forums. There they did not find the error just weird, but wierd even.
Anyway, the solution was to enable JIT optimization. In other words, in Visual Studio 2008 choose “Tools” and then “Options”. Select “Debugging” and “General” and find the line that says “Suppress JIT optimization on module load”. This kind of makes sure that the debugger and the JIT compiled code aren’t running out of sync because the JIT compiler is such a super duper optimizer of your code. This did the trick.
Of course my code is so much optimized it never runs out of sync, but it still didn’t feel good. So I was trying to reproduce the error and turned “Supress JIT optimization” on again. To my even bigger surprise, the error did not return and my application is working just fine again. This even more ensured me turning it on or off on my own code, does not make a difference… ;-)
I just downloaded and installed Isolator 5.3.1 which has the ability to fake DateTime.Now, probably one of those functions in .NET you’ve always wanted to isolate correctly in tests. And now you can. For quick reference, check the Typemock Insider blog.
This can however be a breaking change in your unit tests. For example, we had the following test to verify of a DateTime was put into a property.
Isolate.Verify.WasCalledWithAnyArguments(() => someObject.ProcessDate = DateTime.Now);
With version 5.3.1 the test failed with the following error message.
TypeMock Verification: Method MyNameSpace.SomeClass.ProcessDate was called with mismatching arguments.
I fixed this by setting the following behavior on DateTime.Now.
// Arrange var testDate = new DateTime(2000, 1, 1); Isolate.WhenCalled(() => DateTime.Now).WillReturn(testDate); // Act // Some code here // Assert Isolate.Verify.WasCalledWithAnyArguments(() => someObject.ProcessDate = testDate);
As Dennis Doomen, I was quite happy with how the session went. Some stuff went by pretty fast, mainly because I did not want to present how the tools I used work, but did want to show the audience how I did it and what the tools are capable of.
Here’s the presentation if you’d like to review it and I’ve created a package with the demos as well. It contains…
Thanks to the many votes we received on our wildcard proposals from attendees, colleagues and community members, Pieter Joost van de Sande, Dennis Doomen, Michael van der Veeken and me have won a timeslot on next week’s Microsoft Developer Days. I’ll be talking about creating a build and doing continuous integration on Friday May 29th at 15:00 in the conference room named South America.
I will be showing how you can do continuous integration with the new abilities that Visual Studio 2010 has for this. I’ll also be showing other tools that can help you and give you best practices and pitfalls on continuous integration.
I’ve been on a fair amount of projects in the past 10 to 15 years and almost all of them were waterfall. I’ve become really, really great in being able to tell if a project will fail soon or later. Not sooner or later, but soon or later. My weakness however is that I’m not really able to tell how to really run a project. I have some ideas that I preach, but it’s very rarely that I’ve been able to practice these. Of course it’s not my job, but it’d be nice to be able to tell others from experience.
I’ve just read Scrum and XP from the trenches and thought this was a great book. One thing I noticed however was when Henrik Kniberg was saying that the product owner gets to choose priority of the stories, but the team says how many stories go into a sprint. Kniberg describes how the product owner can influence this by altering stories or priorities, but the team sets the estimated velocity and thereby selects how many stories go into a sprint.
This reminded my of Microsoft Solution Framework, where in a team with different roles, there’s always the product manager and the program manager. These roles can never be filled by the same person. Putting it simple, the first role is there to make sure the customer gets what he wants. The second role is to make sure the team isn’t stressed out, can do their job, etc. That’s why the title of this post says “a project manager”, which is the opposite of “multiple” :-)
On every single project I’ve been on, I’ve always only had a single project manager. There are of course good project managers that really take care of the team. But because of various reasons, there’s always much more work than was originally planned and with this and various other reasons, the development team suffers by doing lots of overtime.
But with the simple rules stated above for both Scrum and MSF, the development team is (to some degree of course) protected from being burned down completely by doing so much overtime, that the people, the code and as a result the product, suffer greatly.
Very soon I’m going to start a new project at a customer and will really try to practice Scrum, sprints and daily scrums that take 15 minutes at max. Maybe I’ll blog about the experiences so people can learn from it or give me some hints on what we should do. The people involved so far are also pretty anxious to use Scrum and some XP practices for this project, so we’ll see where this ends.
Conclusion so far however is that if you have only one role that mainly keeps track of some Excel sheet but hardly protects the team for overload of stories, use cases, function points, features or whatever you may call them, perhaps you should look for another job… erm, project manager.
Because it’s not clear to anyone, I want to state that you don’t have to actually be a visitor of the DevDays to be able to vote on the sessions. The only thing you need to do is register for an account, verify your email address by clicking on the link in the email you receive and you’re allowed to vote. Don’t forget to vote for my session.
Almost all companies use a source control repository to work in a team, but a lot of those don’t use Continuous Integration (CI) to…
That’s what I want to explain and show during the developer days. If you want to know more about this, vote for my session.
Dennis Doomen will also be able to present you with a great presentation on Test-Driven Development and SOLID principles by Robert C. Martin (Uncle Bob) if you vote for him too.
On a site note, it’s funny how I sometimes see the ranking of both sessions drop. Some people seem to vote on a friend or colleague and give a thumb down on my and Dennis Doomen his session. Although it might be tempting to make all our thumb up voters also give a thumb down to all other sessions, it’s also a pretty sad. So giving me the thumb up will do, thank you. :-)
There’s a lot of discussion going on about designing for testability. One of the problems of unit testing your code is that you might want to insert a fake object (like a stub or mock) so that your code under test won’t actually call out to the database or an external logging class. You can solve this by Inversion of Control (IoC) and using Dependency Injection (DI). You insert an object you want to isolate or an object you want to do assertions on via the constructor or properties.
Typemock Isolator also has a very powerful feature where you don’t have to use dependency injection. Let me be clear on this before you continue reading : you don’t have to. I know with Isolator you might not even need DI but it’s still a good practice to decouple dependencies. But I personally think it’s a bit sad that you need to change your design and use DI just because else you would not be able to write your test. And that’s where Isolator can help us.
Imagine we have to following code. A class called “SomeClass” with a method called “SomeMethod” that we want to test. This method however creates an instance of the “ClassWithProperties” class. Our method will fill this object and we really want to see what happened with this object. We want to verify it using tests. We’ve got different tests to test “ClassWithProperties”, but we want to know if the few lines of code that work with this extra class is doing what we expect it to do.
public class SomeClass { public void SomeMethod(string name, int age) { ClassWithProperties cwp = new ClassWithProperties(); cwp.Name = name; cwp.Age = age; // Start processing, calling ServiceAgents, whatever... } } public class ClassWithProperties { public string Name { get; set; } public int Age { get; set; } }
A real life example of this, for me at least, was where an Order object was created and filled with order lines and customer information and I wanted to assert the flow inside the method and if the object was filled correctly. Was the Order object indeed filled with the correct information?
We can insert the ClassWithProperties object via DI or use a ServiceLocator but why do that if you have a powerful framework? Using Reflective Mocks, the ‘old’ way (since there’s a much better API now) we could do the following.
[TestMethod] public void CanWeGrabInternalObject() { // Arrange string name = "Dennis"; int age = 34; Mock mockedClassWithProperties = MockManager.Mock<ClassWithProperties>(); // Act new SomeClass().SomeMethod(name, age); // Assert var result = mockedClassWithProperties.MockedInstance as ClassWithProperties; Assert.AreEqual(name, result.Name); Assert.AreEqual(age, result.Age); }
What you see here is that a Mock object is created at line 8, which could be described as a fake version of our ClassWithProperties. We then make the call to “SomeMethod” at line 11 and pass two arguments that is mapped onto the class that’s created inside “SomeClass”. However using MockManager.Mock we make sure future instances are replaced by our fake object. When the call to “SomeMethod” is done we can retrieve the instance that our fake object is at line 14. We can then easily assert its current state and see if everything was correct. The Reflective Mocks is however not the most easiest way to go, although it’s still very powerful.
The Triple-A or ArrangeActAssert API is since Isolator 5.0 the way to go because of cleaner unit tests and its API is also much easier to understand. In our example we’d get the following result.
[TestMethod] public void CanWeGrabInternalObjectWithNewAPI() { // Arrange string name = "Alex"; int age = 37; var fake = Isolate.Fake.Instance<ClassWithProperties>(); Isolate.Swap.NextInstance<ClassWithProperties>().With(fake); // Act new SomeClass().SomeMethod(name, age); // Assert Assert.AreEqual(name, fake.Name); Assert.AreEqual(age, fake.Age); }
In line 8 we create the fake instance but nothing happens with future instances. If we’d use DI we could inject our fake object. As we’re not, in line 9 we’re making sure the next instance that’s created is swapped with our fake object. As you can see this is exactly the same behavior as the first test we wrote, but it’s much more clearer on what’s happening. We then call “SomeMethod” and make the same assertions.
However we’re now interfering with everything that’s normal to this ClassWithProperties. Constructor and other methods aren’t called. When we do want the class to act as usual, ie. be able to execute methods on it, we need a different approach. The "Isolate.Fake.Instance” method has an overload that allows us to supply an argument what the fake object should actually do. We can use Members.CallOriginal on it to make it behave like before. However that will also destroy our ability to check the state of the swapped object.
This is where we can perform a little trick though. Now that we have access to our fake object, we can redirect every call to this fake object to an object of our liking. We don’t even have to use a fake object. Hence the following test.
[TestMethod] public void CanGrabFakedObjectAndRedirectCalls() { // Arrange string name = "Marco"; int age = 33; var fake = Isolate.Fake.Instance<ClassWithProperties>(Members.CallOriginal); var original = new ClassWithProperties(); Isolate.Swap.NextInstance<ClassWithProperties>().With(fake); Isolate.Swap.CallsOn(fake).WithCallsTo(original); // Act new SomeClass().SomeMethod(name, age); // Assert Assert.AreEqual(name, original.Name); Assert.AreEqual(age, original.Age); }
Here you see that with the creation of the fake “ClassWithProperties” object, we specify that we actually want to call the original object. You normally do this, for example, when you want to verify specific calls on the object, set expectations on only a few method calls and/or want to redirect one or more calls. And that’s what we do, but we’re redirecting all calls. And we redirect them to the variable we call “original” in this test.
This will make sure, everything that’s happening on the fake object will get redirected to the object that we initialized, maintain and eventually assert in our test. Again, simple state based testing, although less elegant than the first test with reflective mocks.
Now of course there’s also a different way and speaking of elegant code, this is also technically better. And although I love state based testing over verifications (because most of the time it’s more readable), this last test is probably the nicest there is right now.
[TestMethod] public void UseVerificationsOnObject() { // Arrange string name = "Mike"; int age = 35; var fake = Isolate.Fake.Instance<ClassWithProperties>(Members.CallOriginal); Isolate.Swap.NextInstance<ClassWithProperties>().With(fake); // Act new SomeClass().SomeMethod(name, age); // Assert Isolate.Verify.WasCalledWithExactArguments(() => fake.Name = name); Isolate.Verify.WasCalledWithExactArguments(() => fake.Age = age); }
As a conclusion, there seem to be a lot of options with Typemock Isolator. Two remarks have to be made here. First of all, Isolator is so powerful that sometimes problems can have multiple solutions to it. This isn’t always what you want, as this makes finding the best solution harder. Especially when you don’t know what the best solution is, even though you know all possible solutions. Luckily with the new AAA API it’s much more clearer on what path to take.
As a second, for these tests, I’d say the last one is the best, because it’s best at revealing all the intention, one of my favorite rules of TDD by Kent Beck in his Extreme Programming Explained.
Every developer is familiar with the phrase "It works on my machine". But what if you could claim your code can be deployed at any time of the day? Simply because the latest tested and verified version has been prepared for you on your build server. Not to mention with separate installation packages for both testing-, acceptance and production environment?
If you would like to know how you can set up such an environment using the best tools and the best practices, vote for me at the DevDays site and let me tell my story in one of the two wildcard sessions.
I’m going to be talking about how to setup a build and use continuous integration to build the code, verify all unit tests and integration tests, build packages for all different environments and servers and setup configuration for each of them. We’ll do this using Team Foundation Server, MSBuild, FinalBuilder and more and also list a lot of the common tools used. Also discussed will be how to setup each environment and how virtualization can help you set these up. After visiting this session, you’ll know the best practices but also some of the anti patterns of continuous integration.
And if you want to know how you can get cake at work, every day, vote for my session and some see it.
Via Twitter @MarcelMeijer and SDN site, that Silverlight 3 SDK Beta 1 was just released, a few hours before Mix09.
Because of the nature of my work, coaching people on-site and training people in classes, I talk to a lot of developers and managers about the way people work. Unfortunately a lot of companies still don’t unit test their software and don’t setup an automated build. At times that’s specifically what we at Class-A are hired for. But if it’s not, we try to convince our customers that they gain by working with these practices.
Most companies want to professionalize and create better (quality) software. But for some reason, this can’t cost them anything. And I’m not talking about development time or learning curve, that’s a different story. I’m talking about the licensing cost of the tools you want or even need. For some reason people can’t lay down a few hundred dollars for something that will save them immense amounts of time, and thus money.
People rather spend countless number of hours on creating their own grid, whereas for a small amount of money you can buy a grid that has it all and can do it all, before you started thinking about it. People rather spend countless number of hours writing extra code, just to make it testable. People rather spend countless number of hours doing stuff that can be automated, generated or in some other way be helped with. I’m not sure about you, dear reader, but on my part this is unacceptable.
This blogpost is about my top 3 favorite products for developing software. Each one of them costs money, while there are free alternatives. But they’re in this list because they make developing software so much easier, that they pay back the investment within a matter of weeks or sooner.
Again, if you really want to gain in productivity and think this is worth money, buy these tools.
If you want to lag behind, have less control over what you’re doing and don’t think quality is something your customers need, don’t…
I suddenly remember that Azure can supply you with analytics on how your services and storage is doing, so I wanted to check this. Some funny results came out of this.
First of all, these statistics are about my speed traps application I blogged about before. It’s nice to know what it actually does.
So here are the statistics for my service and my website. Urls can be found in the previous post.
In the left image you can see the number of VM hours used every hour. This means that every hour of the day, I use up 4 hours of VM usage. This results in 96 VM hours per day. Which is kind of weird, as you get a max of 2000 VM hours per trial-key, which means my service should not be able to run for 21 days straight. Meaning that my speed traps service should start failing any day now! Here’s how…
The following two pictures are about my storage. In the left image you can see the daily network usage in megabytes. Per day I transfer a maximum of about 2 megabytes. On the right side you can see the daily storage usage in megabytes as well. The funny thing is, as I’ve told, that every time before I store the latest speed traps, I delete all current available in my table storage. But still I use up to 40 MB of storage per day. Is that accumulated? No idea.
I got sick of manually attaching to the webserver (either aspnet_wp.exe on WinXP or w3wp.exe on Win2003 or later). You can have a macro for that, incl. a shortcut key. I got this from somewhere on the web, but forgot where. If I find out, I’ll of course post it here. But I constantly have to search my sent items in Outlook for this bit of script when I tell someone about this. So here it’s on my weblog.
Now go to your web application project and press ALT+F10 and you're in debug mode, attached to the webserver. Press F5 in your browser (of course in the correct website) and you're done!
Here’s the code:
Imports System Imports EnvDTE80 Imports System.Diagnostics Public Module AttachToWebServer Public Sub AttachToWebServer() Dim AspNetWp As String = "aspnet_wp.exe" Dim W3WP As String = "w3wp.exe" If Not (AttachToProcess(AspNetWp)) Then If Not AttachToProcess(W3WP) Then System.Windows.Forms.MessageBox.Show(String.Format("Process {0} or {1} Cannot Be Found", AspNetWp, W3WP), "Attach To Web Server Macro") End If End If End Sub Public Function AttachToProcess(ByVal ProcessName As String) As Boolean Dim Processes As EnvDTE.Processes = DTE.Debugger.LocalProcesses Dim Process As EnvDTE.Process Dim ProcessFound As Boolean = False For Each Process In Processes If (Process.Name.Substring(Process.Name.LastIndexOf("\") + 1) = ProcessName) Then Process.Attach() ProcessFound = True End If Next AttachToProcess = ProcessFound End Function End Module