Simple.Data and Dynamic Calls Are Awesome

| Comments

Couple of weeks ago I started to look into different open source packages on the .NET platform such as Nancy and Simple.Data. They all looked very cool, but one paragraph in an article called Introducing Simple.Data - explaining how the code snippet below works - caught my attention:

getting data from db
var db = Database.Open(); // Connection specified in config.
var user = db.Users.FindByNameAndPassword(name, password);

That’s pretty neat, right? So, did we have to generate the Database class and a bunch of table classes to make this work?


In this example, the type returned by Database.Open() is dynamic. It doesn’t have a Users property, but when that property is referenced on it, it returns a new instance of a DynamicTable type, again as dynamic. That instance doesn’t actually have a method called FindByNameAndPassword, but when it’s called, it sees “FindBy” at the start of the method, so it pulls apart the rest of the method name, combines it with the arguments, and builds an ADO.NET command which safely encapsulates the name and password values inside parameters. The FindBy* methods will only return one record; there are FindAllBy* methods which return result sets. This approach is used by the Ruby/Rails ActiveRecord library; Ruby’s metaprogramming nature encourages stuff like this.

Just read that sentence once again…

That instance doesn’t actually have a method called FindByNameAndPassword, but when it’s called, it sees “FindBy” at the start of the method, so it pulls apart the rest of the method name, combines it with the arguments, and builds an ADO.NET command which safely encapsulates the name and password values inside parameters.

This sounds like crazy awesome magic and I need to understand it!

How magic works?

To find out how the magic worked, I downloaded the source code from github and started to poke around the code. The rest of the article explains what I got out of this experiment.

All Navy Outside and a Pirate Dying to Be Released Inside

| Comments

She was then hired as a senior consultant to Digital Equipment Corporation, a position she retained until her death in 1992, aged 85.

Her primary activity in this capacity was as a goodwill ambassador, lecturing widely on the early days of computers, her career, and on efforts that computer vendors could take to make life easier for their users. She visited a large fraction of Digital’s engineering facilities, where she generally received a standing ovation at the conclusion of her remarks. During many of her lectures, she illustrated a nanosecond using salvaged obsolete Bell System 25 pair telephone cable, cut it to 11.8 inch (30 cm) lengths, the distance that light travels in one nanosecond, and handed out the individual wires to her listeners. Although no longer a serving officer, she always wore her Navy full dress uniform to these lectures.

Grace Hopper invented the compiler and coined the term debugging. The two things I do in most of my professional life. She must be a truly remarkable person and I owe her my job! :)

Stop the Troll

| Comments

What does this sound like? Yes, it’s a textbook case of a protection racket. It is organized crime, plain and simple. It is an abuse of the legal system, an abuse of the patent system, and a moral affront.

In the face of organized crime, civilized people don’t pay up. When you pay up, you’re funding the criminals, which makes you complicit in their next attacks. I know, you’re just trying to write a little app for the iPhone with in-app purchases, and you didn’t ask for this fight to be yours, but if you pay the trolls, giving them money and comfort to go after the next round of indie developers, you’re not just being “pragmatic,” you have actually gone over to the dark side. Sorry. Life is a bit hard sometimes, and sometimes you have to step up and fight fights that you never signed up for.

I think the last sentence is classic and I fully agree with it. Life is a bit hard sometimes, and sometimes you have to step up and fight fights that you never signed up for.

There are some very awfull software patents granted in the past and there are some, who are clearly abusing this system. Let’s stop these trolls together!

Exploring Xamarin iOS on Windows

| Comments

Xamarin not so long ago released the version 2.0 of their product that allows all .NET developers to use C# and .NET libraries to code apps for iOS and Android. Better yet, it allows us to use our bellowed Visual Studio.NET to code for these platforms.

I love to try out new things, so I decide to figure out if it is really possible to create very basic application for iOS and for Android purely from Visual Studio.NET.

Getting Started With gridster.js

| Comments

I am looking into to learn more about web client side programming, but whenever I find an interesting project I am overwhelmed with the unknown names of different libraries and technologies mentioned, while reading the project’s page. Consider Dashing for example. They mention Sinatra, Heroku, jQuery.. These are the ones that I have at least a slight idea what they are good for. But the list continues: Sprockets, Gridster.js, Server Sent Events and batman bindings.

This is nuts, I do not understand any of these. So I decided to divide and conquer the problem and try to focus on one unknown technology at a time. The aim is not to master the library, but to construct a minimum viable sample that helps to understand what it is good for.

