Starting with Xamarin or why I paid 2000 USD for a T-shirt and a monkey !

Hello again,

This is my chance to talk a little bit about a platform that I absolutely love.

I am pretty sure you can’t guess which platform I am talking about, right ? Yup, it is Xamarin.

So where did it all start? It must have been two years at least since I first heard about Xamarin. I remember looking into it, trying a few things, getting frustrated and then just put it aside for another year. Yup, been there, done that.

What helped me a lot was the fact that one of my friends was and is using this platform and he has for several years. So every year he tells about what cool things he built using Xamarin and that made me feel a bit stupid because I couldn’t even build a simple thing let alone a decent professional application. Thanks Paul, yes I am talking about you !

So in December last year I decided to stop moaning about how it doesn’t work and just make it work.

First issue was the license. I really wanted the Business one so I can code using Visual Studio which is only my favorite IDE of all times. I kept looking at the price and thinking to myself I don’t actually have a way to pay for that while I learn it. No one is going to pay me to learn a new platform. Then I kept thinking that if I don’t just do it then I won’t be able to learn and I had and still have big plans which all involve Xamarin. So I decided to take the jump, pay the business license for both iOS and Android. In the end as a professional software developer I do pay for all my other licenses and this is no different. Yes a bit pricey but the mobile world only grows and it’s well worth it in the end.

Second issue was the fact that I had no idea where to start. So I thought hmm, my time is worth quite a lot and I don’t have the time to sit down and figure things out for months and months so why don’t I learn from the people who actually built the platform. So that’s how I decided to pay for Xamarin University. Before I actually did it, I got in touch with Xamarin and they offered me a nice little discount because they provide a discount if you happen to have a start-up which I do. Now, when I say start-up don’t imagine a little Google just waiting to grow. No, I just have my own company so I can build a few products. This allowed me to get Bizspark which is very nice and also a discount from Xamarin, I think it was 20% if I remember correctly.

This still meant quite a lot of money, don’t get me wrong, but it was an easy decision to make. Heck it’s not like it’s hard to make money like a software developer, especially a mobile one, so my investment is already paying off.

Ok, so now is the time to ask why did you pay 2000 USD for a monkey and a T-shirt? Well, that’s you get once you do your first Xamarin University class, you write a little app, place an order and in a few weeks you receive them. Of course it’s not why I paid that much money, it was the other benefits that attracted me although to be sure I had no idea what I was getting into, but it made for a nice pun :).

Now that I have actually done all the classes I wanted I can say straight away that it was well worth the money. You learn everything you need to know, you learn how to build things properly, what to look for, how to optimize things and the little quirks we all know and “love” when talking about mobile development. If I had to learn all that on my own, I’d probably still be doing it 5 months later and I wouldn’t know anywhere near as much as I do now about the platform.

I haven’t done the certification yet, that’s another bonus for attending the Xamarin University, but I will do that pretty soon as well. I hear it is a brutal exam but hey, it’s well worth the effort. It does seem to require a lot more study then the recommended classes which can only be good in my book. Once you have that you can say you know the platform and can prove it as well.

So what’s next ? Yes, there must be a next. There is no point paying thousands of dollars for something if you don’t have a way of making that back and then some. Next, I have a ton of work involving not only mobile apps, but also wearable apps. Every now and then I keep an eye on the Xamarin jobs forum, every now and then you get companies looking for developers and sometimes it is remote work as well. The opportunities seem to grow every month. What can be more attractive than the concept of sharing code between platforms and using my beloved C# and Visual Studio ?

Was it worth it ? To me yes, but this is a question you need to ask yourself. Are you serious enough to bet on the platform and go all out with it ? If you are then don’t hesitate, get it all, learn it quickly and start using it. The mobile and wearables markets are only getting bigger now and the process is accelerating every month. It is, without a doubt a good time to start taking Xamarin seriously. Invest in yourself and it will pay off.

Advertisements
Posted in Personal Views | Tagged , , , | 3 Comments

Xamarin IOS – authentication using Owin, Web Api2, Json Web Tokens

This article continues the work done in a previous article : Authorization system with Owin, Web Api, Json Web Tokens.

We saw how to build an Authorization system based on Owin, Web Api and Json tokens. Next we want to see how we can put this system to good use from a Xamarin app.

I plan to write an article for each platform and this one happens to be the iOS one.

Please note, this article assumes you already have Xamarin installed, working and hooked up to your Mac Build Host. If you need help with any of these topics then please check out the official documentation which can be found here.

This article also assumes you have read the previous article so it won’t explain terms and concepts used there. I encourage you to start there first.

To recap, we already have two restful APIs : an Authorization Server ( AS ) and a Resource Server ( RS ) built in the previous article.

We will send a request to AS, passing through our ClientID and ClientSecret and if everything is correct we will get back a Json token which we can then use to send calls to RS.

We will use the Microsoft HTTP Client Libraries NuGet package for our HTTP calls. In fact, we will write a ServiceWrapper PCL library because of course, we want to reuse this code for each our platforms.

At this point in time, the current Xamarin version is 3.9.547. I always stay on the stable channel, because it should be the most tested and stable and that’s what I am after!

The code is available on Github  and you’re free to play with it as much as you’d like.

We’re going to start with an IServiceWrapper interface because we are responsible coders and we may want to change some things at some point and we know it’s never a good idea to hard code ourselves into a corner, right ? 🙂

This interface is very simple,  we will only have enough calls to show how to use the authorization system :

IServiceWrapper

As you can see we only have three calls, one to receive the JSon token, one to register a user and finally a call to validate a user. I think this is enough to show how to get going and I encourage you to write a few methods of your own just to get a good grip on how this system performs.

Next, let’s write an implementation of each method in the interface, using the NuGet package mentioned above.

Let’s start with GetAuthorizationTokenData :

GetAuthorizationTokenData

We create the FormUrlEncodedContent, this is where the grant_type goes. Then we add the Basic Authorization Header and then fire an async post call to the Authorization Server which in my case is happily running on Azure. Please remember that my APIs are not guaranteed to be up 24/7 and may actually be taken offline completely at some point. For now however you’re welcome to use them, just don’t abuse them! Using the previous article you can easily write your own APIs and deploy somewhere under your control.

Let’s take a look at the ValidateUser method :

ValidateUser

This one needs to send the username and password using a Bearer Authentication header this time. Other than that the code stays pretty much the same, there is literally nothing fancy there.

Finally the RegisterUser method :

RegisterUser

Same as before,  we simply build our post model, fire the post call and return the result.

Now that we have our service wrapper in place let’s see how we use it in the iOS app.

In order to build the UI I used the storyboards system because I kinda like it and it makes sense to me.

My Storyboard looks like this :

StoryboardUI

