Archive for the 'Web' Category

Speaking at the Vic.Net User Group

I’ll be speaking at the Vic.Net User Group on Monday 23rd January.

What about? Glad you asked.  The title is “Building Mobile Websites with ASP.NET MVC 3 and 4“.

It sounds fairly self-explanatory, but I’ll be covering more than just the obvious in this talk.  In addition to actually showing how to write mobile-targeted sites in MVC 3 and 4, I’ll be discussing:

  • Why it’s important to think about mobile sites, and why people aren’t,
  • How smartphones actually render a desktop site and what you can do about it,
  • How mobile and desktop sites can coexist beautifully, and
  • Why ASP.NET MVC is the perfect technology to deliver sites that look great on any device
  • What libraries and packages are available to give you the best results

So if you’re in the Melbourne area on Monday, I’d love for you to come and check it out.  Just RSVP on EventBrite and I’ll see you there.

UPDATE: The slides are now available at http://brdy.in/mobilemvc

My Quick Computer Predictions for 2011

Given that we’re well into the new year, I figured it was safe to make a few predictions about what I think 2011 will hold.

People will start to use four distinct types of “computer”.  Roughly in order of usage, they are:

1. A Smartphone.

New ones are already being released with dual-core CPUs, and the specs will quickly get ridiculous.

New smartphones are quickly becoming a legitimate replacement to a laptop. If you’re like me, you’ll use your phone for nearly everything, all the time (I already do). The only reason you’ll use a tablet (and you will) is for the screen size.

2. A Tablet.

Internet-connected tablet PCs will sprout up everywhere with all sorts of resolutions and sizes.  The iPad was just the first, but it certainly won’t be the last.

For people in my industry, that means something new to consider when writing websites. If you have a menu on your site that drops down on mouseover, change it. Seriously. There’ll be no mouse for most of your visitors.

I’m going to go out on a limb here and suggest that if you have a website, by the end of the year more people will visit your website using a phone or a tablet than a traditional computer. If you don’t cater for those devices, people will stop visiting altogether.  Don’t wait, do it now.

3. A PC or Notebook.

They won’t go away, but you’ll notice I put them at number three. That’s perhaps a bit unfair as they’ll continue to be the “main” computer in workplaces, but I predict that a lot of people will find they don’t really use their home PC any more.

4. A Gaming Console.

Purely a gaming machine, so obviously this depends greatly on the person. If you’re spending 20 hours a week with your Xbox, you’re probably not going to stop. On the flipside, there are people like me – I have a Wii that never gets used.  That probably won’t change either.

And that’s it. Short and sweet.  Feedback welcome as always.

(Predictable) Trouble in the House of Google

Jeff Atwood recently blogged about the declining quality of search results, particularly with respect to Stack Overflow content.

His main observation is that content syndication websites are starting to outrank the original content source in search results. He’s right to suggest that this is a problem; for everyone except content syndicators of course.

While I appreciate his disappointment, far from being upset by this, I’m impressed that it’s taken this long.  It also wouldn’t surprise me if this was a short term thing. As Jeff mentions, Google could probably “tweak a few algorithmic knobs” to make the problem will go away for a while.

It’s clear that Google does a lot of work to try to give you useful results to your queries.  But Google is only one company.  A single (albeit massive) company fighting to provide relevant results against an army of hundreds of millions (billions?) of sites trying to get to the front page of Google search results.

So why should we be surprised that it’s finally becoming a problem?  There are striking similarities in the history of DRM, or computer viruses, or spam detection. One protagonist against millions; all looking for ways to game or cheat whatever system they’re trying to defeat. In my opinion, Google has been orders of magnitude more effective in staving off attacks than the three prior examples.

Effective DRM is really only renowned for pissing people off (those links took mere seconds to find – in Google coincidentally), and we’re always being subjected to new viruses and spam techniques.

I hope that this trend is halted by the twiddling of knobs, but either way I’m impressed by how long Google has largely held off this threat.

Using the data you generate

I stumbled across an excellent article by Zachary Seward titled, “Everything the Internet Knows About Me (Because I Asked It To)”. It’s an great example of how much data can be collected about your every day activities.

While Zach gives some very interesting insights on what that data means to him, my immediate thoughts flew to, “what could an application do with this information?”

Using The Data:

Lately, I’ve been working on a presentation predicting the “rise of participative software”; software that actively participates in your life rather than standing idle waiting for instruction. As Zach hinted, data collection is prolific and the data ubiquitous.

Software is already capable of using swathes of data to actively push targeted advertisements your way, so why can’t it use its power for good and make suggestions to save you time or improve your life? Key to this concept is the idea that data-mining logs of your personal habits and activities can yield vastly useful useful information.

The Alarm Clock:

My go-to example of this kind of software is the humble alarm clock.

A stock (read: boring) alarm clock will sound an alarm wake you up at a certain time the next day. Extensions have included multiple alarms, repeating alarms, and technological marvels (like WakeMate and Sleep Cycle) that try to wake you up at the best possible time. Ultimately, they’re all just trying to wake you up before a certain time.

