August 1018

If I ran DevDiv… my take on things

There have been some very thought provoking blog posts focussing on .NET recently and this post is my reaction to them. In “How I Feel About The .NET World Lately” Davy Brion rants a bit about some stuff he doesn’t like and Ayende has some ideas for how he would change things going forward.

Davy’s post is, by his own admission, a rant. He refers to the Microsoft recommended development practices and products as “Fisher Price Development”, a sentiment I share to some degree. In my opinion a developer is someone who can write code and not someone who can only use the wizards in Visual Studio. Microsoft has plenty of documentation on how to use their tools and write code as long as you want to do it the Microsoft way, but it isn’t much help if you’re trying to do things in the real world. Now I don’t think it’s Microsoft’s place to try to teach people how to be a good developer, but I would like to see better quality documentation. We know they can write good code so why settle for poor quality on MSDN, proper use should be made of using statements and care taken to ensure that objects are properly disposed – even in these simple examples. Hello world samples are useful when you’re trying to learn something new and sometimes so obscure that it’s hard to see how to apply their example to what you’re trying to find an answer to. To quote my friend Karl:

When I was trying to learn how to use delegate functions, the MSDN example was something to do with an array of dinosaurs which were sorted using a delegate function. It was so utterly unrealistic it was no use and didn't teach me anything about delegates!

There are times when I need to ‘hack’ something, occasionally it makes sense to just throw in some raw ADO.NET code to pull back a simple value from a database and setting up an ORM for just that one bit of data is over kill. Like sorting your record collection alphabetically even though you only have one album. That said I still think there’s room to have an advanced / real world examples that show production quality code; including defensive programming, error logging and proper validation – people need to know what proper code looks like and this would be a good opportunity for Microsoft to lead people to a professional programming style. They could turn their developers loose on MSDN once a week and let them add in the advanced concepts, I’m not asking for much – just one afternoon a week. Granted this might not give documentation to suit all tastes but most developers can adapt code samples to something that works for them, so those in the alt.net community could use it as a jumping off point and maybe somewhere like codebetter.com could start it’s own MSDN style resource?

Where are things going?

A lot of attention seems to be focused (at the moment) on the entry level .NET developers – my concern here is that this appears to be at the expense of those at the other end of the spectrum. Both WebMatrix and LightSwitch (it should be noted that I haven’t actually used either of these, so you’ll have to take my opinions with a pinch of salt) are designed to allow people to:

solve specific business needs by enabling them to create professional-quality business applications, regardless of your development skills

The trouble I have with this strategy is that it hides the complexity of creating professional software from those using the tools so when you need to do something that isn’t possible through the wizards you’re in real trouble. I have seen quite a few people call themselves developers, even get jobs as developers, who can’t actually code and I worry that tools such as these will only encourage more people. Please don’t misinterpret me here, I am not saying there’s anything wrong with having a cool IDE that lets anyone put together a nice program – everyone has to start somewhere right, but that’s not the same as becoming a developer yet that’s the impression that’s being given and doing that devalues professionals and the years of effort they’ve put in to learn their craft. I have a Sony A200 and I can take pretty decent photos with it, but I am not a professional photographer, nor do I delusions that I am one.

Ideally I’d like these newer tools to provide a nice easy path into the more serious end of programming but I fear that mastery over something like WebMatrix isn’t really going to help someone migrate to using Visual Studio.

What can we do about it?

So that’s a rough summary of where things are at the moment, and a glimpse of where it looks like they’re heading, so what can / should be done about it?

Good question, in fact that’s pretty much the question Ayende tries to answer,

if you were in Scott [Guthrie]'s shoes, what would you do?

  • I’m very much behind Ayende’s call to kill duplicated effort, his example of the embarrassment caused by LINQ to SQL & Entity Framework fiasco illustrates this point nicely, they should have identified the overlap while they were still internal projects and unified them before they saw the light of day. This is how I feel about their tools, internally they need to collaborate / communicate more to know what other teams are doing. I know a developer who refuses to look at new technologies because they get killed off and he ‘wasted his time learning UML and other stuff’ – essentially he’s afraid to invest his time into learning something new in case it gets pulled within a year or two, and to be honest you can’t really blame him if his fingers have been burned before.
  • This point was made by Karl and I’m simply repeating it here: “Stop trying to out-X X!  Microsoft software does its own stuff and does some brilliant things.  But you can't out-Google Google, out-Linux Linux or out-Apple Apple.  That's why the Phone 7 stuff is so interesting to watch develop because, unlike Android, they've actually done something new rather than just copy the current state of the art.”
  • I’ve said I feel there is a lot of attention focussed on the entry level developers – well I also agree with Ayende that Microsoft should focus some love towards the non entry level developers, this shouldn’t be allowed to continue.