Just to give you a basic idea how I built this UI, I started with a new storyboard and removed the default controller it created for me. I then added a navigation controller so I get some basic navigation between my screens. I hooked up the Login screen using a Segue, this is done by holding CTRL key and dragging from the Navigation Controller to the Login screen. The rest of the navigation happens when you click on the buttons. For example to navigate from one view to another, all you have to do is push a new ViewController onto your navigation controller. The code looks like this :

var loggedInController = this.Storyboard.InstantiateViewController(“LoggedInSBController”);

if (loggedInController != null)
{
this.NavigationController.PushViewController(loggedInController, true);
}

One tip here, I had issues instantiating a new view controller based on the name, in this case LoggedInSBController. What I ended up having to do was to go into the xml of the storyboard and add a storyBoardIdentifier with the name I wanted.

StoryboardXml

This seems to be a bug in Xamarin, I am sure they’ll get to fixing it, but for now, always keep this in mind. Unfortunately this attribute will reset every time you save the storyboard so you’ll have to go back in and add it manually again.

The UI in general is very simple,  I have a few very basic screens, a login, a registration and a welcome screen.

Let’s run the application and see  what happens :

First the login screen loads :

LoginScreen

Click on the register button, this takes us to the registration screen :

RegistrationWithData

I used user demo and password demo1234, then clicked the Register button. This populated the blue text above “contacting API, please wait …”. I had a debugger set on the register controller so I could see this working :

RegisterResponse

The call worked :

RegisterSuccess

At this point I can navigate back to the login screen, use these details and try to login :

LoginTrying

The result, in debugger looks like this :

LoginResult

Finally I get to see the Welcome page :

LoggedInWelcome

As you can see this app is very simple and it could do with some design love. Let’s not forget the purpose though which was to show how we can use the Authorization API and what we did so far worked perfectly. There’s a lot more we can do in terms of interface and functionality but this will do for now.

In future articles we will look at Android, Windows Phone and finally a Xamarin Forms app.

Posted in Code | Tagged , , , , | 8 Comments

Authorization system with Owin, Web Api, Json Web Tokens

Authorization system with Owin, Web Api,

Json Web Tokens

Intent

What we want to accomplish here is to create a reusable authentication system using Json Web Tokens ( Jwt ), Owin and Web Api.

Technical diagram

Let’s start by clearly specifying the deliverables.

1. an Authorization Server ( AS ).  It will only have one job, to verify the client trying to access it and if successful, generate a Jwt which can be used for a configurable duration to access the Resource Server.

2. a Resource Server ( RS ). This is where all the work will happen. All the calls to this server need to be signed with the Jwt generated by AS. Everything else will receive a Not Authorized error

3. Everything will be backed up by a generic Membership system. The membership system used is the old one before the introduction of the Identity Model.

The reason for this choice is that it’s simple, it works, it’s light and it doesn’t have any additional dependencies, while Identity Model by default needs Entity Framework to run. While it is possible to run the Identity Model without Entity Framework that is a subject for another article. If you do however need the Identity Model feel free to replace the current Membership system with the one you actually require.

4. a way to build all these components as NuGet packages

5. a NuGet server project – this one will be responsible for building a private NuGet feed where we can deploy NuGet packages for both AS and RS. We want to be able to create a new project, add a NuGet package, change the web.config and have a running AS or RS.

6. We want to automate this process as much as possible.

7. All the code is publicly available on github

8. You can use my own NuGet feed but I cannot guarantee it will be up all the time. For now anyway, you’re welcome to use it : http://andrei-owin-nuget.azurewebsites.net/nuget

Reviewers

I asked a number of technical people I respect for feedback on this article and their contribution is acknowledged here :

    • Taiseer Joudeh ( Microsoft MVP ) – blog
    • David Paul McQuiggin ( Founder of Pro-Coded )

Credits

This article is based on the work done by Taiseer Joudeh in this great article.

I strongly encourage you to start by reading Taiseer’s article first, it will lay out the ground work for what we are about to do next.

Ok, so with that in mind let’s begin.

1. The Authorization Server

Description

We will need a database where we will store only one thing – the Audience details.

An Audience is simply a client who wants to access the AS and for that we need a few things :

        • Client Id – Guid
        • a descriptive name
        • a Client Secret 
        • an Issuer ( this can be a site url for example and will be used to sign the Jwt generated)

Let’s talk a bit about this part. The most important bit here is the Client Secret which is a Base64 encoded string.

One of the packages we use to generate the Jwt is Thinktecture.IdentityModel.Core

We’re using the classes from this package in our CustomJwtFormat class specifically when we generate the Signing Key for the Jwt.

ThinktectureSigningKey

Look at lines 44 and 45. We get a byte array from our Client Secret and use it to create the signing credentials. The HmacSigningCredentials constructor takes a byte array and that byte array needs to have a very specific size : 32, 48 or 64 otherwise it will throw an Unsupported key length error. You can see this if you look at the code which can be seen on github at this link.

So, in order to have a valid Client Secret we need to generate a Base64 encoded string which transforms into a byte array of one of the require lengths. To do this I had to dig through the Base64 documentation on wiki. This article tells us that each byte uses approximately 4/3 characters. For 32 bytes we need to generate a 43 characters of Base64 encoded string. Now, a Base64 encoded string needs to have a length which is divisible by 4 so we need to pad it with an equal sign (=) which is the Base64 accepted placeholder for no data.

In order to generate this 44 character Base64 encoded string we need to start with a 32 character input string. This is of course very handy and now you perhaps realize why I chose 32 to begin with. This is basically the length of a GUID without dashes (36 – 4 = 32).

So, after all this Base64 craziness, all we need really is for our Client Secret to be a Guid without dashes. This way you can generate as many Client Secrets as you like and they will all be accepted by the system. You can use online services to generate them or generate your own with Guid.NewGuid().ToString(“N”). This will take out the dashes so you end up with your desired 32 chars long string.

The time has come to create our AS database. It only needs one table with four fields and the script can be seen in the Scripts folder.

Once you setup the AS Database it is time to move on to the code part.

Create an empty Web Project and add the following NuGet packages

        • Microsoft.AspNet.Cors
        • Microsoft.AspNet.WebApi.Client
        • Microsoft.AspNet.WebApi.Core
        • Microsoft.AspNet.WebApi.Owin
        • Microsoft.Owin
        • Microsoft.Owin.Cors
        • Microsoft.Owin.Host.SystemWeb
        • Microsoft.Owin.Security
        • Microsoft.Owin.Security.OAuth
        • Newtonsoft.Json
        • Owin
        • System.IdentityModel.Tokens.Jwt
        • Thinktecture.IdentityModel.Core

I am going to refer you again to Taiseer’s blog post for an explanation of what each of them does or you can read the description in NuGet

