Apr
26

Silverlight and Google Adwords

Wanting to get the new ClientTax Cloud App out as a Minimun Viable Product I thought I would start a Google Adwords campaign. For this I needed a landing site which would explain the product and also serve as a link to the application in the Cloud. Why not write it in Silverlight too, especially as my ASP.NET/HTML skills were a bit rusty? (why do those divs never go where you want them?)

I wrote email alerts to monitor user behaviour. Hmm.. it seemed that there were some wasted clicks from people not having the Silverlight plugin and not wanting to install it there and then, but the majority seemed to get through okay.

It was a bit of a shock a few says later when all my Google Ads where marked “Site Suspended”. I also received an email which told me I was guilty of violating Google’s “bridge policy”.  I was sending users off to a linked site with minimal content on my own site.

Huh? That didn’t sound right. Sure there was a link to the application but there was a fair amount of content on the landing site www.clienttax.co.uk itself. I phoned Google’s call centre. Perhaps I need to add more content to my site.

I added another quite lengthy page. No harm in that.

Then I was told that users were being re-directed to

http://go.microsoft.com/fwlink/?LinkId=161376

This is a link to Microsoft’s prompt to install the plugin. Doh! I couldn’t believe Google could be so stupid. I wrote back explaining that this was just a prompt, and that if they were checking my site they would need to install Silverlight.

They replied that, sorry, well yes they had done that and sure, there was sufficient content. Sorry for the inconvenience. It would only take a day for the site to be re-examined. Then, later, sorry but it’s likely to take more than a day.

I thought I might as well use the time building an alternative ASP.NET site. This wasn’t as taxing as I first thought.

Now I wanted the users to have the following experience : If they had the plugin installed they would go straight to the Silverlight version, if they didn’t they would go to the alternative site without the option of installing Silverlight.

The standard html they gets generated on the Silverlight website default aspx page goes like this:

 <div id="silverlightControlHost">
        <object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%">
		  <param name="source" value="ClientBin/Silverlight5TestApp.xap"/>
		  <param name="onError" value="onSilverlightError" />
		  <param name="background" value="white" />
		  <param name="minRuntimeVersion" value="5.0.61118.0" />
		  <param name="autoUpgrade" value="true" />
		  <a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=5.0.61118.0" style="text-decoration:none">
 			  <img src="http://go.microsoft.com/fwlink/?LinkId=161376" alt="Get Microsoft Silverlight" style="border-style:none"/>
		  </a>
	    </object><iframe id="_sl_historyFrame" style="visibility:hidden;height:0px;width:0px;border:0px"></iframe></div>

The way this works is that the user only sees the <a href bit if Silverlight is not installed. I tried replacing the the <a href bit with a redirect to another page, but found that if I did this the user was redirected whether or not Silverlight was installed.

One can disable the plugin on IE by clicking on the options gear wheel and selecting “Manage Add-Ons”. In Chrome you enter about://plugins in the search bar.

One of the suggestions Microsoft makes is that you provide a background image of the Silverlight site so that users know what they are getting once Silverlight installed. I also added an additional button so that users could choose the non-Silverlight version.

This is how it looks:

Silverlight not installed

Silverlight not installed

Here is the html:

 

     <div class="container" style="position: relative">
<img style="z-index: 32; left: 8px; position: relative;opacity: 0.4;filter: alpha(opacity=40); top: 0px;"�
            alt="bottom image" src="Images/slexperience.png">
<div style="z-index: 100; left: 63px; position: absolute; top: 38px; width: 417px">
    <a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=5.0.61118.0" style="border-color: transparent">
        <img  �
            src="http://go.microsoft.com/fwlink/?LinkId=161376"�
            alt="Get Microsoft Silverlight" style="border-style:none"/>

    </a>

    <INPUT TYPE="BUTTON"�
        VALUE="Click here for the non-Silverlight version" style="background-color: #304854;�
        width: 355px; height: 81px; font-size: small; color: #FFFFFF; margin-left: 40px;"
                ONCLICK="window.location.href='home.aspx'">

</div>

 

 

 

 

Apr
10

Git for non-gits

As a solo developer I have been looking for a free yet intuitive version control system. I confess to have been brought up on Visual Source Safe and PVCS. In that world you check files in, you check them out and they get locked so no one else has access to them.  Many the time I had to tear my hair out waiting for the slowest developer in a team to check in a file so that I could complete my little procedure name change.

