Posts

Showing posts from 2014

Getting started with Redis for Windows

TL;DR - Download redis installer:  Redis-64 (2.8.17) Introduction Redis is an open source, BSD licensed, advanced key-value cache and store that you can read more about on redis.io . There are various video introductions to it, including Channel 9's  Getting Started  and Azure Friday's  Introduction to Redis . Obtaining Redis for Windows Microsoft OpenTech is distributing Windows ports of Redis. Whereas the team is working on adding support in the Microsoft Web Installer and have had various links to installs out there, it's not easy to find a go-to spot to download the latest stable version. If you are using Chocolatey , you can install redis into a local directory by executing choco install redis-64 Since Chocolatey is built on top of NuGet, if you'd rather get the package from within Visual Studio, run  PM> Install-Package Redis-64 from the package manager console. It will download and extract the Redis executables in a Redis-64* sub d

Swift from a C# developer's point of view

I'm thinking I might a bit of a language nut. Or maybe it's the fact that I made a half-assed attempt at Objective-C back in the day, but never could get past the barrier of brackets. In either case, Swift doesn't look half-bad. It has many of the nice features that I'm used to from .NET, including generics, while getting rid of a lot of cruft from Objective-C, including separate header and implementation files and at-declarations (@property(nonatomic copy retain)); all-in-all making the coding on iOS and Mac a lot more approachable from a variety of languages, including C#, Java and JavaScript. Listening to podcasts about the language, you quickly get to the realization that the language and tooling is still maturing (read: changing), so learning and writing about it is volatile at the moment. That said, let's ... have a Swift conversation, shall we? For starters, there's var - which works like var in C# - and let - which works like let in F#. And there&

Love your error conditions

Image
Let's hammer out some code! The above code looks fine and reads nicely - "if we don't have any app settings key called HttpBaseUrlSettingsKey , ... throw a configuration errors exception that explains what's wrong". In reality, however, what comes out, is an  ArgumentNullException  - AppSettings.Get returns null if it cannot find the requested key. This might not be so bad if you're consuming this code from the same solution. However, in a dependent solution, you get very sparse information about what went wrong: Not quite as nice as the intended "Missing keys ' HttpBaseUrlSettingsKey ' ... in appSettings element" message. A correct implementation in this case could look like this: However , the moral of this story is: Love your error conditions and test them. Don't just run down the happy path, leaving your carefully crafted checks behind!

Advanced Distributed Systems Design with SOA, part 3 of N

(This is part 3 of my notes from the ADSD-SOA course. You'll  find part 2 here .) 5. The Topology won't change ... unless a server goes down and is replaced, which is a premise on which cloud services are generally built (see, for example, what an Azure container looks like ), is moved to a different subnet ... or we're serving wireless and mobile users (see Google's   Mobile Performance from the Radio Up ) ...  So ... if our target endpoint (ex. server) is no longer where we expect it to be, what happens? Well, first off: Nothing! And for a significant amount of time too! The default timeout for both OpenTimeout and SendTimeout  in WCF is a minute each ! Connections to SQL Server? On premise, the default timeout is 15 seconds. If you're connecting to an Azure SQL database, it's 30 seconds . Imagine having a thread waiting for such a connection when/as a client disconnects. It's quite the common scenario. Now, multiply the scenario by 10 clients, 1

Advanced Distributed Systems Design with SOA, part 2 of N

(This is part 2 of my notes from the ADSD-SOA course. You'll find part 1 here .) Due to the fallacies we have already discussed, whenever possible, favor in-process execution over remote procedure calls. An in-process call, takes about 10 microseconds to execute. A Remote Procedure Call over the Local Area Network, takes somewhere between 500 microseconds to 1 millisecond, i.e. 50 - 100 times slower than the in-process one. When we step out into a Wide Area Network, we end up with call times of about 50 milliseconds. That is another 50 times slower. Now, imagine that we have a remote object on which we read or write a couple of properties. Not scared yet? What if we put the calls in a loop. But we don't write code like this, right? Enter Inversion of Control and Dependency Injection. IoC is great, don't get me wrong. However, a caveat of this technology, is that you do not know whether or not your service is local or remote. In fact, that's one of its value proposit

Advanced Distributed Systems Design with SOA, part 1 of N

A couple of weeks ago now, I had the opportunity to partake in Udi Dahan's excellent ADSDS course in London. For my own sake (to better absorb the course through repetition), as well as for you (to, perhaps, learn something new) and, at the same time, toss some credits Udi's way, what follows is a collection of notes that I took during the course. No, I won't share the slides. If you find the notes interesting, book the course through Skills Matter , or through Particular Software . It's well worth your time ;-) Meta Udi comes across as a very calm, collected and professional in the way he teaches his class. With intermixed breaks, he keeps his students attentive throughout all five days of his course. I was very impressed by his teaching skill alone. Systems are not Applications Historically, we haven't had to deal with the term  connectivity , really. This is not something that is baked into the mainstream programming languages. Similarly, pattern books