One important point here, pay extra attention to Microsoft.Owin.Host.SystemWeb, this one is responsible for initializing the server so it scans for the Startup class. If you don’t have it, nothing is going to work and it can be the source of many issues to find out why things don’t work as they should. For a deployed server, make sure you have that dll in your bin folder. You don’t need any owin appSetting or any tags on the StartUp class to make it discoverable.

Once you have all the packages it’s time to write some code. We need to create a few classes : CustomJwtFormat, CustomOAuthProvider, Startup.

You can look at the code in github as well to speed things up.

When you first request a token from AS you will hit the CustomOAuthProvider, this is where we check that the Audience and Client Secret actually match an existing Audience and fire some errors if they don’t. Once everything is validated we will then hit the CustomJwtFormat class.  This is where we generate the Jwt.

We are now at the point where we can actually see the AS working.

So I would advise you to create a proper IIS website pointing to AS. You can have it locally for now, give it a nice URL, add that URL to your hosts file pointing to localhost and run it.

During this article we will use the Postman client to work with our restful APIs. Postman is a Chrome extension and is fairly nice to setup and you can even build your own collections and calls for later use.

Ok so, first things first, let’s setup AS in IIS.

AS-IIS-BasicSettings

AS-IIS-Bindings

AS-IIS-App-Pool

As-RS-Hosts

In the first image you can see the site setup in IIS, nothing fancy there, we just point to where our files are.

The second image show the site bindings.

The third image shows the app pool for this site and finally the entry used in the hosts file to make that nice URL work locally. Quick reminder, the hosts file can be found typically at this location : C:\Windows\System32\drivers\etc\hosts

Don’t forget to edit the web.config and place your own settings there. Once you’ve done this you’re ready to test and see if you can get a Jwt.

Let’s fire Postman, put your token URL in there first. In my case it will be http://authz.test.com/oauth2/token

This call needs to be a POST so change that in the dropdown.

Next we need to add an Authorization Header the way it’s described in the CustomOAuthProvider class

Take the ClientId and Client Secret, concatenate them with a ‘:’ in between them, Base64 encode them and add the result to the Basic header. To make this clearer I found a nice website where we can do all this in a visual way. Go to https://www.base64decode.org/, select Encode, select the Ascii charset, type your clientId:clientSecret and hit Encode. It will look like this:

AS-base64encoding

There is an easier option as well, in Postman select Basic Auth at the top, fill in the username field with your ClientId, the password field with the Client Secret, then click Refresh Header and this will generate the correct header for you.

Now that we have the Basic Header, let’s continue.

Select x-www-form-urlencoded and then add:

grant_type –  password

At this point we’re all setup so fire the call and you should get something like this:

AS-Postman-GetToken

We got back a Json object, notice the access_token and also notice we have a few useful properties such as expires_in. This one tells us how many seconds the token is valid for, so we could store it somewhere and reuse it until it expires. We control this value in web.config so you can play with various numbers there.

2. The Resource Server ( RS )

Description

RS will offer all the functionality we need for a membership system. It will allow us to create and update user information, roles, change passwords, reset passwords, all the functionality you need to be able to say you have a membership system.

Creating the membership database is a straight process. Asp.Net offers us the tools we need to do just that. Launch C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_regsql.exe. Obviously check your framework version, that’s just my current version at this point in time. This exe will launch a GUI which will allow you to connect to a database and it will create all the tables and stored procedures required for the membership system to work.

Next, create another empty web project, exactly as we did for AS.

We need to add a number of NuGet packages:

        • Dapper
        • Microsoft.AspNet.Cors
        • Microsoft.AspNet.WebApi
        • Microsoft.AspNet.WebApi.Client
        • Microsoft.AspNet.WebApi.Core
        • Microsoft.AspNet.WebApi.Owin
        • Microsoft.AspNet.WebApi.Tracing
        • Microsoft.AspNet.WebApi.WebHost
        • Microsoft.Owin
        • Microsoft.Owin.Cors
        • Microsoft.Owin.Host.SystemWeb
        • Microsoft.Owin.Security
        • Microsoft.Owin.Security.Jwt
        • Microsoft.Owin.Security.OAuth
        • Newtonsoft.Json
        • Owin
        • System.IdentityModel.Tokens.Jwt

The RS code is available on github as well so have a look at the classes and controller(s) there.

You’ll notice that each calls clearly identifies its own route and there’s a route prefix at the top of each controller. Each call validates its input model  and returns a HttpResponseMessage containing the proper code and an result object where appropriate. Notice the [Authorize] attribute at the top of the controller. This attribute makes sure that no one is allowed to hit any of the controller methods without a proper Jwt. If you remove it you can freely fire calls to the RS without any authentication.

The important part happens in the Startup class.

Look at the ConfigureOAuth call. It fires a call to get a list of all the audiences in our system and then it adds them all to a list of AllowedAudiences. These are the only ones allowed to access the RS.

At this point we should be able to fire calls to the RS and see what happens. Notice we only added a few endpoints in our RoleController so we will play with those a little and see how they work. I have also added a couple endpoints in a UserController, so we can create a user and then validate it. It wouldn’t be much of a membership system without this basic functionality.

In order to be able to fire calls to RS we need to add a Bearer Authorization Header with the access token generated by AS.

RS-GetAllRoles

The call succeeds, it returns an empty list since we haven’t actually created any roles yet.

Now try to remove the last character from your token thus invalidating it, or even simply remove the Authorization Header completely.

RS-GetAllRoles-Denied

Unsurprisingly, we get an authorization error. So everything we did up to this point worked.

Let’s try something a little more complicated now, let’s say we want to create a role.

RS-CreateRoleSuccess

Everything looks fine, the role was created, to prove this fire the same call again, with the same Value. We should get a duplicate role error now :

RS-CreateRoleDuplicateError

Fell free to run the GetRoles now and you should see your one role returned.

Next let’s delete this role we’ve just created :

RS-DeleteRole

Hopefully this provides enough information for you to be able to continue and write other calls yourself.

Postman tip

Notice we can create collections and add a number of calls to them so we could end up with a list we could just click and go and only having to change the bearer token.

Now, wouldn’t it be extremely nice if we could create our projects as NuGet packages and deploy them at a click of a button ?

4. NuGet packages setup

This is where the real fun begins. What do we need to do to create and deploy NuGet packages ?

There are a few steps we must go through.

First we want each project to create it’s own NuGet package and copy it to a specific folder ready for upload to the NuGet feed.

For that to happen to must first setup the NuGet feed itself. This is actually very easy, have a look at the PrivateNugetFeed project. It is a simple web project with the NuGet server  and NuGet core packages. The important bit is that it has a packages folder where we need to copy all the packages we build. Once that’s done we need to deploy it somewhere. I went with an azure feed myself so I can publish quickly.