So what can all this public and personal data do for the alarm clock? It’s worth noting before I start that I use the alarm on my smartphone because it’s always on the bedside table at night. An alarm clock running on a device like this opens up a world of possibilities.

Let’s say my standard alarm is set to 7:30am on weekdays. That’s great most of the time, but there are a lot of exceptions to the rule. On public holidays I want to sleep in and if I have early meetings I need to wake up earlier. This is easy enough to do; the data is available. Public holidays are known well in advance, and my work calendar is already synced to my phone so that information is available as well.

Let’s take it a step further. My phone has GPS and knows about the wireless networks at my office and at home. In short, because I’m all but physically attached to my phone, it has the ability to track my movements.

If I leave work at 11pm on one particularly gruelling day, that data could feed back into the alarm clock. Wouldn’t it be nice if, when I finally went to bed that night, my phone asked me whether I wanted a sleep in the next day and adjusted the alarm accordingly?

Let’s take it even further, shall we? At 6:30am one Tuesday morning, my phone notices I have a 9am meeting at work. The phone turns on GPS or Wifi to check I’m at home, maps a driving route to my office (using Google or Bing Maps), and checks traffic data to see whether there are any accidents on the way. If there are, it might decide to wake me up early so I’ll make it to work on time.

Active Participation

I’m sure you can see where I’m going with this. The key point I’m trying to make is that I shouldn’t have to explicitly tell the software to behave this way for me. It knows my habits, has access to relevant data, and can therefore make predictions on what I want. It’s really just about combining and interpreting the huge amounts of data available and using it to actively participate in my life.

GPS data combined with bank account details and ATM localities could allow my phone to tell me I’ve been paid as I walk past an ATM.

Foursquare checkins combined with restaurant reviews and data from a coupon site could suggest places to go for dinner on the days I usually go out.

The possibilities really are endless.

The Skynet barrier

Whenever I talk about ideas like this with my fiancée, she blanches. She sees things very differently to me in this respect, almost certainly because she’s not an IT nerd. She doesn’t want her technology covertly collecting information on her or telling her what to do, and that’s probably the biggest barrier to this type of technology.

Just because you can do something doesn’t mean people will be comfortable with it. As Arthur C. Clarke famously wrote, “Any sufficiently advanced technology is indistinguishable from magic”, and while not everyone is scared of magic, it’s reasonable to be scared of the magician when it involves your private information.

Conclusion

With any product, it’s really up to the market whether applications like this will be deemed acceptable and ultimately popular. I may see opportunity while others see Skynet, but the opinion that matters is the one belonging to the consumers with the money.

If you want to share your opinion, or if you would like me to share all my ideas on this topic, let me know on Twitter, or by email.

IT Careers and Training – my Stack Exchange proposal

Just a quick post to plug a proposal I’ve made for a new Stack Exchange site for IT Careers and Training.

The intention is to have a Stack Overflow-style site where you can ask and answer questions about how to progress or start your IT career.  What training courses and certifications are worth their money, what companies are good to work for, and how to get where you want to go in your career.

Have a look and give your support here.

jQuery 1.4 released!

Yep, jQuery 1.4 has been released.

Here’s a great post from nettuts outlining some key differences and new features.

I don’t really have much to add on this, but just a few thoughts:

  1. Speed improvements are good and all, but when you can get ten times better javascript performance by changing browsers, nearly doubling the speed of your .css() method not the most important thing. Still, I can’t expect the jQuery team to be able to retire browsers for people I guess…
  2. A lot of changes seem to deal with allowing functions to be passed into methods.  Being a .Net 3.5 guy, I’m love this anonymous delegate stuff, so it’s good to see!

Yeah, that’s all the comments I have right now. Told you I didn’t have much to add!

Getting into ASP.NET MVC

It all started when I decided that I’d rewrite a partially-aborted PHP web app of mine in .Net. The PHP version was relatively functional, but PHP is not my strongest skill, so updating and improving it was hard. Combined with a lack of good quality free time, it meant that I didn’t have the inclination to update it much.

Much of the design work is already done. The database schema is solid and it isn’t trivial – it took me a number of iterations to get right. The UI flow has been decided, and at this point, I’m happy to reuse most of the layout, css and images.

At Tech.Ed this year, I heard a lot of great things about ASP.NET MVC. The Hands-On-Lab I did gave me just enough of it to get me interested, so when I decided I was going to rewrite this thing in .Net, MVC seemed like the way to go.

So I’m now attempting to learn how it all works, and it’s going really well. The secret? The NerdDinner tutorial courtesy of Rob Conery, Scott Guthrie, Scott Hanselman, and Phil Haack (actually I get the impression that Scott Guthrie wrote the tutorial, but the originating book is authored by all of them).

