• 2010-04-09

    Unit Testing Aspects

    Something that I haven’t really run into is how to unit test an aspect - given how unique the circumstances are required to invoke such an event, I was at a bit of a loss. After some thinking and trial/error, I came up with a cut-down version of what the application uses - a limited Spring configuration, the Spring test suite, JUnit and a lot of assertions.

    The Spring config is actually pretty trivial, as most of the magic happens using Annotations (@Component, @Aspect and @Order) - very little configuration lives in an XML file. Since I use Spring 3, I might even do away with the config file - we’ll see how that goes.

    The interesting part is the unit test, which you can see here:

    I use the Spring test runner, which means I can inject my configuration file, and can also autowire the necessary objects. In this case, I’m injecting a user DAO along with the Ehcache manager. My test then invokes the DAO and checks to see if the item was actually cached. Pretty simple, but took a while to get right. The one caveat is that you need to turn off things like Terracotta, or else things may be considered valid when they actually are not.

  • Comments
  • 2010-04-08

    Drink the Kool-Aid

    “Perhaps the best announced feature of iAds, though, is that it doesn’t take you outside of the app you’re using to view the ads. Dismiss the ad whenever you want, and you’re right back where you left off.”

    Seriously?  This is the best announced feature of an advertising platform that can ram things down to you at will, probably blocking the entire UI until you dismiss it?  Gee, thanks!

  • Comments
  • →

    Code Attrition

    Given my day job as a software developer, I tend to get asked random questions by family and friends about computers.  On this occasion, my dad was asking me how to make some C# code work, since he’s working on a C# based project.  I popped open the project in Visual Studio, noticed that it compiled, and ran it.  It fires up a window that asks you what directory you want to search in, and what file type(s) you want to search for.  You click the button, and off it goes.  Relatively simple, as they go, though I took off points for not using a standard dialog box to select the directory, and the lack of recursion.

    I selected a drive, I selected a folder (separate fields, wee), entered a pattern (“*.txt”), and hit the button.  Immediately, I got a nice UnauthorizedAccessException - something that I haven’t really dealt with, as the last time I seriously used C# was probably in 2003/2004, back when .NET 2.0 was just showing up.  I threw in a try/catch around the offending block, and gave it a whirl.  “No files found.”

    At that point in time, I had the usual conundrum: do I spent time trying to figure out what the person in 2001 was thinking, and then what the person in 2010 who “cleaned it” actually did?  Or, did I just bite the bullet, create a quick new project, go spelunking in the .NET 4 API docs (yes, I have Visual Studio 2010) and find a better way?

    I went for the latter.

    Here is the result (click for bigger):


    I have less stuff going on in mine since I wrote a Console app, but still.  It shouldn’t be that hard.

    Hat tip to Jamie for the title.

  • Comments
  • 2010-03-29

    Bullying and You

    Read this and tell me why District Attorney Elizabeth Scheibel (the ‘she’ in the following quote) needs to re-think her worldview, especially in light of the fact that they could probably have saved somebody from suicide.

    She said the investigation looked at whether the adults’ failure to help Phoebe amounted to criminal behavior.
    “In our opinion, it did not,” she said. “Nevertheless, the actions or inactions of some adults at the school are troublesome.”

    Read the full story here: http://bit.ly/axCKDR.

  • Comments
  • 2010-03-28

    NoSQL vs. SQL

    The backlash against NoSQL has begun!  After enjoying a solid rise in popularity over the last 12-18 months, people are starting to fight back.  The problem is that, as always, people are missing the point.  NoSQL became popular quickly because it addressed an area that DB servers do not: scalability.  Of course many businesses have been running on database servers and have managed to scale them to handle huge volumes of requests and data - they just paid a LOT of money to do so.  NoSQL allows your average bootstrapped startup to do the same thing with a far smaller out of pocket expense.

    For example, let us consider a serious Oracle setup - I’m using Oracle because most companies feel that if it doesn’t cost them an arm and a leg it isn’t good.  Personally, I’d suggest PostgresSQL, but hey.  Creating a single Oracle DB server that will support 10k TPS will require a hefty outlay to by a dual CPU server with a very large/fast IO subsystem.  When you start hitting the ceiling with the single node (and realize you have a nice single point of failure) you start looking at things like Oracle RAC.  Now you want to play in the big leagues!  You buy a second server, upgrade from a local RAID 10 to a SAN, and pay Oracle more money.  Now you can handle more transactions!  Every time you hit the ceiling, you can try to grow your RAC by adding nodes or updating servers to more powerful hardware.

    NoSQL takes a different approach to this problem.  Instead of requiring expensive hardware and software, it leverages commodity hardware and free software.  You can now achieve scalability on a far more modest budget.  There are tradeoffs, of course - the application you write has to know how to join the data, data is synchronized ‘eventually’, etc, etc.

    In the end, there shouldn’t be any real fight - each technology addresses a very different problem; both technologies can co-exist and grow.


  • Comments
  • 2010-03-01

    DSi XL

    “Many gamers only play their Nintendo DS games at home—in bed, in front of the TV while their parents or spouse watch something they’re not interested in.” - http://bit.ly/dBuRNf

    I play mine while I’m at the PC waiting for games to load, or while doing something in EVE and there is no action. Gaming while waiting for games.

  • Comments
  • 2010-02-16

    Wicket Bug

    I’ll have to file a bug report for this, since it is so interesting, though more investigation is required to see how pervasive it is.

    Generally, when I use Wicket, I don’t use a FeedbackPanel to display error messages to the user. Instead, I use a FormComponent.IVisitor that walks through all the FormComponents for the form that was submitted (via AJAX, natch). Each component is check to see if it is failed, enabled, and required, and then pulls the error message from the component.

    That message is then fed back to the browser via the AjaxRequestTarget as a call to a JavaScript method that’ll pop up an error, or whatever special sauce I require. Usually I pass back the ID of the failed element and the message, and then use jQuery to build some sort of error bubble.

    While implementing the above, I ran into an interesting bug - this part gets a bit technical, so I forgive you if you click away. I have a Wizard that renders a form containing DynamicWizardStep. The DWS then has a RadioGroup with a DropDownChoice embedded within it.

    Here’s the bug: if I hit the “next” button on my wizard, both (required) components fail. That’s expected - the unexpected part is that the RadioGroup error message is… null! If I move the DropDownChoice outside of the RadioGroup, both work properly again.

    Now, it isn’t great design to nest one within the other (I did fix that part), but the lack of validation message is just weird. It does fire the validation, just loses the error.

    I wonder if I can make a quickstart for that…

  • Comments
  • 2010-01-02

    HTML5 - Expanded

    My HTML 5 tweet needs a bit of expanding - one that 140 characters won’t allow for.

    One of the blogs I follow is Dive into HTML5 as it provides some great insight and explores some of the new features that HTML5 provides. The most recent entry (that I read) was called A Form of Madness, detailing the new input types that will be brought to the table. As a (terrible) web designer, these fields interest and excite me - it’d be great to have the browser take care of stuff for me.

    However, that is where the problem lies - relying on the browser, especially on the browser supporting the feature. Having it degrade nicely is awesome, but the fact that apparently no browser with a large market share (Firefox or IE) supports any of the HTML5 features (in a production release) means that I just don’t have the energy to bother. As you read the article, you’ll see that there are little boxes showing the different browsers currently available, and their level of support for the HTML5 feature/field - notice that the only ones that support them are Safari 4, Chrome (which version?) or Opera (again, which version?). Combined, let us say that they cover 15% of the market (and I’d say I’m being generous with that) - that means that 85% of the people visiting your website will have a completely different experience. So, as always, the question is: cool technology, or building my site so that the majority all see the same thing.

    Age old conundrum, I know.

    On a side note, would it be wrong to suggest that the people running Chrome/Opera/Safari are the ones ahead of the curve and usually the people you don’t have to worry about? Ah, the joys of stereotypes! I don’t use any of those browsers - I’m still using Firefox 3.5 quite happily, since I’m ever so plugin happy.

  • Comments
  • 2009-12-29

    µTorrent UI Changes Bad Idea

    The new µTorrent UI just doesn’t do it for me; replacing the ‘play’ start button with that weird up-down icon, the other icons, the menu bar style itself - they just don’t fit well together. Changing a UI to make it more functional is one thing, but breaking something that was pretty perfect makes no sense to me.

  • Comments
  • 2009-12-02

    Math Problem

    If Ana leaves point A at 9AM and Michael leaves point A at 9:50AM, what speed is Ana’s fist moving at when she hits Michael for arriving at point B at the exact same moment?

  • Comments
→