.NET 4.5.1

To continue the last post about the //BUILD/ Conference, what else is new? What should you look at now? A few things stand out and I will go through them in order.

See Function Return values in debugger

For F# or any functional language, return values of functions are pretty crucial to be able to see when you debug your code or else you are sort of robbed of the idea of a debugger. Of course, you do have less code and fewer bugs per user story in functional languages vs imperative languages in general, so debugging probably isn’t as important, but the fact that you had to change your code to be able to double check return values must have been a huge pain. The point is, now in VS2013 Preview, when you step past a return statement, you will see the return value in the Autos window as well as being able to access it in the Immediate windows as $ReturnValue. I know I missed it in C#, it must have been super annoying for our functional friends. The takeaways are YAY and  – try F# (still near the top of my to-do list).

64-bit Edit & Continue

ORLY? I will be happy to see the 64-bit dialog box go but would have been happy to just have the debugging stop immediately when somebody tries to type in a code window. That probably indicates that the programmer knows what’s wrong and needs to make changes, not that they would like to go full VB3. To me it’s just embarrassing to see VS handle 64-bit as if it was magic. There should be no difference for a real programmer how you handle 64 or 32 bit (beyond the obvious, but that’s a five minute conversation among stakeholders over coffee) and the fact that the segregation remained is a bit of an embarassment.

ADO.NET Connection Resiliency

EF/ADO.NET Connection resiliency. When you use SQL Database in Windows Azure, you will notice that you only get a brief window of connectivity so as to not waste server resources. This is brilliant and should have been the default on your vanilla SQL Server back in the nineties as well, it would have given us less sucky client / server apps back in the day, but the point is the folks over at ADO.NET now gave us connection resiliency, which means your connection autoresumes when you remember to access your database again. This means simpler code in your app and the database abstraction layer also abstracts connection failures, the way $HigherPower intended.

Hosting and Runtime Features

IIS App Suspension – Another Azure-derived feature is that they will allow web apps to run, but to be suspended in its current state when it has been idle for a while. This feature is available in IIS 8.5, Windows Server 2012 R2 Preview.

Large Object Heap compaction – the Large Object Heap can be now compacted as part of the 2nd generation GC run, as in a full stop-the-world GC, so use carefully. You will need to use a separate API to invoke this feature, but if you are having problems with the Large Object Heap not being compacted, you are probably aware of that and are prepared to add a line of code.

New runtime features that will affect you without you doing anything include automatic multi-core support to make app startup time faster and ASP.NET apps and also the fact that you will get Windows Updates of the .NET framework with precompiled native images. In previous versions of Windows your .NET apps will JIT mscorlib.dll et c as you run them when the dllis different from the cached binary installed with Windows, VS or a service pack.

Cadence – pleasing both camps

A huge deal is that the .NET Framework will go full Ubuntu style versioning, with many small incremental changes, with big bang Long Term Support versions made for the enterprise. They wouldn’t call it “ubuntu style versioning”, so I did it for them. They have implemented this by deploying new features as NuGet packages continuously, while they collate mature features and include them in big releases. This is pretty significant and a great decision.

Build Conference

Although Øredev as per usual will be the place to be, in this case November 4-8, Microsoft currently run two conferences of their own, TechEd Europe and more importantly //BUILD/ which covers the latest news about the preview versions of Windows 8.1 “Blue” and releated developer tools, Visual Studio 2013 and .NET Framework 4.51.

In general for Windows users, the most important things are the ressurection of the Start Button, which, in combination with the ability to set your desktop background as being the background of the start screen as well, will give you a smoother more vintage Windows feel. Also, there are impressive new features for Multi Monitor support, such as the ability to have different DPI on different monitors, which again pushes Wndows ahead of OSX.

But for developers, in the words of Lou Reed,  What’s good?  The cool things that have emerged are that XAML under Windows 8 has evolved far further. A whole new set of controls have been released that allow for better performance when dealing with large sets of data, there are tests to measure power consumption of an app to help developers save their users’ battery Life, you can manage separate frames on separate monitors (Think Powerpoint presentation vs Speaker Notes or Point of Sales cashier view vs customer view).
http://channel9.msdn.com/Events/Build/2013/2-164

Also ASP.NET has taken a huge leap forward with the separation between ASP.NET WebForms, ASP.NET MVC, ASP.NET WebApi and SignalR have been erased, allowing you to create one ASP.NET project after which you cherry pick the features you need. This has also meant a vast improvement in what you can do in WebForms, in terms of async support and model binding to name but a few things. I truly Believe users stuck in Legacy Hell will appreciate this the most of all the things that were introduced during build, including the debugging support for Async.
http://channel9.msdn.com/Events/Build/2013/2-546

Oh. and this is only after day 2, so there’s a whole last day to check out.

Good times