Now in a cheesy attempt to generate some comments… what would you do dear reader?

Spread/Promote this post

If you enjoyed this article, consider bookmarking or helping me promote it! Thanks.

  • Del.icio.us
  • Digg It!
  • Technorati
  • BlinkList
  • DZone It!
  • Furl
  • NewsVine
  • Reddit
  • StumbleUpon

Don't miss another post

Subscribe to SJM Dev's RSS Feed to stay updated with our latest articles!

Permalink | Comments (1)

July 1029

Double auto brace completion problem

Just recently I’ve been getting a double closing parenthesis when I open one. I know CodeRush has auto completion and that’s been working fine so this threw me a bit.

The problem is quite easy to define, whenever I type the opening bracket of something – for example I type ToString and then the ( I get a double closing )) – this was quite annoying! This was only happening on my home pc where I have Visual Studio 2010. I did a quick Google (amazing how often I say that) and found the answer in a recent Visual Studio 2010 Productivity Power Tools update – this has an Automatic Brace Completion option and so does CodeRush so I figured they were both firing and that simply wasn’t necessary and turned off the PPT feature. This required a restart of Visual Studio, which found an update which re-enabled the feature so I had to disable it again and re-restart. Now typing the opening bracket ( just gives me a single closing bracket ).

I have to say that I wasn’t totally happy with my experience, a restart just to turn off the feature? And the setting wasn’t persisted? I’m prepared to accept maybe I did something wrong but if I did I’ve no idea what and so I’m not left with a satisfied feeling about it.

In one of those ‘strange co-incidence’ moments my rss feeds this morning had an item from DevExpress about a completion problem and the summary looked enticing. I was quite surprised, amused, interested in this having suffered the same issue only the night before. I’m not sure which tool offers the better implementation of the feature and asked whether there were any feature comparisons – Rory Becker quickly came back with the options he’s disabled in PPT. I have made the same changes and show them here in the hope it helps someone else.

Disable Automatic Brace Completion, Ctrl+Click Goto Definition and Highlight Current line

Spread/Promote this post

If you enjoyed this article, consider bookmarking or helping me promote it! Thanks.

  • Del.icio.us
  • Digg It!
  • Technorati
  • BlinkList
  • DZone It!
  • Furl
  • NewsVine
  • Reddit
  • StumbleUpon

Don't miss another post

Subscribe to SJM Dev's RSS Feed to stay updated with our latest articles!

Permalink | Comments (0)

June 1029

How to resolve relative and absolute URLs without using tilde slash (~/)

The ~/ (tilde) shortcut when working with ASP.NET controls is awesome, so awesome I use it all the time. Trouble is that it doesn’t work for standard html elements, such as images, css and JavaScript. Well the good news is that there is a solution, read on…

When you use ~/ in paths for controls it is automagically translated to <%= Request.ApplicationPath%> for you, this means that you can develop in different domains and not have to worry about changing the paths for your controls. I develop locally with an http://localhost/myapp url and then push the changes up to a testing server which uses a different format – http://www.myapp.com/ if it wasn’t for the ~/ I would be in a world of pain.

The quick fix, for standard html controls (such as image and anchor tags) has been to use the ~/ and add a runat="server" e.g. <img src="~/images/myimage.jpg" runat="server" alt="" />. While this works great for these items it doesn’t work for paths to JavaScript files or CSS, also it is a minor performance hit because each control needs to be processed as a server control - that’s been causing me a bit of pain recently, so I did a bit of research and have come up with the following advice.

Following advice on avoiding problems with relative and absolute URLs in ASP.NET my first attempt to solve this problem saw me adding <%=Request.ApplicationPath%> to the address e.g. <img src="<%=Request.ApplicationPath%>images/myimage.jpg" alt="" />. This means I could drop the runat="server" from my controls. I tested this locally and all my paths were being resolved correctly, but when I pushed it to the testing server none of the paths were getting resolved, in fact Firebug was showing 503 service unavailable for all paths. That didn’t look very promising, the whole point of this is to eliminate the differences in url structures and file paths when working locally – if it works locally but not on the server that’s not going to help. This fell into the category of unexpected results when using Request.ApplicationPath but my problem wasn’t a double leading slash "\\" – it was the 503 error. I needed something else.

Google also threw back an interesting post “Using the Tilde (~) in ASP.NET Everywhere – Not Just Controls!” that shows a neat way of getting the tilde to work everywhere but reads the page output into a memory stream to parse and rewrite it, but that’s not the solution I was looking for either, I want something that’s just quickly understood. I did try replacing Request.ApplicationPath with the HttpRuntime.AppDomain.AppVirtualPath property as that’s what the author of the post was using to rewrite the paths – it didn’t work either.