So, let’s see how do we build the packages. You will need to get nuget.exe which you can grab from the NuGet ‘s main site.

At this point the folder structure is very important so have a look to see how the solution is laid out. There is a Tools folder where the nuget.exe is placed, this is so that if you work on a team, everyone has everything they need the moment they clone the code, rather than installing their own dependencies.

With that in mind let’s open the properties of AS. Under Build events we want to create the package only on a successful build.

We need these lines :

start /wait $(SolutionDir)Tools\Nuget\nuget.exe pack $(ProjectPath) -Symbols
copy $(TargetDir)*.nupkg $(SolutionDir)Code\PrivateNuGetFeed\Packages

Then first one will create two packages, one of the main dll and another containing the pdb so we can actually debug in a  target project.

The second line will copy the packages to the Packages folder of the NuGet web project, ready for deployment.

The start /wait means that the second command will not run until the first one finishes.

You will notice these two lines on the RS project as well.

The last thing we need to setup is the nuspec file.

To create one all we have to do is open a command line prompt, navigate to the folder of the project in which we want to create it and type nuget.exe spec. This will create a nuspec file with default values we need to edit.

Let’s look at the one we have in the AS folder:

AS-NUSpec

Everything you see between $ signs comes from Properties/AssemblyInfo.cs in the same project:

AS-AssemblyInfo

The assembly version is very important, it will become part of the NuGet package file name and will be visible on your feed as well. So let’s say you want to update such a package, you simply increase the version to say 1.0.3.0, deploy it and then when you check under Updates in NuGet you will see it appear there.

Let’s get back to the nuspec file next. We need to tell it which dependencies to load so check out the dependencies xml tag and you will see the packages we want installed when our package gets installed somewhere. This will ensure that everything will build from the get go.

Under files we add all the files we want deployed as they are in the target project. In our case we want the web.config file and all the pdbs which will come from our symbols package.

The Web.config is an important part. It will need a transformation file as well, simply create a normal text file and then rename it the way I did.

One last thing, every file under the files xml tag will be copied inside the NuGet package in the location you specify. In our case Web.config goes inside the package, inside a Content folder and everything in that folder gets added to the target project which is exactly what we want.

At this point we’re ready to create our feed, so let’s do it step by step

1. build all the projects in the solution, this will copy all the NuGet files to the Packages folder of the publishing project.

2. These nupkg files need to be included into our solution otherwise they will not get deployed when we publish the Nuget server site, so make sure you don’t forget this step.

2. In the target solution where you will install these packages, you will need to tell NuGet about your private feed, so right click on the solution name and allow it to restore all the packages on build. This creates a .NuGet folder right at the top. Open up the NuGet.targets in there and add another package source with your own private feed URL.

Ok, the moment of truth has arrived. Can we create empty projects, install the packages we just created, change the web.configs with our own values and have a running AS and RS ?

Let’s test this bold expectation!

Create an empty solution, in it we will need two web projects, one for AS and one for RS.

Create the empty AS web project first.

Right click, manage nuget packages, select your own private feed then click on the Authorization Server package:

Andrei-As-Nuget

Notice how we can see the version and the dependencies, exactly as expected. Now click Install, wait a few seconds and then your project should include all the references it needs. Don’t forget to edit web.config and do the setup work with the new api URLs and databases. You don’t need anything in this project, it won’t have any classes, will just be an empty project with the references to all your dlls which is where the magic happens. Now, isn’t this nice ?

Repeat this procedure for RS. You’ll and up with two projects with no code files!

Remember to fill in your own details in the web.config of each application then use postman again to test the AS and RS just like we did before. Everything should work exactly the same way.

You’ve just setup an entire owin authentication system in a few clicks of a mouse!

If you check Github, you’ll notice I also added an ApiUse console app. Its only purpose is to show how we can use the APIs. The code is very simple and uses WebClient, firing a call to AS first to get an authorization token and then it uses it to fire a call to RS to get a list of roles. It’s just an example of how you would use these APIs in a real project.

ApiUse

One final thought, always make sure you secure your APIs with https so that every information exchanged is protected. It will protect your authorization header and all the post data.

I am interested to hear what you think, is there anything that could be done better or maybe we need more functionality added.

Posted in Code | Tagged , , , , , | 11 Comments

IT start-ups – Open Source software or Microsoft stack?

You are a software developer who wants to create their own start-up or an entrepreneur who has an idea for an IT related product. The first question on your mind will be …

Where do I start ?

Open source is cheap so clearly that’s what I need when I can’t afford to pay anything in the beginning. Right ? You would never consider an established vendor because let’s face it, software isn’t cheap.

I have seen this type of discussion over and over and the same stereotypes repeated over and over. Open source is the king, it’s free, strong community, don’t get locked into Microsoft stuff. Microsoft big and bad, Open source good !

So, let’s see if we can bust that myth, shall we ?

What we need in the beginning is a little bit of help, obviously money is going to be tight, however you must have an idea for a product otherwise you wouldn’t consider starting your own business right?

What could your development stack be ?

Option 1

php / ruby / mysql / anything else free and Open Source.

Option 2

Microsoft stack

Ok, I admit i might be a little bit on the biased side because I think Visual Studio is the best and most productive IDE there is. Can you get it for free ? Yeah, up to a few months ago you had the Express editions which had some limitations. Recently Microsoft came up with the idea of Visual Studio Community Edition which is effectively a free professional edition for small start-ups, however this is far from the only option available.

But, and this is what I encourage you to do, there is a much better option available and that is …. ta da … drum roll …. BizSpark

Chances are most of us have heard of it but how many really use it or even tried to get it?

So let’s see what BizSpark gives us.

Free Software and Azure credits

5 free MSDN licenses which include a lot of software – Visual Studio Ultimate, Office, Visio, several Windows OS versions ( including Vista, 7, 8, 8.1, 8.1 pro ) and much more. In addition to this, each MSDN account comes with $150 or £95 worth of Azure credits per month. All this for three full years.

Let’s try and put a value on this offering:

the Azure credits alone are worth $750 x 36 = $ 27.000.

Visual Studio Ultimate with MSDN – that’s about £13.482 and 5 of these are almost £70.000 or $107.000

Up to this point we have almost $135.000. Add the rest of the software and you’ll probably end up over $150.000. You will also get any new versions that Microsoft releases during those three years.

Ok, you showed me the numbers but who can actually get all that?

Well, the rules are pretty simple, you need to be a start-up no older than 5 years, build a product and have your own website. That’s pretty much it !

Any business which satisfies these three rules can get BizSpark. You have three years to make your idea a success and if you can’t then no harm done, at least you tried it and didn’t have to sell your house you cover the cost of the software. Once the three years are up you can decide what to do after that.

