Amadiere.com

Fourteen and a half crazy frog burpers

31st May 2009

How To Become A Better Programmer

Filed under: Blogging, Programming — Tags: , — Alex Holt @ 7:23 pm

One of the things that I’ve really begun to do in the last few years is pick up the trail in an attempt to become a great programmer. I am obviously not there, nor do I think I’ll ever get there – but I believe I’m on the right path! Previously to my changing my goals / gaining focus on what I wanted to do, I only got better and more knowledgeable at things that were needed for my job. Now, I’m starting to gain momentum – I can almost *feel* my brain bulging!!

So here are my top tips for becoming a better programmer!

Do Some Homework!

A lot of people are very content with programming for a living, but through sheer code exposure logic – if you do programming at home you are exposed to more code and will therefore become better over a shorter period of time. It’s kinda simple when you think about it. There are a few different ways to do this as far as I see it:

  • Take home some work and refactor that ugly function you created. A task that is too big and time-consuming for too little benefit to warrant a redesign in “works time” – but is pecking at your soul, screaming “I’m your dirty secret!”.
  • Create your own project to work on. Establishing a really good, motivating idea can be a great way to spur you on. It could be something for your own devouring or for a wider market (though, check to see whats out there if the latter).
  • Contribute to Open Source – this is probably one of the better, most light weight solutions you can go for. You’re under no obligation to contribute and at worst you get to look around another persons code that you wouldn’t normally and potentially pick up some interesting methods of achieving something you’ve not thought of.

Syndication, Syndication, Syndication!

Find some good blogs & podcasts and subscribe to them! If you can dig out some of the best bloggers for the technology stack that you’re interested in, you can sometimes get some excellent articles to read on the way into work. It’s important to avoid subscribing to too many blogs – you need to be able to actually read them. Too many would be unproductive and you would not get chance to read them and give them the concentration that they deserve.

As it stands at the moment, the blogs I can recommend are: Coding Horror, Joel On Software, Stack Overflow, Scott Hanselman’s Computer Zen, Jon Skeet Coding Blog, ScottGu’s Blog, you’ve been HAACKED, Elegant Code and of course, shameless plug to mine Blog @ Amadiere.com

I’d also highly recommend listening to a few podcasts when you can, the Stack Overflow podcast is particularly good, but there are plenty of others. So scout around for the ones which focus on your development environment (or are to a degree, fairly generic like the Stack Overflow one).

Care About Your Craft

I’m not saying you have to start hyper-ventalating when someone shows you a demo of some of the stuff in ASP.NET 4, but you should at least be interested in what opportunities it might have to offer you (exclusion, of course, for those that do not use .NET). The mere fact you are reading online blogs about improving your craft implies that you already care enough to read and work out of hours. It’s important I believe to feel for your projects, they should be like children to you. You look after them, care for them, make sure they wash behind their ears and when they are finally of age, you can help them leave home and go and live with their users.

Keep Updated With Changes To Your Development Stack

Things change. Don’t be as they say, a “COBOL Dinosaur”. You should be subscribed to whatever feeds you can that tell you when software and development languages are updated. If the updates aren’t detrimental to your development, go ahead and install them and have a play around with any of the new features that took your fancy. Ride the wave of the future!

Have A Book To Read

It doesn’t have to be a dead tree, but having something you can just work your way through will do no harm. There are a number of great books that people recommend with the top ones being Code Complete and the The Pragmatic Programmer. I quite enjoy language and environment specific books too, such as Professional ASP.NET 3.5, Professional ASP.NET MVC 1.0 and Professional C# 2008.

Write Something!

At the end of the day – don’t procrastinate! Write some code! Get your hands dirty and enjoy the glory that is !le code!

21st May 2009

Cross-page PostBack’s and Master Pages

Filed under: ASP.NET — Tags: , , — Alex Holt @ 6:39 pm

I’ve been a developer for a long time in PHP and Classic ASP, recently, we’ve been picking up the ASP.NET baton and running with it. We’re not running very fast it has to be said. It’s more a running the hundred metres with 100’s of rakes scattered across your track.

I digress. We came across a problem and boy did it stump us. We were trying to use Webforms to submit a POST to another Webforms page. We had our trusty copy of ASP.NET 3.5 Professional, but its example wasn’t working in our page. We took it out and placed it into a sandbox, sure enough it was fine and dandy. We eventually bottomed it to be something to do with the Master Page and after examining the Site.master file for any obvious errors we were stumped.

Basically, the book says to do a standard CrossPage PostBack you do the following:

using System;
using System.Web.UI.WebControls;
 
public partial class DestinationPage : System.Web.UI.Page
{
  protected void Page_Load(object sender, EventArgs e)
  {
    if (PreviousPage != null && PreviousPage.IsCrossPagePostBack)
    {
      TextBox text = PreviousPage.FindControl("TextBox1") as TextBox;
      if (text != null)
      {
         Label1.Text = text.Text;
      }
    }
  }
}

This didn’t work quite because the PreviousPage was the Master and the Master doesn’t directly contain the TextBox1. Therefore, before we can access this property, we must create an access point to the ContentPlaceHolder via something like:

ContentPlaceHolder ContentPH1 = (ContentPlaceHolder)PreviousPage.Master.FindControl("ContentPlaceHolder1");

This worked a treat, we were then able to access our TextBox1 via that control.

TextBox text = ContentPH1.FindControl("TextBox1") as TextBox;

This may seem a very trivial question, but it caused no ends of problems because the searches we found were never clearly the scenario we had. Therefore, I’m actively writing this post to reverse that injustice and hope that someone, at somepoint, finds it useful!