Could not find concrete type mapped to ... #nservicebus #ncrunch

Image
Know your tools. Today, I learned that to successfully run NServiceBus tests through NCrunch - and this is really related to the IoC aspects of NServiceBus why it's not product specific - you need to do a little more with regards to your test setup than just doing Test.Initialize(); I ran into the following output in the NCrunch error window: System.ArgumentException: Could not find a concrete type mapped to IfInsurance....IPolicyActivatedMessage    at NServiceBus.MessageInterfaces.MessageMapper.Reflection.MessageMapper.CreateInstance(Type t)    at NServiceBus.MessageInterfaces.MessageMapper.Reflection.MessageMapper.CreateInstance[T]()    at NServiceBus.MessageInterfaces.MessageMapper.Reflection.MessageMapper.CreateInstance[T](Action`1 action)    at NServiceBus.Testing.StubBus.CreateInstance[T](Action`1 action) in c:\BuildAgent\work\d4de8921a0aabf04\src\testing\StubBus.cs:line 242    at NServiceBus.Testing.Handler`1.OnMessage[TMessage](String messageId, Action`1 initializeM

Super-Quick: Host a simple web page through GitHub pages

There are instructions out there , but it still took me a couple of attempts to get it right. Here's the super-duper-happy-path ( Expression © NancyFX ;-) ): Create a GitHub Account Create a public repository named your_username .github.io (pick .gitignore and license as it suits you). Create a file called CNAME containing the hostname you will publish under ( example ).  Create a file called index.html  containing your web page. Sign up for a DNS provider: I use DNSimple (referral link). Fiddle with DNS Records automatically (highly recommended) or manually (I never got this right ...): Automatically: Add the GitHub Pages service from DNSimple Manually: Create a CNAME record from  (empty (nada, silch))  to  your_username .github.io Have fun!

NCrunch and PostSharp

They're both great tools, but today, I had to separate them, seeing as they were unable to get along! I kid, I kid... I did get a build error through NCrunch, however, saying The "PostSharp.MSBuild.PostSharp20GetCurrentProjectDirectory" task could not be loaded from the assembly ... To get around this issue, I right-clicked the failing project in the NCrunch Tests window, selected Configure Selected Component , causing NCrunch Configuration window to show. There, I clicked the Additional files to include button and added the directory in which I had my PostSharp .dll files. Et voilà, things were looking great again! (Thank you, Remco for the handy forum post , leading me to the solution!)

Creating NuGet packages from a solution

Image
Alternate title: Packaging multiple projects into one NuGet package [Updated Thursday, March 13th, 2014: Added Troubleshooting] Background For a recent client project, to make it easier for my developers to create certain types of projects, I created specialized NuGet packages that contained the most commonly referenced infrastructure pieces that they would need. For example, if they were to create a portable  Application Service  component, they would want to reference the shared Foundation library, followed by a Application Services Foundation library and some Common Data Types. I also knew that they would be dependent on a number of NuGet packages, prominently the Microsoft.Bcl package (which, in turn, references Microsoft.Bcl.Build). Let's walk through how this is done! To create a singular NuGet package containing all these references, create a new, Blank Visual Studio solution, add a Solution Folder called "Package Source" and a Portable Class Library Pr

Debugging session ended.

Image
I've been involved in some Xamarin development of late (which is evident from the other blog I've been writing at - monodeveloper.org ). I recently ran across a tedious issue at a client's and I thought I'd share the solution with you, dear reader, so that you don't have to waste nearly as much time as I had to. Scenario: You have built an iOS application in Visual Studio. It might've worked before, it builds now, but nothing ... happens. Visual Studio says "Debugging session started", followed by "Debugging session ended". Error list says nothing. Output says nothing. Hell, not even the "Mac Server Log" spits out anything useful. Everything seems peachy here So what do we do? As it turns out, there are more logs we have access to! On the Mac build server, we can access the build process' logs through the Console app (CMD+Space "console"): Aha! That's  the issue! As you can see from the screenshot