How long does it take to get it ?

Microsoft says about 5 working days, it took a bit more for me, but I was doing it around Christmas time so maybe not many of them were around. All in all, it took me about 3 weeks to get approved and all I had to do was to register for BizSpark and provide the little information they required.

Conclusion

For an IT start-up, BizSpark is tremendous value and I encourage you to check it out : http://www.microsoft.com/bizspark/

All this information is freely available and this is why I am surprised to hear the stereotypes that creating a start-up is hard and expensive and your only chance is Open Source software and don’t even dare to go near the Microsoft stack.

Hopefully this and a little bit of your own research will prove that actually this couldn’t be further from the truth and the best offer in town right now comes from Microsoft in the form of the BizSpark program.

Disclaimer : I do not work for Microsoft and they did not encourage me to write this article.

I do have BizSpark for my own start-up and if you need some help or ideas how to start make your idea a reality then I am more than happy to assist you.

Also, if you are aware of anything else that could be of benefit to an IT based start-up, please mention it in the comments so others can see and benefit from it too.

Time to build some great products using great software tools!

This article was published on LinkedIn as well : https://www.linkedin.com/pulse/start-ups-open-source-software-microsoft-stack-andrei-dragotoniu

Posted in Personal Views | Tagged , | Leave a comment

Starting with Angular part 3 – services

We have covered basic topics in the first two tutorials. Now it is time to see something a little more advanced. In this tutorial we will see how to add services to our application, after all there is no application without some sort of data coming from somewhere.

Wouldn’t it be nice if we could figure out not only how to retrieve data, but also how to separate this functionality into something a little more advanced like a factory ?

Let’s see how we can do this. So, we will build a simple application which reads some data from an external URL and when that data is loaded it does a little processing.

Let’s start with a simple Html page :


<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.9/angular.min.js"></script>
<script src="app.js"></script>
<script src="dataFactory.js"></script>
</head>
<body ng-app="tutorial3App">
<div id="content" ng-controller="tutorial3Controller">
<div ng-repeat="item in tutorialData">
{{item}}
</div>
</div>
</body>
</html>

What’s going on here ? We can see the usual ng-app and ng-controller and a little loop to repeat some data. We should be familiar with this from the first two parts of this series. If you need a little reminder ( no shame in that ! ),  at the bottom of this page I have included links to the previous articles.

So nothing fancy here, but notice we have two JavaScript references this time.

Let’s look at the app.js file :


(function () {
angular.module('tutorial3App', []);

angular.module(‘tutorial3App’).controller(‘tutorial3Controller’, [‘$scope’, ‘$http’, ‘dataFactory’, function ($scope, $http, dataFactory) {
$scope.tutorialData = [];

$scope.processTutorialData = function()
{
$scope.tutorialData.push(‘local data’);
}

$scope.init = function () {
dataFactory.getMeTestData().then(function (data) {
$scope.tutorialData = data;
$scope.processTutorialData();
})
}

$scope.init();
}]);
})();

Ok, there are some differences this time so let’s have a look see if we can figure out what’s going on here.

First of all, we can see we’re injecting an $http object into our controller. What is $http ? Well, it is a core Angular service and the documentation tells us that it facilitates communication with the remote HTTP servers via the browser’s XMLHttpRequest object or via JSONP.

You can read more about it here : Angular $http service documentation

We will need this service to fire a call for our data. Next, we can see we inject a new thing called dataFactory. Ok this is definitely new and it must be coming from somewhere right? Yes, you are 100% right, but for now let’s keep looking at the rest of the app.js file.

We can see some boring properties and methods, however there is one interesting thing,  an init method which we call at the bottom of the code.

This method references the dataFactory again and then it does some fancy stuff. At this point we’re ready to look at the second JavaScript reference and see what’s in it :


angular.module('tutorial3App').factory('dataFactory', function ($http, $q) {
var service = {};

service.data = [];

service.getMeTestData = function () {
return $http.get(‘someUrl’).then(function (response) {
service.data = response;
return service.data;
})
}

return service;
});

We are now looking at a little more advanced Angular, but it shouldn’t be too scary. So, first of all we inject dataFactory into our application module using the factory function. Inside this factory we create a service JSON object and then we assign a property and a method to it. The getMeTestData method fires a $http.get request. if you read the documentation it will tell you that $http.get returns a promise. 

Hang on a sec that sounds fancy, what exactly is a promise ? Think of an async request, you fire a request and at some point it will complete and return the data. A promise is just that, a promise that at some point we will get some data. When the data is available whatever is inside the when function will execute.

In our case, we will take the data which comes back, assign it to our internal property service.data and then we will return it. This is all that happens inside this fancy dataFactory. I bet you now think that actually, it doesn’t feel fancy at all and you would be right.

One last thing we didn’t explain is $q, what exactly is that ? Again we will search the angular documentation and find out that it is a service that helps you run functions asynchronously, and use their return values (or exceptions) when they are done processing. More details here

So at this point, hopefully everything is clear and we can look at the app.js file again, specifically at the $scope.init method. We can now see that it calls our data factory using the name we injected earlier, it calls the getMeTestData which of course return a promise so we wait until it completes by calling the when function and in there we assign this data to a local property and then we do some processing to it. In our case it simply returns an array of items and we inject one more once we receive it. The important thing here is that we need the data call to complete and then we do something with it, which is a common scenario in any application.

This should give you an understanding in how we build a real application with Angular and how simple things really are.
I have provided a little service consumed by this tutorial just to show a real call in action.

This is what you see when you run the application :

angulartutorial3result

The first 2 items are coming from our service call, the third was added locally after the data was received.

Please note that the service which delivers the data for this tutorial is  NOT guaranteed to be always up. If you happen to get an error when running the application, feel free to replace it with a call to a service under your control. all you have to do is return an array of items like this :

["item 1 from service","item 2 from service"]

I hope you enjoyed this mini series this far. In the next chapter we will look into how to build a more serious application.

If you’d like to download the code for this tutorial, you can do it here : Angular Tutorial Part 3 – services

As usual, the code is released under the MIT License

Have fun and see you later !

Starting with Angular

Starting with Angular Part 2 – loops

Posted in Code | Tagged , , | Leave a comment

Starting with Angular Part 2 – loops

In this tutorial we will continue the basic tutorial and show how we can work with some simple structures, such as loops.

In case you missed it, you’re welcome to visit the first tutorial in the series : Starting with Angular

This shows what resources you need to get started with Angular, where to get the scripts from and how to build a very simple Angular app. In this tutorial I will assume that you know these things so won’t spend time on discussing the same thing again.

Let’s see how we can repeat some content without having to write too much code, hardly anything in fact.

We will basically have an array of content and we will display each item inside a div.