Let’s start with Gridster.js.

Gridster demo page

The project page describes this library as:


| Comments

Microsoft has the tendency to overdo things. It happened before with .NET around the 2000s. They started to call all of their product ending with .NET. Do you remember Windows Server.NET or Windows CE.NET? Now, they are back with overdoing other stuff such as secrecy, not listening and neglectic developers with Windows Phone and Windows 8. Hal nails it again:

Let me contrast three strategic thrusts going on at Microsoft. Windows, Windows Phone, and Azure. Windows and Windows Phone are in the “shut up and ship” camp. Azure is in the ENGAGE camp. It seems like every week Scott Guthrie is announcing new Azure technology previews or releases. Everything about Azure is exciting. Amazon, Salesforce, and a few others defined cloud computing. Azure is displacing them. It has the Big Mo. Let me make this clear, AZURE IS GOING TO WIN the cloud computing infrastructure and platform battle. Meanwhile Windows and Windows Phone continue to alienate their ecosystems. It is unclear if Windows Phone will ever amount to a significant third ecosystem. It is unclear that Windows will be able to halt an overall market share decline against IOS and Android tablets. Azure developers are excited. No, it’s beyond excitement. Windows and Windows Phone developers? Not so much. They are, at best, conflicted. Azure is doing platforms right. Windows and Windows Phone? They prefer to “shut up and ship”, even if it risks no one caring what they ship….

Git and Visual Studio Are Awesome Together

| Comments

I love Visual Studio and I love git too. What can be even better than this? Visual Studio 2012 integrated with Git. The two together are pure awesomeness and I fell in love with them.

Git Source Control Provider

There is a provider that you can install in visual studio 2012 and you will get git integration. It can talk to tfs, if you use git there. IT can create local git repos and even can clone repositories from github or from other git hosting servers.

Fixing the SelectedItems Property Binding for the Silverlight Listbox Control

| Comments

I recently had to implement a feature in our silverlight app, where the user can remove multiple items selected in a listbox. The project uses the MVVM pattern, so all logic and state is handle in the ViewModel class. When trying to implement the multiple selection, I needed to add a property to my viewmodel that would be a reflection of the items selected on the view. It turns out the ListBox control does not support binding against the SelectedItems property for some reason.

This article describe, how the problem has been solved.

Mass Customization of Apps

| Comments

But in the past couple of months we’ve noticed another category of customers, and that group is growing fast.

I call the trend the “mass customization” of apps, to borrow the manufacturing term. This group creates app templates designed for a particular industry and then customize those templates for each end customer. The customization could be as simple as different branding but more often includes adding differentiating features also.

This article is a total eye-opener for me. With this trend, non-native apps (HTML-CSS-JS have now an edge over native mobile apps. The common source code base. With this common code-base, you can provide customizable apps that can be built and packaged from a web page and deployed much faster. Obviously, you will not build cutting edge racing games or first person shooters in html, but it does not matter. You can build awesome apps to large customers on all platform using the same codebase.

This is totally awesome!

The 5th Recommendation to Get Better at Designing Windows Phone Apps

| Comments

It seems I am unable to count to 5. In my last blog 5 ways to get better at designing apps for Windows Phone I promised 5 ways and I delivered only four. This is the follow up, where I try to give one last piece of advice.

Write apps for yourself

You need to scratch your own itch. You need to solve your own existing problem, so find something you truly miss from your phone and then solve it! This way you will have an app that make your life better. Also, you will use this app every single day, so bugs and problems with your app surface much quicker and it will be easier to fix them as you are the one, who designed and coded it. But be very careful….

Do not write apps that no one will use…

I am guilty as charged. I had this idea of sending emails to myself and wrote the app. It took me three months of hard work and when I finally released it, there were only a few downloads. This is not the end of the world, because I use the app myself several times a day and learned lot of stuff, while designing and coding it! But when I started to promote my app, no-one seemed to understand what problem of theirs that my app will help to solve.

I found a solution to a problem, that seemingly no other person on earth had. Frustrating, but the key lesson I learned is this - similar to designing your app - you should start promoting your app, before you start coding it! Go out and explain the idea behind your app and the problem it tries to solve. Find out that others are having this problem too and pitch your app to them. Embrace the feedback and in the end you will have a much better app. Learn from my mistake and do not create your app in vacuum…