Having a look at other systems I discovered that didn’t quite work like that. Subversion uses similar terminology but it means something totally different. I know because I lost a whole bunch of code that way!

So on to Git. My wiz-kid Ruby Rails developer son Pascal speaks highly of it. Plus there’s GitHub which you can use as an internet base repository, all for a few quid a month. Or for free if you don’t mind your code been nicked by others. There’s also Git Extensions which is a GUI for windows and a Git Source Provider for Visual Studio.

Any resemblance to VSS is purely an illusion. One starts off with a local repository. This is what VSS calls a working folder to which you check out files from the central repository. With Git it’s the other way round. The folder in which you work is king.

Hmm .. nice .. but how to I get it backed up to Github? Obviously “backed up” is not in the Git vocab but that sort of what I wanted to do.

Github and lots of help pages that tell you how to do this and that. Well no mainly they are telling you how to make a copy of an existing repository and put it on your computer for you to work on. Not what I want to do.

Anyway, I set up my GitHub account and created a “repo” (I’m getting into the lingo now). Help says I must  do something like:

git remote add origin git@github.com:MyUserName/MyLovelyCode.git

that is accepted, but then when I tried

git push -u origin master

it wasn’t at all happy.

Git has these weird names and verbs like “push”,”pull”,”bash”,”stash”. Was Git invented by hill-billies I wonder? “Git Bash” is where you enter the Unix like commands so beloved of version control systems. You can also use the GUI, which helps in some cases but confuses in others.

Aah – it seems I have to create the “repo” on github first and then do the push thing. AND it’s case sensitive. I can’t call my local folder mylovelycode.

Also I needed to get the mysterious “ssh” thing set up so that my PC can talk to GitHub. For me “ssh” was what was hissed to me when talking after lights out in my school dorm, but this was obviously different.

Anyway, I eventually have my code copied to GitHub.  Now I wanted to get the code out to my laptop. This involved the “clone” command and various other bits which I have now forgotten and will have to look up in six months time when I want to do it again. Seems I have to have a different email address on my other pc. Or is it a username? Or is my username the name of my github account? No one wants to tell me.

I suspect everyone who’s on the bleeding edge of IT already know all this. I’m obviously far behind. But then everyone I’ve actually worked with seems to be even more far behind. I’m sort of in a dark no-man’s land between the bleeding edgists and the stuck in the mud traditionalists (also known as Delphi developers) “we’ve done it that way for 20 years … if it’s not broke then don’t fix it!”.

Anyway I have now got my little system going. This is mainly the result of trial and error plus some intuition.  I code on one machine, commit and “push” it to Github. When I want to use my other machine I “pull” it from Github. If I like I can even make changes on both machines.  When I “pull” now I have to merge. Darth Vader bellows from the dark past.

MERGES ARE TO BE AVOIDED!!!!

In the new and liberated world of Git is seems it happens all the time and everyone is quite happy with it.

Feb
23

Silverlight recommended for Line of Business (LOB) applications

Telerek has a useful overview of appropriate technologies for various application types,  and it sees Silverlight as ideal for Line of Business Applications. This might seem surprising given all the recent hype about HTML5, but Silverlight is a more mature platform with rich tooling, wide support and can be accessed out-of-browser in both Windows and Mac operating systems. This enables a rich desktop experience with the simplicity of a web deployment. Microsoft has also pledged support up to 2021.

 

Feb
19

Open-Closed Design Principle – is it still Relevant?

The Open-Closed Principle (OCP)  is and Object Orientated design principle put forward by Bertrand Meyer in 1988. It states that “software entities (classes, modules, functions, etc.) should be open for extension, but closed for modification“.

At a recent meetup of the London Software Craftmanship Community there was some discussion about the relevance of the principle today when compilers are super-fast and there is little overhead in revisiting existing code in the light of new requirements.

This got me thinking. That explanation didn’t sound right to me. What is behind this principle? Why shouldn’t we modify existing code?

One reason might be that it’s a lot easier to write completely new code rather than try and rearrange and add to existing code. I’ve seen this for real (haven’t we all) when the latter has been done for years and the result is a mess. Also it means retesting all the existing functionality – not difficult if the code is fully covered by automated tests – but if not you can bet that even very complete regression tests are going to miss something.

Yet there might be a valid reason for breaking OCP, says  Rafael de Azevedo.