Let’s start with a very simple html page :


<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.9/angular.min.js"></script>
<script src="AngularBasicTutorial-loops.js"></script>

</head>
<body ng-app=”simple”>
<div id=”content” ng-controller=”simpleController”>
<div ng-repeat=”contentText in content”>
{{contentText}}
</div>
</div>
</body>
</html>

Now the JavaScript :


(function () {
var app = angular.module('simple', []);

app.controller(‘simpleController’, [‘$scope’, function ($scope) {
$scope.content = [“content 1”, “content 2”, “content 3”];
}]);
})();

As you can see it’s all very simple, not a lot happening. Let’s see how this works :

All we did was to create a div and apply an ng-repeat on it. Inside ng-repeat we can have an expression. Please note that we cannot write any JavaScript in there, but instead we can have some constructs which refer to Angular parameters or functions.

content is a  simple array and we will find it defined in the JavaScript file under $scope.content. Please note that how we get that data is irrelevant at this point. In another tutorial we will be looking at how we can get some real data from somewhere but for now we want to keep things simple so we understand how they work and fit together.

So, all we did was to select all the content items in the array with our expression.

ng-repeat will take the element it’s applied on and repeat it for all the items it finds in our expression. So we can expect to see three divs each displaying {{contentText}}.

Notice the double swirly brackets around contentText. This tells Angular that this is an expression and the content of this expression comes from an Angular parameter which is called contentText. We don’t have anything like this in our JavaScript, but we did define this item in our expression applied inside the ng-repeat tag. So {{contentText}} will be replaced with each value found in $scope.content. After all this, we can expect to see three divs, each one containing one of the array items defined in JavaScript.

Double click the index.html file and let’s see what happens :

On a blank page we will see this :

AngularTutorialPart2-Loops

If you’d like to see the rendered html, please right-click on an item and select “Inspect element” assuming you use Chrome or whatever other option you have in a different browser.

Now, let’s spice this up a little bit and let’s use some JSON data, now gets us closer to a real scenario.

In our html page add this new content under  our original div :


<hr />

<div ng-repeat=”contentText in properData”>
{{contentText.id}} – {{contentText.name}}
</div>

in the JavaScript file add this new parameter under $scope.content :


$scope.properData = [{ id: 1, name: "Peter" }, { id: 2, name: "John" }, { id: 3, name: "Alfred" }]

Now we have an array of JSON objects with two properties : id and name.

We need to change the ng-repeat a little bit to make it work with JSON. Fortunately this is very easy, so accessing properties from a JSON object can be done directly without any fuss.

The result now looks like this :

AngularTutorialPart2-Loops-second

This concludes part 2 of the tutorial. hopefully you’re now starting to see the power of the framework even if we haven’t actually done a lot.

If you’d like to download the code for this tutorial, you can do it here : Angular Tutorial Part 2 – loops

As usual, the code is released under the MIT License

Have fun and see you later !

Starting with Angular

Posted in Code | Tagged , , | Leave a comment

Starting with Angular

So, you’ve looked around, looking for a new role and most of them seem to mention Angular.

Wherever you turn, whatever ad you read, it mentions Angular, it’s right there in your face.

AngularJS-large

You’ve never touched it so you decide its time to do that to keep your skills up to date. But where do you start ?

Let’s see if it’s really as bad as it seems.

First of all what is Angular ? A good starting point is to check out the angular website: https://angularjs.org/

If you are just starting out we can think of it simply as a binding framework. It will help you bind your JavaScript to your front end. Of course this is a very limited definition, but for now it will suffice. All we want really is to see how we can build something very simple with it so we get the idea of how it works.

We clearly need our nerdy  Hello World application. Wait, no, let’s make it do something more interesting.  I mean we don’t need Angular to display a little text, what we want is to see how we can write some JavaScript code and make it do something.

We will be building an application which adds 2 numbers and shows the result in a label. Pretty simple but let’s see how we can do that with Angular.

Step 1.

We go to Angular’s site and get a link to the js file. That’s all we need really.

Click on the download button and choose version 1.3. That will give us the CDN link that we need.

AngularDownload

Step 2.

Create a simple HTML page with this code  :


<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.28/angular.min.js"></script>
<script src="AngularBasicTutorial.js"></script>

</head>
<body ng-app=”simple” ng-controller=”simpleController”>
<input type=”text” ng-model=”val1″ />
<input type=”text” ng-model=”val2″ />
<button ng-click=”calcSum()”>Sum</button>
<input type=”text” ng-model=”sum”/>
<div>
<button ng-click=”testFrontEndBinding()”>Front End – BackEnd Binding test</button>
<button ng-click=”testBackEndBinding()”>BackEnd – Front End Binding test</button>
</div>
</body>
</html>

Now, let’s see what’s going on here.

You can see we added a few extra things on the body tag. For Angular to run and interpret code we need to create an Angular app and a controller. An app is the main container and a controller is a specific section of the code.

Everything inside will be interpreted by Angular. All we had to do was add an ng-app tag and give it a name and then an ng-controller and give it a name.

We can see we also added a reference to an AngularBasicTutorial.js file. Let’s see what this file looks like :

(function () {
var app = angular.module('simple', []);

app.controller(‘simpleController’, [‘$scope’, function ($scope) {
$scope.val1 = 1;
$scope.val2 = 2;
$scope.sum = 3;

$scope.calcSum = function ()
{
$scope.sum = parseInt($scope.val1,10) + parseInt($scope.val2,10);
}

$scope.testFrontEndBinding = function()
{
alert($scope.val1);
}

$scope.testBackEndBinding = function()
{
$scope.val2 = 1000;
}

}]);
})();

This is using the module pattern and we basically create a function expression ( for some details please visit this link : JavaScript Module Pattern)

You can see how we hooked up the app name and the controller name between JavaScript and Html.

Angular is very good on the two-way binding side.  This means that once we’ve done the connection between code and front end, any changes we do in the code reflect on the UI straight away. When we change something on the front end the value of the linked JavaScript model also changes. As you can see this is all very simple and it didn’t take much code to write.

So what we expect is that we run our web page we will see the textboxes already pre-populated with the default values we assigned in JavaScript. The 2 way binding works because we marked input fields with the ng-model directive. if you’re interested to read a bit more about it please go here : ng-model explained

To demonstrate the 2 way binding I added a couple buttons, one which shows the frontend – backend connection and a second one which shows the backend – frontend connection.

Let’s take the first one and let’s look at the JavaScript as well.  Here we will type a new number in the first textbox and then we will alert the value in $scope.val1. Go ahead and type let’s say 7 in the first textbox, then click the FrontEnd – BackEnd Binding test. You should get an alert with the number 7.

