Virtual Conference

Conferences have tons of great content, much of which gets recorded and posted online. Here, I offer up a virtual conference to all of you that has some of my favorite recorded conference sessions on a variety of useful topics.

I encourage everyone to explore further and share any interesting sessions they find in the comments. I’ve found lots of great sessions just by starting with one interesting video, then opening the recommended related videos that seemed interesting. From an educational perspective, I find this to offer much of the benefit of attending a live conference, but with much more flexibility and no cost. But, there’s no hallway track here however.

The Ability to Change Things

I touched on this previously in Management Shouldn’t Be The Only Option, but I saw this post, and it has me thinking about the topic again. The Codist regrets not having gone into management, for what looks like two core reasons. First the money: pretty straightforward since managers appear to make more of it and have more career advancement options to get even more money (and money has lots of advantages). The second reason – the ability to change things – is way more interesting to me.

I could go on and on but the key is that you can’t make changes in how people do things in a technical sense unless you have the ability, the authority and the opportunity. Once you make that call and assuming you find the right places to grow, the sky is really the limit.” Why doesn’t a top ranking developer have the the ability, authority and opportunity to change how things are done?” (emphasis mine). Read More

Xamarin

In case you missed it, Xamarin was acquired by Microsoft and now it’s available for free for small teams or non-commercial use. I had always been curious about this technology, but with the hefty price tag it was never going to really become something I would get to try. But now that it’s free, it immediately jumped out as something to do.

So far, I’ve done one tutorial and a little bit of exploring. I used this tutorial, which was a reasonable introduction to Xamarin Forms and into getting the environment set up. The environment setup was actually the hard part. The Visual Studio plugin was easy enough to install. Downloading the emulator was easy too, but it had odd conflicts with my existing install of VirtualBox. I managed to find some good advice on how to clean up the virtual network adapters that were causing the problem. The hardware acceleration options for the emulator are not actually “optional,” as without them I could barely log into the emulated device.

Xamarin Forms themselves are a bit of a throwback to WinForms (although it is all XAML under the hood), which was a skill I had mostly forgotten, having been doing web work more recently. The drag-and-drop editor works just as well as it did for WinForms, although out of the box you have a lot more custom widgets. There were a fair number of conventions the tutorial used but didn’t explain, like the id syntax “@+id/CallButton” and “@+id/TranslateButton”. It shows a clear pattern and that showed up in the generated resource class when you referenced these ids in the code it had you adding. This does come out in a nice and clean way to add references to these bits in the code. For instance,

Button callButton = FindViewById<Button>(Resource.Id.CallButton);

But the tutorial didn’t explain the id syntax or reference additional documentation. The deep dive explains some of this, but the tutorial and the deep dive could have been linked together better.

Overall it seems very nice and matches at least some of the hype surrounding the technology. While I don’t have any plans to make a mobile app it never hurts to try out something new so you can see what it can do.

Anonymous type XML serialization

I ran into an issue recently with the C# XML serializer. There was a fair bit of indirection, but it boiled down to this code snippet:

</pre>
<span style="font-weight: 400;">static string ToXml(object toSerialize){</span>

<span style="font-weight: 400;">XmlSerializer x = new XmlSerializer(toSerialize.GetType());</span>

<span style="font-weight: 400;">var results = new StringWriter();</span>

<span style="font-weight: 400;">    </span> <span style="font-weight: 400;">x.Serialize(results, toSerialize);</span>

<span style="font-weight: 400;">return results.ToString();</span>

<span style="font-weight: 400;">}</span>

<span style="font-weight: 400;">ToXml(new {item = "thing"});

 

That snippet results in the following error:

Run-time exception (line 15): <>f__AnonymousType0`1[System.String] cannot be serialized because it does not have a parameterless constructor.

I checked using reflection that the anonymous type has a single constructor that takes a string, as you would expect based on the lack of a parameterless one. That being the case, it makes sense that you can’t use the XmlSerializer against it since it doesn’t match the required interface. But, this brought up the question: if it matched, would the XmlSerializer accept it? There is a request out at user voice to enable this and there is a comment that implies it wouldn’t be simple. So I set out to find out whether or not it was a simple fix.

I opened up the intermediate language representation of the type and tried editing it to add the constructor. This quickly turned out to be beyond my current understanding of intermediate language. In doing research on intermediate language, I found a bigger issue – anonymous types are read-only. I had never even considered they wouldn’t be writable. This is a big deal because the XmlSerializer will not serialize read-only properties. Only enabling a parameterless constructor wouldn’t enable serialization unless the anonymous type was further changed. So, I endeavored to change the fake anonymous type to be read-write as well.

Overall this is all of the changes I made:

  1. Added parameterless constructor
  2. Added assembly declaration
  3. Removed the <> token which indicates a compiler generated class
  4. Changed the class to public
  5. Fixed the assembly declaration since it didn’t match the file name
  6. Removed initonly from the field
  7. Built the set half of the property and it’s backing method

Overall, it was easier than I thought it would be, and it does serialize once you make all of these changes. Check out the IL code here. Unfortunately, this sort of change will never get folded back into the mainline anonymous types, since breaking immutability would mean you can’t use them as keys for hashes anymore. Tuples don’t serialize either for the same reasons, maybe they could be extended, but then you can’t name the fields.

Book Chat:Release It!

I just finished reading Release It by Michael Nygard. Overall my opinion is mixed. The message is great, but parts of the book haven’t aged well since its release in 2007. It describes some specific technical details that were Java 5-centric, which are not helpful anymore. The overall concepts are still things you should know if you are trying to build a large-scale web application. There are three strong case studies of issues with specific systems that illustrate the value of the other recommendations being made.

Part One describes architectural patterns that were a precursor to microservices. It describes pitfalls to avoid when using those patterns; the microservices architecture solves all of the problems described. It does describe parts of microservices but only in SOA terms. There is lots of overlap between microservices and SOA, but it leaves open space for implementations that have known issues.

Part Two is all about preparing a brand-new system for launch and dealing with capacity planning for this. Again, it’s a great concept, but the specifics didn’t age well. For instance, there is a significant portion about capacity planning, but it is speaking in terms of running your own data center. With the significant rise of cloud options, running your own data center is not as relevant, so the discussion is not as complete as you would like. This part opens with a case study of a release and how black Friday caused a massive outage for the new e-commerce platform. However, the portions that describe how to better understand the patterns that control the capacity of the application are really good and still relevant. This information is available in other places but this is a nice concise description.

Part Three is about general data center networking, availability, and some basics of building a large system. Again, lots of good information, and maybe because I knew less about these parts, it felt like it aged better. There is some interesting math on SLAs and some tips for trying to figure out what the cost of increasing the availability of your service would be.

Part Four describes operational patterns that were a precursor to the DevOps model. It’s all about real-time monitoring, understanding the rhythms of a system, and anticipating the growth of that system. The ability to know what “normal” is, and tell when the system has deviated from normal, is critical to staying ahead of problems before they become crises. Anticipating growth isn’t just capacity planning; it is also about setting up version one to be able to deploy version two without downtime.

Despite the weaknesses on the whole I’d recommend the book. The case studies describe the sort of experiences that are critical to understanding how to build great software. But nobody should have to actually live through them. For anyone who wants a more modern resource on some of the individual aspects covered, notably Continuous Delivery and Building Microservices.