technicalcreative

Wednesday, May 24, 2006

Ditching web forms, learning Javascript

It's a shocking admission to make, but I'm currently learning Javascript.

With eight years of post-Uni software development behind me, including four doing web, I've never seriously looked at the language. I'd open the odd window or include the odd validation script; you know, pidgin Javascript.

Difficult to believe, eh? Hardly. In the old days, we never bothered with Javascript. You could never fully rely on it for validation, it got processed in different ways on different browsers and I started doing ASP .NET stuff soon after, which handily started generating Javascript at your behest.

We've recently decided to abandon the extensive use of web forms on front-end work, the eventual aim being to free ourselves of the constraints of postback and form-based server controls.

The case for learning Javascript starts there. Client-side validation is important. You've still got to validate on the server, but a few choice validation functions can prevent your servers from having to validate incorrect data from Javascript-enabled visitors.

The most surprising thing I've learn't about Javascript is how much I already know. The operators and syntax are very close to C# ( it's even got try..catch :D ) and I've managed to whip through the basic language in a couple of nights. Still need to go through the libraries, but before I take myself through the DOM and get onto prototype and AJAX, but things are going well.

I'm encouraging the junior members of the team to re-visit the language as well. They too, have been spoiled on the sumptous banquet of ASP .NET Validation Controls. We're all working from the concise, but decent tutorial over at w3schools.

Been fun so far, but learning something new normally is.

Monday, May 22, 2006

Programmer 101

Programmers have come a long way in thirty years. Beards are no longer compulsory, science fiction is optional and punch-cards are just something mad old men mutter about in corners of forgotten ale-houses. Most modern-day coders are 'daylight-capable'; some can even handle non-technical chatter for literally sentences at a time.

Despite the unquestionable progress, we're still a misunderstood lot. No longer. Welcome to "Programmer 101".

Let's get the big fella out of the way. The first question a non-programmer might ask is :-

Q "How did you ever get into these dire professional straits?"
A : The short answer - mostly by accident. Time for an expansion :-

People are not born programmers - even in 2006 there is a universal lack of USB compatibility in human new-borns.

Most of us were ensnared by the charms of some fetching little 8-bit number at an early age. They were mysterious, infernal little contraptions requiring a lot of work to operate, and got bigger and better every year. You had to read manuals, type commands in by hand and solve puzzles as you went. Every computer user in the 1980s was a programmer, whether they knew it or not.

Making the conscious decision to become a programmer is a surprisingly easy decision. It gets you out of the house, and it’s not exactly difficult – especially since the first year of every computer degree involves hapless lecturers running courses like "Computer Monitor or TV? : Simple Ways To Tell the Difference".

University, like actually getting paid for something you'd be doing anyway, is a bit of a no-brainer.

Q : Science Fiction is optional. Surely that's untrue?
A : Coders can operate without Sci-Fi, but without the fighting spirit of James T. Kirk, the grammatically-dislocated wisdom of Master Yoda or the time-travelling prowess of the Doctor ( what do you think legacy code is? ) it is difficult to see how they could ever become truly successful.

Q : At which stage in your careers do you have "people skills" removed?
A : Many will think that the limited interpersonal capabilities of a programmer are the direct and tragic result of prolonged periods of time without human contact. This may be true.

Really though, programmers are control freaks by default. The job involves telling a computer exactly what to do, mostly with success. People are a whole lot harder to work with by comparison. We’re trying, though.

Q : What are the good things about the job?
A : It's fun to come to work to solve puzzles and create things.
It's also a real buzz whenever your brain delivers the goods, rendering you a hero for the day.

Q : And finally, the bad?
The power of creation has its down-side. Whenever you see one of us really ticked-off, it's normally because the thing we've created has become a mutated monster running rampant in a live environment. These little worlds we create are reflections of ourselves, so it's a pretty personal experience to see one of them turn into a bomb-site by your own command.

Finally, the worst thing about programmer is that normal people just don't know anything about being a programmer. Hopefully, with "Programmer 101", you'll know us just a little bit better.

Cherry picking

One of the most challenging questions you'll ever answer on Microsoft's .NET Framework is how much of it you're going to use.

It is great for solving large architectural problems and C# is probably in the running for my favourite language ever.

Thing is, you don't have to take all of it, and if you're developing for the web, you really shouldn't. Microsoft offer a lot out of the box with ASP .NET, superficially neat controls that on the surface, save programmers a lot of time. In my experience, they cause more problems than they are worth - and are probably responsible for innumerable spats between design and programming teams the world over.

Postback is another area where Microsoft attempts to do you a favour. Again, it saves time and again, it causes problems. If you use postback or server controls, get used to hefty page weights (through auto-generated ID tags and Viewstate ) and a lot of Response.Redirects in your code. It makes maintenance a pain and means that programmers end up doing more of it than designers ( "oh, can you just make it go here!" ).

Microsoft have to be applauded for the platform as a whole, but their appreciation of the web leaves a lot to be desired. Postback and ASP .NET Form-like server controls are time-saving antidotes to the stateless nature of the web, but you've got to ask whether the cure is worse than the disease.