Now, press the second button and you should see 1000 in the second textbox. Feel free to experiment and change to other value in the JavaScript method and you should see your change straight away.

Hopefully at this point you understand a little bit about Angular and a little bit about how the 2 way binding works.
Now, don’t get too hung up on a framework. This is about Angular but if you look at other frameworks you will notice they work pretty much the same way. Yes there be naming differences but the idea remains the same. Learning one MVVM framework will make it easy to pick up others.

If you’d like to download the code for this tutorial, you can do it here : Angular Tutorial code

In the coming weeks I will publish more an this subject so stay tuned.

The code is released under the MIT License

Have fun and see you later !

Posted in Code | Tagged , , | Leave a comment

On networking

So, networking ….

Everyone is talking about it, most people agree they need to do it, not many seem to be able to do it properly.

So, let me tell you how to do it properly then …. I am kidding of course, I am mostly clueless when it comes to networking. This being said, there are a few trends I noticed in the past few months.

Let’s take LinkedIn for example. This is because I don’t really use anything else, so there you go.

I’ve always believed that it’s better to build a network with people you actually know and have met face to face.  Made sense, why would you want to add strangers, right ? They don’t know you, so how can they possibly be of any use ?

With this approach in mind, my connections number stayed around 100 for a few years. I wasn’t really getting much value out of this approach as my connections were not that active anyway. The number of professionals in my network ( the connections of my connections ) wasn’t very high either.

Then, a few months ago I thought I would change this approach, because I wanted to get some value this time.

Value means seeing what other people talk about, learning about topics you never even knew existed, more jobs opportunities, maybe even some extra work on the side.

I started to accept invitations from anyone who bothered to send me one, even if they used the default message. Why would I do that ? I realised that I wasn’t using the power of a professional social network at all. In fact it wasn’t about who sent invitations, it was about their network. Even if their connections were private it didn’t matter.

What matters is that every time you write a message, it gets seen by your direct connections but also by their connections too. The number of people you would reach grows exponentially with every connection you add. Every update you make gets seen by all these people and there is a chance someone might be interested and get in touch. If you write an article, your audience is suddenly much bigger. It’s all about big data, isn’t it ?

The result of this approach is that I have been contacted more in the past few months then in the 5 years put together, so the results are clearly better. You get your name out there, more people hear about you, chances are you will make some quality connections who you can help or they can help you in your professional life.

In the end it’s a question of what do you want to get out of LinkedIn. If all you want is to keep in touch with a few people you know, that’s fine. But if you want to get your name out there, then become part of the network and connect. This is all that matters.

Posted in Personal Views | Tagged , | Leave a comment

So you can’t find good developers …

Intent

What I want to do here is to offer the perspective of a developer after quite a few years in the field. I’ve been searching for a good company to work for all the time. I have done numerous interviews and applied to lots of jobs. Now it’s feedback time. A developer’s feedback that is. I will use some personal examples to illustrate my stories, hopefully they will help someone.

Problem

I see this coming up more and more often. Businesses complain they can’t get good developers and when they do find some, they don’t stick around for too long.

Recruiters complain they don’t find enough candidates and it’s very difficult to fill roles.

Is it a developers shortage ? Or is it something else ?

Business reputation

These days how a company behaves is very important. If you are a company looking to hire, you need to realize that developers talk. The good ones will research you and see what people say about you. They will talk to people who worked for you in the past or work for you now. They will look at your website, check out your clients, check what you build and how.

Once you have a bad name in the community, you’ll find it very difficult to hire anyone, except people who don’t bother to do their homework.

How to get a developer

We all know the tried ways of finding developers, right ? Ads on job boards, recruiters, newspaper ads.

This is pretty much the past. These ways don’t work as they once did, if they did you would have no issue finding developers.

My firm belief is that networking will help here.

1. Jump on LinkedIn or any other place you know of that is likely to house developers.

2. Start searching, once you find some names, aim to build a relationship with these guys ( or gals ! ).

3. Send them a message, tell them what you need, tell them what you can offer them and see if they are open to discussion. If they’re not, maybe you can keep in touch so that when they are looking they will come to you first. Be careful how you nurture this relationship, you want them to remember you in a positive manner, not to avoid you like the plague. Maybe you can have a coffee every now and then, you get the idea.

The point is that good developers have jobs, a lot of them have good jobs and they’re not going to be available when you contact them.

A lot of them are comfortable where they are, it may not be perfect but they’re used to it. In order to attract them, you need to stand out from the crowd. Do what other companies don’t. Think about it. There are companies recognised as very good places for developers. Everyone knows about them, most want to work for them. Not everyone can be Google, but there are certain things a business can do to attract good developers, and KEEP them.

This brings us to the next point.

Ok you got me, but how do you make sure you keep me ?

It would be great if you would understand that your job hasn’t finished when you hired someone. No, the hard work barely begins. You also need to be sure they stay put. What can you do, as a business to make sure you keep your people especially those that know what they’re doing ?

This is quite a big subject but let’s give it a go. A lot of companies ask what a developer is making, add an extra 1 or 2k ( add your local currency here whatever it may be ) to it  and that’s it. They think their job is done. If you do this you will not attract the right crowd. The good guys, in UK at least are on £40-45k or more. An extra 2k means nothing. What this means is that you cannot offer market rates alone. These guys will be on market rates already. So by putting a top limit on what you can offer and advertising that, you’ve just ruined most your chances of finding someone. Developers will look at what you offer, think, I am on that or more than already so let’s move on. Now if you build relationships and get people in without going through recruiters, this means that you won’t have to pay the huge recruitment fees so you can offer more to someone you want. See how that works out in your favour ?

Once you managed to hire someone, now it’s time to plan how you will keep them. The painful point for a business is this, you need to understand that developers are a hot commodity. This means you cannot put them in the same category with everybody else. I remember a few years ago I was working for a specific company. They wanted me to build them a new website / platform. I did that in a few months, then review time came. During the review I was told how happy they were they hired me, that I was the best choice and they really wanted me to stay. But they told me they could not offer me a pay rise because I hadn’t been with them long enough. One month later I had another job offer for about 30% more and I was gone.They hired another guy, offered him almost the same the new company offered me, so quite a bit more, then they paid the recruitment fees as well and guess what? One year after that, the new guy left as well.

Morale of the story, if they offered me a nice pay rise for what I did, I would have stayed put and they wouldn’t have had to go through the process of waiting for the new person to learn what I did. This is a point that many businesses refuse to consider. It is very expensive to replace someone. First they lose the knowledge of what they already built. Then they lose the business knowledge accumulated on the job. Then they have to hire someone else, then pay the recruitment fees, then wait for the new person to learn enough to be able to do the job properly. This process is extremely expensive so would it not make sense to do your best to keep your people ? Let’s look at this in-depth next.

