It’s condescending AND informative.
IE6 denial message for Momentile.com
Pro commenting tip
Here's a little, mostly useless tip. If you need to toggle between two blocks of code (for example, comment out a block of text and replace with debugging values, and then switch back again), instead of doing it like a noob...
.. use this technique instead:
Now all you need to do to switch back to the other block is add a single slash to the first line:
$myArray = $database->getObject();
$myOtherArray = doSomethingElse();
/*/
$myArray = array("foo");
$myOtherArray = array("fu", "bar");
//*/
Javascript Packer, again!
I just had a complete "duh" moment while thinking about the Javascript Packer thing I developed extended, as one is apt to do. I'd linked to the source code here in an earlier post (which also describes the functionality of the tool), but that's just way too static, man!
I've now created a public space (for free!) at Assembla, which you can access through a number of methods. The first is to just head to the code page at http://code.assembla.com/packandroll/ and click the download button. The super-1337 way to do it would be to get a checkout of the repository: http://subversion.assembla.com/svn/packandroll There's no username or password required to view and download the code, but you won't be able to commit any changes. If you do take a look at the code and decide you want to improve upon it, please let me know and I'd be happy to give you write-access to the repo.
So anyway, have fun now.
PHP6 Namespace Separator hate
PHP6 will introduce a long awaited feature: namespacing. It should have been a joyous occasion for the PHP developers across the interblogosphere, but for one thing: the namespace separator is a backslash \.
A quick search for information about and reactions to this shocking revelation returns headlines and comments such as:
PHP is going to use backslash (\) as a namespace seperator? lame
Set sail for fail (php namespaces)
I personally tend to think of php as a social experiment and I'd suspect php creators to be psychologists in disguise. I'm pretty sure somebody of them is writing his PhD thesis on tolerance of developers towards "questionable" design decisions & how far you can push it.
I'll admit that my first reaction to the news about it was a bit negative. It seems strange to use the escape character for this purpose. Then I started considering what I'd choose instead. Then I started thinking about what is actually so wrong about the backslash.
As mentioned in the RFC discussion, \ is easy to type (on US layout keyboards anyway); it's one character; in the Windows world, it's already known as a hierarchy separator; and it's not that different to the forward slash which is universally known as such. The original idea was to use :: but it was thrown out because it could lead to collisions and ambiguity, given that it is already the static method operator.
That is, this is the ambiguity you'd run into:
static function bar() { }
}
namespace Foo;
function bar() { }
Foo::bar(); // what is being called here?
A common response to this is that you'd have to be an idiot to do this in the first place. Maybe so, but you often don't have a choice when it comes to the skill of a predecessor or 3rd party developer. Avoiding ambiguity is paramount in my books, and the PHP team agrees. A different character is needed.
A commenter on Ninh's blog wrote:
And this is (one of) the many reasons PHP sucks:
Java:
Attribute/Method access: foo.bar
Static method access: Foo.bar
Package access: foo.bar.bazC#:
Attribute/Method access: foo.bar
Static method access: Foo.bar
Namespace access: foo.bar.bazPython:
Attribute/Method access: foo.bar
Static method access: Foo.bar
Module access: foo.bar.bazPHP:
Attribute/Method access: $foo->bar
Static method access: Foo::bar
Namespace access: foo\bar\baz
Is it just me, or does this actually make PHP look the easiest to understand? If I see -> I know we're talking class methods or attributes, :: means static methods, and \ means namespaces. It really couldn't be simpler. This is in line with PHP's mandate that variables start with a $. Sure it might not be necessary, as proven by C, Java, Python, Javascript (etc etc), but it sure helps me see what a particular line of code does.
Another argument against it is that it's going to be confusing in strings.
$namespace = "mystuff\\table\\row\\neat"; // win
$namespace = 'mystuff\table\row\neat'; // win
Please someone tell me what is so hard about that. Escaping characters is not an uncommon thing to have to do in PHP and shouldn't be an issue.
PS: Using \ as selector is UGLY.
Oh come on, get over it. It's just a character and is no more ugly than $, /, ::, -> or anything else, you're just not used to it.
The whole thing reminds me of the blog rantings when Nintendo renamed the Revolution to the Wii. There's a big hoo-haa and then once you get used to it, you realise it's just a name (or a character in this case), and everyone moves on. The sooner that people will stop their whining about how "lame" a character is, the better.
The evolution of a UI
Windows 95 Disk Defragmenter:
Initially a very simple view with a progress bar, clicking on Show Details revealed a very confusing view of the individual clusters on your disk, coloured so you can see which are part of a fragmented file, which are empty, etc.
Pros: Simple GUI, with the option for an advanced view. Showed exactly what the tool was doing, and you could estimate how much longer it would take.
Cons: Lacked an overall view so you could see at a glance how fragmented your disk was and how much you needed to defrag. Perhaps a lot more technical than anyone actually needed.
B-
Windows XP Disk Defragmenter
Pros: Easily select any disk, and you can analyse the disk to see how badly in need of a defrag you are. The view lets you see the whole disk, and does away with the far-too-detailed cluster view. As the tool runs you can see the stripes change and then even compare a before and after. A report at the end tells you which files couldn't be moved and gives some statistics.
Cons: It's difficult to say - I really can't actually think of anything wrong with this. Some people may desire a much more technical view, but it found a really good balance between being easy and being informative/useful.
A-
Windows Vista Disk Defragmenter
Pros: Simple (only one button). Easy access to the scheduler (still possible in previous versions, but via a different interface).
Cons: All the useful information... and I do mean ALL the useful information has been removed. You get no idea of how badly you need to run a defrag, how effective it was or even how long it will take. The only information you are given is a spinning "wait" cursor and a message which reads "This may take between a few minutes to a few hours." There's no advanced view. You can't do an analysis before starting. You are given no reports or updates. You just wait and wait.
Update: I forgot to mention as well: the Vista defrag doesn't even allow you to choose which drives you want to defrag, it just does them all. This is especially annoying users like for me who have partitioned their hard drive into a small C drive with just Windows and programs on it (where you really do want to avoid fragmentation), and a large D drive for file storage, music, videos, etc. I'd really like to just quickly defrag C once a week or something, and only bother with the lengthy defrag on D once a month.
F
Windows 7 Disk Defragmenter
Windows 7 sees a vague return to form, adding a (sadly text-only) progress display for each run, and allows to just analyse without defragmenting whilst keeping the easy access to scheduling.
C
It's baffling to see how the tool was improved and then ... well... nerfed so badly over progressive versions. It makes me wonder about their motives in design. Was it perhaps a response to the Apple philosophy of making it super simple? Whatever it was, it's a lesson that not every change is a good change. If you are going to push towards simplicity in design, don't do so at the expense of functionality. If you're REALLY set on making the interface as clean as possible, then hide the "advanced" view behind a button click or something. Users like me don't mind having to go through a couple of menus to get what they want, but they really hate having options taken away for no good reason.
Google Street View idea
A little while ago, I had an idea to do with Google's Street View. In Google Maps, you can already input two or more destinations and it will give you driving instructions on how to get there. From there, it seems an almost trivial step to link that with Street View, so that it gives you a video of the journey.
As usual, I didn't actually take my idea further than that, but thankfully someone else did.
Joelaz does mention in the comments that this was recorded just by manually clicking through the pictures while recording the screen. Converting this to be automatic would be pretty sweet.
Stack Overflow, Answer Astronauts and Groupthink
Stack Overflow is a programming Q&A website (think "Experts Exchange" but not rubbish) launched last year, the brainchild of Messrs Atwood and Spolsky. I've been slightly addicted since day one of the public release (the count currently stands at 150 questions and over 500 answers), so I've been there, I think I grok it pretty good.
It's insanely good for when you want to know something that you know should be simple, but you just don't know it yet: for example, How to make a field NULL using MySQL GUI Tools?, but it has a few shortcomings which are a direct result of it's best feature: reputation. When you write a question or answer (but mostly an answer), and others like what you've written, they can vote it up. Each vote gives you "reputation points". The more rep you have the more moderation you can do on the site -- up until a point where you have all the extra features there are and now it just becomes a competition to see how high you can go. Like I said, this is its best feature, in that it completely incentivises community participation and the exchange of valuable information, but it does have a nasty side effect: everyone wants to write the BEST answer.
How is this a bad thing?, you're probably wondering. To borrow and mutate a term, I feel there's a certain group of users which I have dubbed the "Answer Astronauts". Spolsky first wrote about the "Architecture Astronauts" in 2001, and the semblance to my own astronauts are uncanny:
That's one sure tip-off to the fact that you're being assaulted by an Architecture Astronaut: the incredible amount of bombast; the heroic, utopian grandiloquence; the boastfulness; the complete lack of reality.
Remember that [these] people are solving problems that they think they can solve, not problems which are useful to solve.
Ask a question about how best to include variables in some HTML string, and you can be sure to get a smug answer telling you to use a templating engine. Ask how to find the page coordinates of an element in javascript, and you'll be told to "just" use jQuery or Prototype. How best to use the mysql_query() function? Easy: don't ever!! And my absolute favourite: ask what's the most efficient way to do X and you'll get a dozen people screaming "premature optimisation" in your face. Pick your standard "best-practice" and that will seemingly always find its way to the top in a glorious self-fulfilling prophecy.
God help you if you make up a code sample to illustrate a point. Every character will be analysed and picked on: "With variable names like that...", "'For' loops should be written like this...", and so on.
I dunno, maybe they're right. Technically, they're not wrong. It's just that sometimes all I want is an answer to my question, not a thesis demonstrating where I went wrong.
However, the thing which really irks me is that at times many of the proffered answers display the qualities of groupthink:
Groupthink is a type of thought exhibited by group members who try to minimise conflict and reach consensus without critically testing, analyzing, and evaluating ideas. Individual creativity, uniqueness, and independent thinking are lost in the pursuit of group cohesiveness, as are the advantages of reasonable balance in choice and thought that might normally be obtained by making decisions as a group. During groupthink, members of the group avoid promoting viewpoints outside the comfort zone of consensus thinking.
If you've been on Stack Overflow long enough, you'll know exactly how certain questions and answers are going to get voted, and because of this, it disincentivises saying anything else even if it's the best solution. Minimising conflict and reaching consensus is how you win in this game.
All of that said, I do not want to end on a sour note, because Stack Overflow has been the single most useful resource I've had since it launched. There are literally hundreds of really amazing programmers out there, all doing their bit (get it?) to help others and the community as a whole. I've learnt a lot more about my craft and have definitely advanced my skills because of having such a quality asset handy. It's also been fun! I don't know if it's just me, but I get a real kick out seeing a particular user's questions as they get through their project, and you can be there giving pointers along the way. I really like it when a lowly ranked user gives a great answer and I can be the first one accept it, the first one to say that their ideas are the best. Personally, I still get a tiny thrill to see that one of my answers has been accepted, too.
Stack Overflow has realised so much of its great potential so far, and I'm sure that it will continue to grow in the future. I just wanted to get off my chest a couple of my little pet hates about it.
Annoyance of the day, solved!
Photoshop has been really annoying me lately. Opening or creating a file of any size (even 8x8 pixels), would take upwards of 10 seconds. The computer I'm on has 4GB RAM, on an Intel Core 2 Duo 2.4Ghz with plenty of available disk space, so this shouldn't be happening! A bit of searching about found the unlikely culprit: I had a network printer set up as my default printer. Changing my default to a local printer solved the problem instantly.
Bizarre.
jQuery: Select adjacent elements
Just a quick post to say that I've put together another somewhat-handy jQuery plugin which I call "Adjacent". It simply selects the consecutively adjacent siblings of the current element which match a given filter. The demo page gives a better explanation and, obviously, a demo too. You can download the source from the jQuery plugin project page.
jQuery: Select ALL previous/next nodes
jQuery has a number of helpful functions to traverse the DOM tree (children, parent, parents, siblings, prevAll, nextAll), though there was one which I thought was one 'axis' which was strangely absent. The prevAll and nextAll functions just select the previous and next siblings of the current element. What I wanted was to find ALL nodes previous and next to this element, even if they are ancestors, descendants or anything.
$.fn.reverse = function() {
return this.pushStack(this.get().reverse(), arguments);
};
$.each( ['prev', 'next'], function(unusedIndex, name) {
$.fn[ name + 'ALL' ] = function(matchExpr) {
var $all = $('body').find('*').andSelf();
$all = (name == 'prev')
? $all.slice(0, $all.index(this)).reverse()
: $all.slice($all.index(this) + 1)
;
if (matchExpr) $all = $all.filter(matchExpr);
return $all;
};
});
});
Including this script will give you three new functions on the jQuery object: reverse() (which simply reverses a jQuery set), prevALL() and nextALL() (note the case).
Usage is pretty simple and in keeping with the other selectors:
.prevALL('div')
.html("A div before myElement")
;
$('#myElement')
.nextALL('a:first')
.html("This is the first link after myElement")
;
Just like prevAll(), the order of the elements returned by prevALL() is "backwards", that is, nodes closer to the original element will be at the start of the result set.
Update: I've submitted this into the jQuery plugin repository, so you can download it at the project page, and also view the demonstration page.
Recent Entries
- IE6 denial message for Momentile.com
- Pro commenting tip
- Javascript Packer, again!
- PHP6 Namespace Separator hate
- The evolution of a UI
- Google Street View idea
- Stack Overflow, Answer Astronauts and Groupthink
- Annoyance of the day, solved!
- jQuery: Select adjacent elements
- jQuery: Select ALL previous/next nodes
Recent Comments
- Damo in Pro commenting tip
- Recent URLs tag… in Javascript namespace error
- Fisher in Google Street View idea
- Damo in Google Street View idea
- Damo in Google Street View idea
- Bookmarks about… in Computer Synchronisation
- Damo in Annoyance of the day, solved!
- jQuery: Select … in jQuery: Select ALL previous/next no…
- Remmrit Bookmar… in Bravo, 37signals!
- Ashims in The best recovery disk you'll ever …
Categories
Archives
- June 2009
- May 2009
- April 2009
- March 2009
- January 2009
- December 2008
- September 2008
- July 2008
- June 2008
- April 2008
- March 2008
- December 2007
- November 2007
- September 2007
- August 2007
- July 2007
- May 2007
- April 2007
- March 2007
Pages
Blogroll
- Bob Dot Spadgos
- Chris Dot Spadgos
- Fisher Dot Spadgos
- Furious Steals - Highly destructive UT2004 racing mod
- Marshmallow Duel - The 1996 cult classic and delicious fan remakes
- NB Dot Spadgos
- Pospi Dot Spadgos

