Jamie & Lion

Month

September 2011

2 posts

Class’s and behaviors: thoughts on elegance.

Elegance, or, simplicity, or as some have call it “the right way” is something all developers strive towards. The feeling of developing a clean, tight, and elegant solution to programming problems is something we all enjoy.

Today a thread came up on twitter which opened the topic so i decided it would be time to get some of my thoughts down. This is very much a first thoughts on the topic and i am really interested in discussion.

The problem that triggered this topic, was about how to open external links in new window… my favorites solution is a mix of a class (external) and some javascript.

Elegance, thought hidden complexity is not real elegance.

One of the suggested solutions was to use a clever jquery selector, it simply identified any links where were not relative. This is a very clever solution, its superficially clean and elegant. However, on closer inspection i feel uncomfortable about it.

The reason is thus, simplicity and using things how intended is important for something to be elegant. In the world of standards we have an in built way of identifying hooks for behaviors and styles. Which is simply the class attribute.

Im my opinion as long as a class is semantic and meaningful then it makes sense to use one. Even more so if the class in question will also be used for styling the external. Though, at the same time, we need to be careful not to litter our code with meaningless classes or going class crazy.

By using a class attribute with the value of “external” then we have have our hook for both styling and CSS. Its not heavy markup, its flexible and it makes sense in the context. Another side effect is that i makes the markup link into the script in a easy to follow and understand way. By looking at the markup and seeing the class i can easily see how the open in new window functionality works. It provides more context to the solution.

1: Its brittle - it will give false positives when using absolute URLS. And coding around this flaw makes the solution less elegant.

2: Its needlessly complex. It hides the complexity within the jQuery source code but it is a very heavily solution. just because the complexity is hidden does not mean that its not there. Using a simple class is less complex, and thus i would feel the better solution.

3: its not easy to see. As i have mentioned above, its more complex to see the relationship with the markup and the code. If i was investigating how the clever jquery worked i don’t really have any clues. I will have to read all the source code or look for comments. Using a class of external, i can simply search the JS for the class name and then find the related script.

class=”external” is not perfect tho

For one, its added weight to the page. It makes pages heavier and means that external links need to be marked. This adds some complexity to any backend code and slows the page down a little.

So, theres my thoughts. Please feel free to shares you in the comments or ask any questions.

Sep 27, 20112 notes
Living with the MacBook Air, 8 months on.

I purchased my 11” MacBook Air back in January after a period of consideration. I brought it primarily too be my personal machine. For my university work and for my personal computing needs such as managing my photos, chatting online and using social media. I thought after 8 months of hard use i would report in on how the Air is to live with day to day.

SSDs are fast, but you get use to it.

When i first wrote about the MacBook Air one of my first take away points was that the Air is an extremely fast machine. While its CPU (a 1.4ghz Core 2 Duo) is not to quick the SSD makes it snappy for most tasks i use it for. This too largely still holds true, except that over time i have gotten use to the speed of the SSD and now everything else feels slow.

Over time i have gotten use to the speed and this has taken the edge of off the amazement. I am now use to the speed and expect it from every machine i use. 

RAM trumps hard drive space.

When i brought the Air i was torn between the 64gb SSD + 4gb RAM model, or the 128gb SSD + 2gb RAM model. My worry was based around how much space i use for storing my personal photo collection. With the macbook being a mostly sealed system i wanted to ensure that i did not run out of space.

In the end, i went for the larger SSD at the expense of the RAM. The model with the higher RAM was not available and this should have been a hint to me that more RAM going forward would be worth the expense.

My worries about space have so far proved unfounded, in the 8months since i purchased the Air i have only used 41gb of disk space. However, the Air is low on RAM and will get into difficulty when running multiple heavy applications (iPhoto + iTunes + Safari with 15 tabs etc). As the RAM is soldered to the logic board  it cannot be upgraded, the SSD can. 

Avoid beta software unless your brave & willing to accept issues

I am an OSX & iOS developer so i had early access to the OSX Lion beta. The Air was only non production machine i could install it on so i installed it a few months before lion was eventually released. On the whole Lion is extremely smooth on the Air but there are a few limitations which cause me much frustration. For example, broken screen zooming (requiring a restart to resolve) and patchy WiFi issues. I understood what i was letting myself in for when i installed the Lion beta, but in hindsight it would have been better if i had not. As my personal machine, i want a machine that works, installing and fiddling with beta software is too close to work for me.

With me all the time, use every day.

Although my uses have changed since i purchased the machine, one thing which has held the machine in good stead is its portability. Originally i was expecting to use the machine for 2 years more of university, in the end i took and early exit from university and took a job. However, the Air comes into work with me everyday. I use it at lunchtime and for managing my social life. Its become the computer i take most places. So much so, that i am writing this on a train back from a training event! Which leads on to my final point.

Better than the iPad.

While i do love the iPad, the Air, for me is simply better as the one item i carry with me all the time. The iPad mostly stays at home and is used to consume media / web browsing. However, when mobile i vastly prefer having a proper keyboard and mouse and using the touch screen interface for writing is a miserable experience!

The Air is so far my favorite computer i have ever owned, its very portable, fast enough to be useful, and after 8 months of use continues to impress me daily.

Sep 18, 20119 notes
#macbook air #review #apple #2010 #ssd
Next page →
2011 2012
  • January
  • February 5
  • March 3
  • April 1
  • May
  • June
  • July
  • August
  • September
  • October
  • November
  • December
2010 2011 2012
  • January 3
  • February
  • March
  • April
  • May
  • June 1
  • July 2
  • August
  • September 2
  • October
  • November
  • December 1
2009 2010 2011
  • January
  • February
  • March
  • April 2
  • May 10
  • June 1
  • July 1
  • August 4
  • September 1
  • October 1
  • November 1
  • December 5
2009 2010
  • January
  • February
  • March
  • April 5
  • May 2
  • June
  • July
  • August 2
  • September 1
  • October 1
  • November
  • December