The answer

I thought I’d give this a new section, so anyone who wants to cut to the chase and just see how it’s done can do so.

Just use ResolveUrl("~/") and you’re good to go!

Seriously, it was that simple e.g. <img src="<%ResolveUrl("~/images/myimage.jpg")%> alt="" /> or in a JavaScript path <script type="text/javascript" src="<%=ResolveUrl("~/") %>scripts/myscript.js"></script>. Note that you can either pass the entire url or just the tilde slash to ResolveUrl and the result is the same. I’m not sure whether there’s a performance hit in passing just the ~/, but I think keeping the actual path out of the function makes it just a little bit easier for someone else to come along and modify the path without needing to know about the ResolveUrl function and what it’s doing.

Spread/Promote this post

If you enjoyed this article, consider bookmarking or helping me promote it! Thanks.

  • Del.icio.us
  • Digg It!
  • Technorati
  • BlinkList
  • DZone It!
  • Furl
  • NewsVine
  • Reddit
  • StumbleUpon

Don't miss another post

Subscribe to SJM Dev's RSS Feed to stay updated with our latest articles!

Permalink | Comments (1)

June 1024

A Heisenbug

Ok so I’ve just put up a post saying that I’m not doing anything blog worthy and what happens… yeah I get handed an interesting problem to work on. This post is as much a cry for help as anything else.

That’s great I hear you say, but what the heck is a Heisenbug? Well Wikipedia defines a heisenbug as

a computer bug that disappears or alters its characteristics when an attempt is made to study it.

The name heisenbug is a pun on the Heisenberg uncertainty principle, a quantum physics concept which is commonly (yet inaccurately) used to refer to the fact that in the Copenhagen Interpretation model of quantum mechanical behaviour, observers affect what they are observing, by the mere act of observing it alone (this is actually the observer effect, and is commonly confused with the Heisenberg uncertainty principle).

So now you know what a heisenbug is (and have found out that what you thought you knew about the Heisenberg uncertainty principle was wrong – I had it confused), let me bore tell you about my heisenbug.

I have a relatively simple asp.net form; after logging in the user has to pick a qualification from a Radio Group and enter the correct security ‘password’, the logic behind the submit button checks the page is valid by ensuring that a qualification has been selected and that the password matches the value stored in the database for the account, if everything is good then redirects off to the next page. If nothing has been selected, or the password does not match then asp.net validation alerts the user that something was wrong and they must fix it before progressing to the next screen, so far so good. This works fine on my local pc, it works fine on the testing server and on the staging server but on the live server we’ve been getting reports that it isn’t working properly sometimes. Users fill out the form as expected but when they hit the submit button the page just reloads, no validation errors but the page reloads, but other times the same user has no problems with the process. Weird eh?

My first thought was to fire up Visual Studio, attach the debugger to the process and try to step through the code rather than start the page in debug mode from Visual Studio as I wanted to run this against the real code rather than my development code which I know works. Unfortunately that’s no so simple and though the debugger appeared to be attached none of the breakpoints were being triggered, so I’ve had to just run the project in debug mode with my local copy. Of course now I’m watching I can’t repeat the bug, every time I try the process, using the same details I’ve seen others use and run into the bug, it just works for me. Is it that I’m watching and affecting the way the code executes or is it where the code is running or what?

Spread/Promote this post

If you enjoyed this article, consider bookmarking or helping me promote it! Thanks.

  • Del.icio.us
  • Digg It!
  • Technorati
  • BlinkList
  • DZone It!
  • Furl
  • NewsVine
  • Reddit
  • StumbleUpon

Don't miss another post

Subscribe to SJM Dev's RSS Feed to stay updated with our latest articles!

Permalink | Comments (0)

May 1025

Setting up hosting with Unfuddle

This is the first in a new series showing how to set up version control. I am aiming this primarily at individuals or those working on their own, if anyone would like a discussion about some of the challenges in scaling this approach up then please get in contact or use the comments.

This post will walk you through creating an account at unfuddle where you can host Subversion and Git repositories, and I will concentrate on Subversion for the moment. If you haven’t already installed tools for working with Subversion I suggest you install TortoiseSVN and VisualSVN or Ankh

Disclaimer

I do not work for unfuddle and I am not receiving anything from them for promoting their services; to be honest I haven’t tried any other subversion hosting providers. I’m just going from personal experience. If you have any recommendations please let me know.

Right that said on with the post. There are 5 plans ranging from the Private (which is free!) for single developer projects to Enterprise ($99/mo) for very large development teams. As the focus of these posts is to get a solo developer set up for version control, and because its free, I’ll be using the Private plan. The Private plan only allows 1 Active Project, no Archived Projects and 2 people but unlimited repositories (well limited to 200mb on disk, but things take up less space in a repository than they do as project files so that’s quite a bit of storage). You can upgrade or downsize your plan at any time.