According to the Single Responsibility Principle there “should never be more than one reason for a class to change”.  Says de Azevedo “Identifying, representing and separating relevant concerns is the fundamental principle for our design process.” 

Imagine a typical conventionally written application with a large amount of technical debt. There’s a form class (let’s say). The code behind not only presents the UI but retrieves the data, has a whole lot of processing in the click event of one of the buttons. Another button uses SMTP to create an automatic email… and so on. Not unusual at all.

The only way to modify this class without changing existing code would be to encapsulate it in a wrapper class. This would be far from ideal. Breaking the Open Closed Principle at this point would be the desired way to go. Instead of one class one would have a number- each with it’s own responsibility. A Presenter or ViewModel class to update and respond to the UI. Those 300 lines of code under the click button (the horror! the horror!) could be moved to a new class, or (as is most likely), the code refers to another class or classes then the code should be moved to that class. Unless that class is closed for extension, modification or anything else.. hmmm.

The automatic email functionality should also have it’s own class.  Suppose that it is this functionality which has a new requirement. How much easier (and cool) just to be able to modify this class and being able to leave the UI class well alone? It also means the new functionality is available in the 5 other places where the automatic email stuff had previously been cut and pasted.

It also makes unit testing a lot easier and focussed as each class can be tested on it’s own apart from the form class (which would now be a Composite).

The lovely outcome of this carving up the code into manageable slices is that we can zero in with surgical precision into the area which is open for extension rather than spending days trying to track down the bits in the existing code which would require changing.

 

Feb
02

The London Software Craftmanship Community

It seems I’m not the only one who likes to think of creating software as a craft. Sandro Mancuso has started a group called The London Software Craftsmanship Community.

Last night I attended a Code & Beer “meetup” at a pub near Liverpool Street station. I was warmly welcomed by Sandro and he told me about his vision.

He laments the lack of professionalism amongst software developers who are expected by management merely to “produce” as if they were workers on a factory assembly line. He would rather see developers as having the same status and respect as doctors and lawyers. He calls them “craftsmen” or “practitioners”.

What can developers do to change this perception? Sandro says that managers don’t care how the software is written so long as it arrives on time with the features specified. This gives an immense freedom to programmers to get their own house in order and create code which is beautifully crafted. Code which is easily maintainable and extendable through the use of such skills as refactoring, written unit tests and use of design patterns.

To that end Sandro feels that practice is important – hence the meetups. Tonight the agenda was quite open and one could work on one’s own project, join a discussion or help someone else with their project. Sandro himself planned to do some pair programming with another developer and as soon as he had finished chatting to me became busy doing just that.

I asked Sandro how his concept fitted in with Agile methodology. He said that Agile was more about the process of getting software out on time than with the quality of the software. But are not refactoring and pair programming part and parcel of Extreme Programming and one of the Agile principles (as I have been recently reading) is to eliminate “technical debt”? The motivation of course is quite different and I’m sure this is what Sandro was getting at. To me it seems that Agile is more about a team working together in the most efficient way while the “craftmanship” is more about the excellence of the individual developer and the position of developers within the industry. Something like the craft guilds of old.

I like it, and I will certainly be joining them again to tune-up my own software craft skills.

Dec
13

Coders as craftsmen?

Mankind have been making things since ape men first carved tools from volcanic rocks in Africa. A great place to find some of these creations is the British Museum and I often go there. Yesterday I visited their latest block-buster Grayson Perry : The Tomb of the Unknown Craftsman. You might think having the art world’s favourite transvestite having a show in one of the world’s most eminent institutions might be over the top – but Grayson Perry’s exhibition style is very down to earth and gives an understanding of what museum visiting is all about. They are pilgrimages of discovery rather than just another of the top ten things to do in London that needs to be ticked off.

Is writing code a craft? Can a developer see him or herself as a craftsman? Or is it just a chore like packing shelves at Tesco?

Ok, we’ve all seen code which if applied to packing shelves would make shopping an absolute nightmare. Throw anything together in a haphazard fashion and as long as it works let’s move on. Or at least it works at least some of the time.

This is not craftsmanship. Not only is it sloppy and makes further development and maintenance time-consuming but it is a lost opportunity. Writing code is one of the few remaining commercial activities where one has considerable freedom to create and perfect. There’s a direct connection between the first tool makers 250,000 years ago and today’s cutting edge technology.