20th May 2009

StackOverflow.com – (Almost) Better Than Pie!

Filed under: Websites — Alex Holt @ 7:01 pm

I know, I know – it’s an outrageous claim! How can a website be better than pie? Obviously, a Meat Pie still has its place atop of the leaders board – but what about the Steak & Kidneys and Apple pies… can a website really be good enough to top them…?

I’ve been subscribed to Jeff Atwood’s blog, Coding Horror, for a year or two now – it always makes for an excellent read. He would say that it [consistently doesn't suck, or it sucks inconsistently]…

Anyway…! A bit back, he teamed up with Joel Spolsky (of Fogbugz) and he coded with help from others the very excellent Stack Overflow! Amazingly, for years we made do with generic Google searches and the scroll-bar intensive Experts-Exchange (which geniously, was named without the dash: ExpertSexChange). I’ve been a long fan and admirer and although I don’t actively participate much in the community, I’m in massive awe of what they have achieved and have been registered since the beta. They have literally taken the developer and programming community by storm!

There are so many things that I could mention in this post, but it would just go on for absolutely ages, so I’ll just try and list some of my favourites:

Open ID to Login:

Woah! What the hell is this OpenID lark? Turns out its mega kick ass! I’m sure I’m not alone in my naivety of this excellent standard, but what I’m hoping for now is that actually StackOverflow opens the eyes of developers everywhere and they all start to use this instead of yet more passwords and usernames! Not that you have to login of course. You can simply browse around and see all the answers and questions and to the most part – feel like a valued customer.

In addition to just using OpenID though, it does a really excellent user experience. To login, all I need to do is click the provider of my OpenID and then type in my username and it guesses the rest of my URL. It then sends me to my provider who I’m already logged in with and confirm I want to allow SO to find out about me – and BOOM! I’m born!

Look at all the colours! It's amazing!

Look at all the colours! It's amazing!

It’s A Question & Answer Site

All the existing rivals I’ve seen for StackOverflow were based on the tried and tested discussion boards technique. But this didn’t ever suit the function it needed to perform and answers could get lost in the midst of a page of differing opinions. This was solved in some cases by adding the ‘accepted answer’ technique, whereby someone would click to say that a specific response was able to satisfy their query. StackOverflow improved upon this model by adding a few mechanisms that allowed it to get rid of a few of the niggling flaws.

In an ideal world, everyone would know how to ask a good question and will include all relevant information. However, we don’t live in the ideal world (pie’s contain calories – do you need more proof?), so further information or clarification is often sought. This can be added into the original question, or as a comment in addition to it.

Creating the perfect question

Creating the perfect question

As you can see in the example above, the site is built towards not only getting top quality answers, but top quality questions too! Eljenso asked this question, but there was some debate over the question and what was meant by “flow”, between the original poster and the other users, they came to a fairly decent understanding. You can also see the question was edited – this was probably by the original poster. But if you are sufficiently trusted by the system (you have a high enough ‘reputation’), you’re able to rephrase the question, correct spelling, format code better – whatever you feel will help the correct answer appear.

Badges & Reputation

So, you have a fab site with an excellent mechanism for logging in, a clearly defined purpose (in being an “questions & answers” site), you even have the means to allow people to create the perfect questions – but without a great answer, or more specifically, without a constant flow of great answers. Your site is worthless.

StackOverflow tackled this in an interesting and seemingly extremely successful way. Reputation and Badges. First, let me say that StackOverflow wasn’t launched from nothing. Jeff Atwood had a big following thanks to his blog, and similar could be said about Joel Spolsky. If they blogged about this new project and asked for participants (including on the blogging site devoted to StackOverflow that existed throughout development) – they would have got hundreds if not thousands of offers from their readers. This didn’t rule out the need for (not only a good product, but also) a good marketing campaign. This they did well with their blogs and with the very excellent and entertaining StackOverflow Podcast (recommended and available from iTunes too). Basically, the problem they had wasn’t in gaining an audience – it was in keeping it. They had to create a site that was engaging and encouraging to read and answer questions for. They achieved something better though, they created an addiction. They managed to create a site that rewarded and encouraged users to not only reply, but reply well! So many sites reward for the most amount of posts, whereas StackOverflow lets other users say whether your points total should go up, based on how useful they think the question was.

The one thing that takes this really to the next level, is Badges!

Jon Skeet's badges have been removed to avoid the need for Horizontal Scroll

Jon Skeet's badges have been removed to avoid the need for Horizontal Scroll

There are the three types of badges indicating the difficulty of gaining them, and these badges are shown on your user profile so that people can see your achievements (and to some degree “trustability”). Even when you post a question or answer, people can see the number of bronze, silver and gold badges you have, along with your total reputation. These aren’t new ideas please note (badges for example are simply the same as XBox Achievements), they are just great implementations of them. Why re-invent the wheel? All you have to do work out how to get all the best ideas into one very nice, round package. This system they created, did that very well!

A quiet moment should be inserted here in homage of the great Jon Skeet. Almost double the reputation of his nearest rival using that age old formula of ‘writing an excellent and accurate answer’. /bow.

Maybe Google is just fibre optics into Jon's mind...?

Maybe Google is just fibre optics into Jon's mind...?

In short – it’s really worth checking out! If you do any sort of programming (or if you’re a responsible for the servers, then maybe visit ServerFault.com – the sister site, an almost clone of StackOverflow by the team), then you may find help (or be able to help others) at this site. If you do get addicted, please don’t forget to eat (though feel free to send the Pies to me!)

Older Posts »

Theme designed & built for Amadiere.com by Alex Holt. Powered by WordPress