Why would you want to do this?

A valid question to ask at this point is why are we setting this up in the cloud, aren’t there risks with hosting things in the ‘cloud’? Well yes there are, but I think the benefits far outweigh the risks.

Ok yes you could use something like VisualSVN Server to create your own subversion server locally and for some that may be the right thing to do, the advantages I find in hosting with unfuddle are that I no longer need to worry about backing up my projects. This issue is really one of scaling the solution up, so if anyone wants to discuss this further please do use the comments or get in touch. But it is a side issue so I’m going to get on with the post now.

Account Setup

You need to create a subdomain for your unfuddling; I use the name of the project I’m working on, or the name of the company and a Title that’s just used for personalising the site. The Administrator Login is pretty easy stuff – once I’ve created the admin account I tend to link it to an openID and not have to worry about it again.

There’s some helpful instructions explaining what happens next alongside the form:

When you are finished with signup, you will find that a single project titled "My First Project" has automatically been created for you. Feel free to use this project to get comfortable with Unfuddle's features.

Once you have settled in, you can either rename this project and use it for active development, or you can delete it and create a new project.

Now the account is set up you might want to spend a little time exploring the options in the site. I like to tweak things, so have changed the colour theme used and updated my personal settings to show that I'm in the UK...

Creating a repository for your project

Ok so you’ve created your account and have things looking pretty nice to set up a repository from the Repositories tab click New Repository; you just need to give it a friendly Title and an abbreviation (which will be used in the URL), for example http://sjmdev.unfuddle.com/svn/sjmdev_testproject/ (make a note of it, we’ll use it in a minute) then specify the type or repository – in this case I’m using Subversion but Git is also an option, the process is pretty much identical. If you like you can give a description, I haven’t missed it yet, but I am the only one working with my repositories and I know what they are from the Title! It only takes a few seconds for the repository to be set up for you.

That gives you a blank repo(sitory) hosted by unfuddle, the final step is to create the repo structure within it. The recommended approach is to have folders for branches, tags and trunk. The trunk represents the main working copy of your work, and in an ideal world will always result in a project that builds. When you want to do something a bit odd the strategy is to branch off so you have a bit of a play in branches. I use tags for my releases, so will have tag folders for v1.0, v1.5, v2 etc that way I can always go back to a known release of a project. Unfortunately unfuddle doesn’t create this structure for you, so we’ll do that now.

Creating the folder structure

To create the folder structure I know and love I usually follow these steps:

  1. Create a new folder in my Visual Studio Projects directory, right click the folder and select SVN Checkout, paste the URL of the repository and make sure that the checkout directory is your new folder.
  2. Inside the new folder create 3 new folders; trunk, branches and tags
  3. Right click the root repository folder and select SVN Commit… This will send the new folder structure up to your hosted repo.

Next I need to add my solution files to the repository, so I’ll either create a new project inside the /trunk folder or I’ll copy an existing project in there, remember the trunk represents the most current development code.

Why don’t I just put the files in there and then use TortoiseSVN to commit the project along with the folder structure? Well there are some files that just aren’t needed in a repo and VisualSVN comes knowing which files they are. So I like to use VisualSVN to add the project files to a repo structure. So with the files I for my solution in the trunk I’ll open Visual Studio, right click the solution in Solution Explorer and select Add Solution to Subversion – it will confirm the folder you’re adding to and check to make sure all files exist in the folders for the repo, then ask whether this is a new or existing repository. As we’ve already set up the repo select Existing repository and give it the url of the repo, in the examples it shows /trunk in the path and that’s a good reminder that we want to commit the project files to the trunk. In our case this is http://sjmdev.unfuddle.com/svn/sjmdev_testproject/trunk/ – then let it work while it uploads all the files. Finally you want to right click the solution and select Commit, this will push all the Visual Studio files up into the trunk, excluding files like *.suo as these are unique per developer and all .dll files – this can be a problem but it is easy enough to add them if needs be. I will do another post explaining some of the reasons behind this and explain what I do about that, but this just about wraps up this post.

Some useful posts

I used some of these posts when writing my post, they go into a bit more depth about the recommended folder structures and what they’re used for:

Spread/Promote this post

If you enjoyed this article, consider bookmarking or helping me promote it! Thanks.

  • Del.icio.us
  • Digg It!
  • Technorati
  • BlinkList
  • DZone It!
  • Furl
  • NewsVine
  • Reddit
  • StumbleUpon

Don't miss another post

Subscribe to SJM Dev's RSS Feed to stay updated with our latest articles!

Permalink | Comments (3)