Seriously, if you’re looking at playing with ASP.NET MVC, run through this tutorial from start to finish. I guarantee by the end of it you’ll be all over the basics, and loving the way ASP.NET MVC is put together.

I’m looking forward to getting into some real development with this project.

Probably the best response on Stack Overflow ever

You’d probably be aware that I’m a fan of Stack Overflow. I mean, I have my SO profile over there on the right of the page.

This is just a quick post to provide a link to the best response I’ve seen on Stack Overflow. And just to clarify, I mean best in terms of amusement. It gets a point across I guess, but wow is it creative.

So here you go: http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454

Using jQuery for evil

Sometimes you find a tool that’s not just good for run-of-the-mill, intended-purpose work, but also for fixing up some bad situations.  jQuery is one such tool.

Some work I’m currently doing involves presenting nicely styled pages to the user of a web site.  The html I have to work with is not always ideal and needs to be massaged.  Because I’m dealing with templates, it’s often simply impossible for me to change the html – I can only try to modify the framework around the bits of html I’m given.

Enter jQuery.

Provided the html I get is more or less xhtml compliant, I’ve got a Document Object Model (DOM) I can work with.  Using jQuery, I’ve found that I can manipulate this to my heart’s desire.

Let’s say I end up with an table which has an extra row between the header row and the first actual row of data.  No problem!

$(document).ready(function() {
    $('#mytable tr:nth-child(2)').remove();
});

And that’s it! Of course you may get a flicker of the incorrect display because we’re making the change only when the DOM is completely built, but we’re not really choosy in this situation.

Let’s try something a bit harder.  How about reformatting a table which contains a single column for debits and credits; the debits formatted with a red <FONT> tag.  And before you ask, yes, I’m serious.

We want this table to have a separate column for debits and credits.  Again, enter jQuery.

$(document).ready(function() {
	// first, deal with the headers
	var cell = $('#mytable tr:eq(0) td:eq(2)');  // look at the second cell (contains debits/credits)
	var w = cell.attr('width').substr(0, cell.attr('width').length-1);  // I know width is a percentage
	cell.attr('width',''+(w/2)+'%');	// half the width
	cell.text('Credits').before('<td align="right" width="'+w/2+'%">Debits</td>'); // split Debits and Credits header
 
	// now deal with each non-header row
	$('#mytable tr:not(:first)').each(function()
	{
		$(this).children('td:eq(2)').before('<td align="right">&nbsp;</td>'); // insert the new column
		var redVal = $(this).children('td:eq(3)').html(); // get current column value
		if (redVal && (redVal.toUpperCase().indexOf('COLOR=RED') > -1 || redVal.toUpperCase().indexOf('COLOR="RED"') > -1)) // if it's red
		{
			redVal = $(this).children('td:eq(3)').children('font').text(); // get the actual value to write
			$(this).children('td:eq(2)').html('<span style="color: red;"> '+redVal+'</span>'); // write to the debit column
			$(this).children('td:eq(3)').html('nbsp;'); // erase the credit column
		}
	});
});

Now this doesn’t give me beautiful xhtml, and I’m never going to feel happy about how this works, but it does the job.

Fun stuff.

Getting Somewhere

My last post talked about how I wasn’t getting anywhere with my project.  Well now I am.

I might have mentioned that I’m using php and while it’s pretty easy to do stuff, I sometimes feel uncomfortable with the looseness of it all.  If you’ve used php in addition to a “real” OO language, you’ll know what I mean.  Lots and lots of globally-accessible functions with no namespaces, duck-typing, all that sort of stuff.

So I’m following some better practices (as suggested by Jon in his comment on the last post).  Nothing is very groundbreaking and I’m sure most newer php projects use the same kind of things.  Anyway, here’s what I’m doing:

I’m using an ORM library to get from my database to my code and vice versa.  Specifically Doctrine.  I’m reasonably familiar how these things work having used NHibernate for .Net (a port of Java’s Hibernate), but I’ve been impressed with how easy it’s been this time.  I got Doctrine working beautifully for my spider-web of a MySql database inside an evening with no experience.  I’ll let you know how it works out in the long run.  And yes, MySql is the database right now but Doctrine allows it to change very easily as expected.

I’m using an MVC pattern so my code doesn’t get too mixed in with my UI.  Now I’m sure there are plenty of libraries and frameworks out there that would help me with this, but I’m rolling my own… if you can call it that.  I’m used to .Net’s code-behind method so I’m really just copying that to an extent.  Each php page will have an include at the top that references the code-behind.  The “code-behind” php file will set up all the data and will provide functions that can be called by the front one.  Simple, but it should be effective.

Finally, I’m using JQuery for UI prettiness.  I had a serious look at a lot of javascript libraries and JQuery came out on top for what I needed.

So that’s it.  That’s what I’m doing.  So far it’s all fitting together quite nicely, but I’ll be sure to post updates if I want to rave about something or if something sends me into a fit of frustration.

As always, comments are welcome.

Damian

Next Page »