As the climate approaches acceptability in Sweden it’s time for the annual Lightening of the Mood, which is what Scandinavians do when the hiatus of gloom occurs that follows the sun coming out of hibernation and the impermeable grayish lid of nuclear winter is temporarily lifted.

There are other things than weather to motivate the increase of joy:

There is a plugin for Resharper that works with NancyFx. Not breaking news, but nonetheless joyful.
https://github.com/NancyFx/Nancy.ReSharper

There is a NuGet plugin for MonoDevelop and Xamarin Studio:
https://github.com/mrward/monodevelop-nuget-addin

In general, xamarin studio and its new UI designer for iOS is a Huge Deal and should be explored if you are into iDevices but still want to use the Language of Honor and Heroes (C#, that is).

WCF 4.0

As the tour is now concluded and we are doing business as usual I figured it is time to post some promised source code and powerpoint material. If you just joined us, the final Jayway seminar of the spring season was on Windows Identity Foundation and a short roundup of new features in WCF 4.0. Stefan Severin MC:d the WIF section while I did the presentation on WCF 4.0.

So what IS up with WCF 4.0?  My three main points were the following:

  1. Simplified Configuration
  2. Full implementation of WS Discovery
  3. A turn-key RoutingService

My full presentation in attached and I also submit some source code, largely based on Aaron Skonnard’s excellent MSDN article with minor modifications to show the difference between WCF3.5 and WCF4 in terms of configuration.

References:

Presentation

Source Code

Aaron Skonnard’s introduction to WCF 4.0

Windows Phone 6.1

I managed to lose my employer’s Nokia N82 and as punishment by my boss he stuck me with an HTC Touch Cruise Windows Phone Classic 6.1 phone that nobody had wanted to use since 2008. I have tweeted about my findings with the hashtag #punishmentphone.

In short, the experience has been mixed. Synchronization with Google Apps works like a charm with e-mail, contacts and calendar and the messaging function is quite OK in the way e-mail works and the SMS part has conversations just like the iPhone. Sadly, though, the Windows Mobile general feel remains with very bad tactile feedback from the touch interface and a borderline unusable virtual keyboard and having a Windows interace on a phone means that user stories like “Create new SMS” or “Make a phone call” be at least a few clicks too far away for comfort. Oh, and another pet peeve: When the phone boots, it throws the SIM-card PIN-code dialog at me first, but that gets hidden by the WinMo desktop and I have to go in to the comm manager and disable the phone and reenable it to get the PIN dialog to a place where I can actually punch the numbers in. WinMo has improved since before, though as the phone has only died on me once so far for no reason, which is vastly better than a QTek S100 I wrestled with years before.

NewID

Many of the companies in the former Way Group have now fusioned under the name Jayway, among them my beloved Dotway.

My dear employer has gone from being the key part in a cluster of separate expert companies (Dotway being the finest in .NET, Jayway ruling the world of Java, Testway laying down the law in the world of testing and Leadway striving forward in project management with Realway soldering on (sic) in the embedded systems field)  and fusioned ourselves into one formidable entity under the name Jayway. To this end we are all gathered under the jayway.com domain and all previous references to Dotway should now be pronounced Jayway.

Using the NHibernate OR-mapper

I have decided to go ahead and set up a class that covers the basics and a few more advanced features of NHibernate. In order to take part in the class, please contact Dotway Stockholm at stockholm@dotway.se

As Domain Driven Design has won followers over legacy Data Driven Design people are focusing on mapping a business case directly into a set of objects that describe the problen space and true workflow, solving the problems the customer wants to solve and thus focus more on stringent, understandable and maintainable systems rather than focusing on what data the system will contain and how to store it cleverly, systems for abstracting away object persistence .have emerged. In the Java community Hibernate has been the big name over the years and in .NET NHibernate is establishing itself as the major player being the foundation for several solutions for automated persistence such as Castle ActiveRecord with the ActiveWriter modelling toolset.
 
This class is directed towards experienced .NET developers looking to migrate to NHibernate in production, either wrapping legacy databases or going greenfield domain-first. It covers a variety of tasks from the basic “getting started” via configuration through XML as well as FluentNHibernate to complex persistence solutions with some comparison to other persistence solutions such as Linq2SQL.
Topics covered in this class:

  • OR-mapper. Why?
  • Getting started
  • NHibernate vs … part I
  • Implementing a Sample Case
  • Session model
  • Lazy Loading
  • HQL
  • Schema versioning and deployment
  • Best practices
  • Worst practices
  • NHibernate vs … part II
  • Troubleshooting
  • Performance tuning

Starting with a very basic example of an ASP.NET MVC website I will expand and elaborate on a number of features in NHibernate, such as configuration, transactions, session scope, various key types, numbering schemes and lazy loading to show how to solve problems with NHibernate and how to retrofit NHbernate on top of existing schemas as well as how to create and version greenfield schemas. I will use a demo version of nhprof to demonstrate how the features, settings and tweaks as well as the chosen platform affect the SQL generated

I hope the class will instill a greater understanding of and confidence in NHibernate for use in your current project. If you wish there will be a fistful of code you will be able to use as a starting pont for your own exploration of NHibernate and its features.

The Dark Side

Back in the nineties when I trained as an apprentice coder at the University of Umeå, I was first exposed to the Dark Side. It was very seductive with an intuitive TCP/IP stack, simple signal management conventions, concise UI:s, lean config files, powerful scripts, nifty daemons and of course the Bible: Advanced Programming in the UNIX Environment by W. Richard Stevens. I marveled at the distributed GUI, broken and deeply insecure though as it was, I admired that multi-user security concerns had been addressed back in the ‘70s already, not as an afterthought in 1989. Then I was brought out in the real world and began appreciating GUI conventions,  speed of implementation, solving customer problems and so on and came and joined the Just and Fair in the Microsoft camp and haven’t strayed since. Much.

But

But now and then the urge to complicate things gets stronger and stronger and with members of my immediate family having been lost to the Others for years now, the lure became overwhelming. After years of propaganda from my father I finally decided to install OpenSolaris on a virtual machine. Of course Solaris will not install on Windows Virtual PC Beta. It does not recognize any of the virtual SATA devices and thus cannot install. What to do? Well I gave up of course.

For a week or two until I thought I should make a serious attempt and actually dowloaded Sun’s VirtualBox.

VirtualBox vs Windows Virtual PC Beta

I really wanted to hate it, it not being made by the Just and Fair folks at Redmond. However, it is difficult to argue with 64 bit CPU high performance virtualization with USB, disk and network integration. It sucks the life out of the host machine, but in return both guest and host perform acceptably, lest you allocate too much memory to the guest “computer”, unlike with Windows Virtual PC where you get low performance (but better than Virtual PC 2007) on the handful of platforms it does handle.

Of course, I popped in the ISO in an empty Virtual machine (ironically using the same empty VHD Windows Virtual PC Beta created but couldn’t make available to Solaris) and of course the setup just chugged along event free. A vast improvement over previous UNIXes I installed back in the day. It refused to give me any options but to fill my VHD with the One Solaris partition to bind them all. None of that allocating partitions to /root, /home, /usr/local et c-business that used to be 90% of the fun of trying to set up a Unix style system.

Stereo? Not for me

Of course, once everything is set up you want to do stuff. Back in the day I would have set up FTP and the Apache httpd and created logins for friends and acquaintances and set up the firewall to allow for SSH:ing in to my computer. My computer in this case just being nothing but a figment of my laptop’s imagination, that would be even more pointless than it was back in the day. So: What to do? Weill, of course: Develop in .NET! After all, if I am to achieve global supremacy, I need to be able to code on Solaris as well, at some point.

This is where it all came back to me. Because it is a proper UNIX and not some humble Linux, allegedly, they haven’t gotten mono to run consistently on Solaris. The hours of gunzipping and ./configuring and make believing. compile errors upon compile errors. Downloaded various other package managers to appease the evildoers. Nothing I did could make mono build, despite gigabytes of source code. Ah well… Now I gave up properly.

OpenSUSE

Until I tried OpenSUSE, that is. Similar scenario, clean VM in VirtualBox, popped a physical DVD in my drive and shared it to VirtualBox, the empty VM booted and started the Open SUSE setup. I got to fiddle with my partitions (yay!) but I chose not to. Again, nothing fun happened during install, it just worked. A couple of reboots later I was able to login on my new machine, open the package installer, select everything mono-related and click install. After 20 minutes or se everything was downloaded and installed, and I just went to the Start menu(or what do you guys call it? The non-Start menu?) –> Applications-Development-Integrated Development Environment (monodevelop) and start to code. Very painless. Press play, off you go and you have ASP.NET being hosted on a Linux machine.

Then I noticed that my window was a bit on the smallish side, I would have preferred a higher resolution, like the one I had on the Solaris VM or so, so I go into the yast2 thingy and change display settings to something I consider appropriate and save the settings. I am instructed to restart the window manager, so I reboot the computer (yes I know. but it involved less interaction) and login again. Everything looks fine until after 5 seconds when the display gets garbled and I’m thrown out back to the login screen. I try all kinds of failsafe settings but to no avail. Of course I could manually edit a conf file somewhere to solve the issue, but Google has yet to reaffirm its friendship with me by coming up with a link to a Q&A forum where the question has been answered,

So?

Back to the good side it is, where stuff just works. Of course you can also end up in situations where stuff just doesn’t work as well (oi! CRM4! There’s this new thing, Windows Server 2008. It’s been out for a good two years now!), but resources are more plentiful and as an added bonus: you feel better cursing big successful company than makers of free software.