Ok so I want to keep you, what can I do ?

The first piece of advice I can give is to be proactive. Good developers are always courted and will always be offered opportunities. So, you need to stay ahead of the pack on this one.

In order to do that, analyse what the person is doing and the results of their work. if they help your company grow and make money then you want them to stay. So every year offer them a nice pay rise. Oh my god I cannot afford that, is that what you are saying ? Well then how can you afford to hire someone else AND pay the recruitment fees too ? Think how much it would cost to hire a new guy,  take half of that and offer it as a pay rise, it makes much more sense than losing someone you really want to keep.

What you try to achieve here, is to make your company stand out. You want your guys to go out there in the wild and tell others how great their employer is. You want their friends to come work for you, direct and then you save money. if someone brings you another developer, then reward them for that. That person has just saved you quite a lot of money so the least you can do is show some appreciation.

Developers are funny beasts. Most don’t like suits, heck I don’t even own one. Most like to feel comfortable so if they want to come to work in T-shirts, why not ? yes you are a business and your image matters, but these are not the guys that go out there promoting you most of the time. They are the engine that makes your company run and if they are a a little … oily …. so what ? Leave them be. Some like to listen to music while they work. That’s fine too. It helps with concentration, it mutes all background noise, phones, chit chat and makes us more productive. I suggest you do a bit of research into the true cost of interruptions for developers. I suggest you start by reading this excellent article on the subject.

Next, make sure your developers have the best tools money can buy, an MSDN subscription, decent hardware to run on, lots of memory, multiple screens. Yes having multiple screens is not a luxury, but something really needed.

Try to understand what it means to be a developer. Our field changes on a weekly basis. New frameworks and technologies appear all the time. Products get new versions every few months. We have to learn all the time, just to keep up and even if we do learn all the time, we can’t know everything. So show a bit of respect and understanding and help us get better. If we get better, your business benefits, if we know more, we can choose better solutions for your problems. So let your developers research, maybe even send them to some technical conferences every now and then. It will work out in your benefit anyway.

A very important point, this is something I have been subjected to myself not long ago. The owner of a company had a very annoying habit of asking why do things take time. His firm belief was that everything is easy. The guy did not believe in testing anything, did not believe in planning anything, loved to change his mind every few days and add new “features” all the time, while expecting the time to develop to remain the same. In addition to this he thought everything was simple because 15 years ago he managed to drag a button on a form and something happened when he clicked it. After that he thought he was a developer and knew what he was talking about. You think I finished ? No, the guy was a control freak as well and loved to micro-manage.

Let me tell you, there is nothing more annoying than such a manager/ boss. No offence intended here, but we do not tell you how to run your business and how to manage your people, so don’t tell us how to do our job and most importantly do not diminish what we do because you think it’s so easy.

No, what you want is to trust the people you hired to do  the job, manage themselves as they see fit and you stay out of the way. No one says you should not have any input, but its a far cry from trying to micromanage everything. Make everything a dialogue, let us manage the technical bits and make it easy for us to do our job. That’s what we want not to be micro managed.

Finally take a personal interest in your developers. Find out what makes them tick, what do they want from their career and if there is something you can help with, then do it. Find out what will it take for them to stick around a while longer. maybe you can offer flexible hours. maybe you can let them go home earlier on a Friday. Maybe they can work from home every now and then. Maybe, if they help you be successful, maybe you can give some of that back to them. People are not going to feel invested in your company, if you do not offer them something in order to feel that way. If someone does overtime, then appreciate it and either pay them extra or offer time off in lieu. Understand they’ve gone the extra mile, now it’s your turn. Make it a two way street basically, don’t just expect people to do things for your business.

Think what is the rule number one in business ? That’s to offer something no one else does. Why don’t you apply the same when it comes to your developers ? Offer something other companies don’t. Then people will have a reason to come to you  I am sure there are things you can think of which won’t cost you much but may make a world of difference to someone.

What exactly are you after ?

Most companies have a list of things they are after. If the developer they talk to doesn’t know some of them, it’s all over, right ? Wrong. There are a lot of technologies out there and we cannot know everything. What we know depends on the needs of our current employer and our personal interests, because some of us study things in our own time.

Think what are you after ? You should hire for attitude and aptitude. That means hire people who are happy to learn and keep learning. If they have a track record of delivering things, that’s what you want. Any specific skill can be learnt on the job. I will give here another example. Last year I had an interview with this company. Among their long list of skills, they had technology X. I had no experience in that, I even mentioned it from the first contact but also mentioned that I am happy to learn it and it won’t take me long. Then we had the first interview. The guys prepared a list of questions, all of them on that one technology. I told them, look I already told you, I don’t know that, but I am happy to learn. Even so, the guys kept asking their questions, on the same topic for half an hour until I got frustrated. The result ? They are still looking, because they couldn’t comprehend that we are more than the sum of what we know at any point in time. Don’t be like that. Hire for attitude first, knowledge will come anyway, especially for someone with a track record of learning new things on the job.

The end

We’re finally there. I hope this can at least shed some light and maybe it will help bridge the gap between companies and developers. We need each other so if we understand each other a bit better maybe things will get better. Please let me know your feedback, I am very interested to know how others feel about this “hot” topic.

Posted in Personal Views | Tagged | 1 Comment

Separation of concerns – Application Layers

This isn’t meant to be a guide. It is meant to show how I like to structure my applications and get some feedback, maybe there is a better or cleaner approach or maybe I don’t go far enough.

The project is zipped up and you’re welcome to download it and look at it for reference.

So, without any more delay, let’s jump right into it. A little context before the code though.

Lately, I have been doing a lot of mobile work and almost every time, I need to add a mobile interface, in addition to a standard web interface. The way I structure this project reflects that requirement.

So I start by creating an MVC project. This is the UI for this example.

Then a DTO – DTO stands for Data Transfer Object and I am using it to get data from the database and serve it somewhere, more than likely over a webservice, which is why it needs to be small and serializable. Anything that comes from a datasource goes out as a DTO, I never ever return a class created by an ORM. This is in case I want to change the ORM and use ADO. NET or I just need to change things. If I return DTOs then I am not coding myself into a corner, should I ever want to change things.

Then we have the Business Layer, this is where all the business rules are applied. To make things simple, I pass a DTO in the constructor and run the rules in the same place.

Finally in the UI project is where things are glued together. The UI project is the only one that references all the other projects. It will get the data, populate the business objects and finally get that data into a model, ready to be passed to the view. I kept it simple as well, just to show how things work.

The interesting bit happens in Home controller, Index action. Yes this means the controllers are a bit fat and this is perhaps where I could look further.

I would like some feedback though and see what other technical people think.

You can download the code for this post here

Posted in Code | Tagged , , , , | 3 Comments