Try-Catch-FAIL

Failure is inevitable.

Vote for me at CodeStock!

clock March 12, 2010 03:21 by author Matt

Voting is now open for CodeStock 2010 sessions!  I have three sessions submitted this year.  If you live in the Southeast, this conference is a real steal.  Early registration is just $55.  That’s $55 for a two-day conference, “buffet style” lunches, and a shirt.  Not bad!  If you register early, please consider voting for my sessions if they sound interesting to you:

Reducing Coupling through Inversion of Control, Dependency Injection, and Event Aggregation with StructureMap

Adding powerful search capabilities to your application with Lucene.NET and NHibernate Search

Improve your unit tests - a practical guide to Moq

Also be sure to check out James “poprhythm” Kolpack’s sessions as well:

Parallel Computing in .NET 4 with Visual Studio 2010

Windows PowerShell Introduction

Thanks, and I hope to see you at CodeStock!

Share or Bookmark this post…
  • del.icio.us
  • DotNetKicks
  • Digg
  • msdn Social
  • Reddit
  • StumbleUpon

Currently rated 4.0 by 1 people

  • Currently 4/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


A Newbie’s Experiences with NDepend

clock February 4, 2010 11:10 by author Matt

Disclaimer: Yes, I was given a pro license to NDepend.  However, what follows are my honest impressions of version 2.12.1 of the tool on a real .NET 3.5 project.  I have not evaluated the recent beta, so some of the issues noted below may be fixed in a more recent build. 

To Patrick Smacchia: I apologize for taking so long to provide feedback on NDepend.  I hope you find the feedback below useful.  Thanks for giving me the chance to check out this cool tool!

NDependHome

NDepend is a complex and powerful tool for static code analysis.  The basic idea is that you feed it your .NET assemblies, then you use the rich set of visualizations, Code Query Language (CQL) reports, and code coverage tools to analyze your codebase.  When I say “rich set of visualizations,” I mean it.  There are a slew of reports that are both eye-candy and useful at the same time.  Within a few minutes of analyzing my first project, I had already discovered useful information, including an obsolete class as well as a unit test that was missing it’s Test attribute. 

The power NDepend comes at a cost.  The interface is immediately overwhelming, and though there is ample documentation available online, it still takes a while to discover all the tool’s capabilities.  It also has a few quirks that can be irritating, and the UI feels a bit “glitchy” at times.  Despite these weaknesses, I found the tool to be immensely powerful (CQL is awesome), and I can definitely see where it will be handy in the future.  Read on if you want to know more.

Getting Started

When I launched NDepend, I notice that it looked and felt a lot like Visual Studio.  It had the familiar “Recent Projects” pane on the left as well as links to common actions.  There was a “Getting Started” pane with links to NDepend screencasts, and a button to install Visual Studio and Reflector integration.  It also had a pane that to let you know if an update is available, a small but nice touch.  I really like it when an application makes it easy for me to stay up to date.

Creating a new project was easy enough.  After creating my project, I was able to add assemblies using any of several methods.  I could drag-and-drop assemblies directly from Windows Explorer, I could add them manually by browsing, or (my favorite) I could add them by specifying a Visual Studio solution file.

Things took a turn for the strange here.  At first, NDepend reported that it was unable to load any of the assemblies for my solution.  It was nice enough to indicate why, apparently there were multiple versions of the assemblies buried in my solution.  After some digging, I discovered that I had built my solution under the AnyCpu platform a loooooooong time ago.  I had since switched to targeting the x86 platform, so I had some obsolete build output nested under my projects.  This same “error” occurred even when trying to load the assemblies manually; apparently NDepend was still detecting assemblies with the same name but different versions.  Once I figured it out, resolving the issue was easy: I just removed the obsolete output directories.  It would be nice if NDepend was a little smarter about loading assemblies, but at least it has good error messages.   

Even after resolving the version conflicts, I had trouble getting NDepend to load the console application from my solution.  I had to manually drag-and-drop the exe into the assembly list, at which point it recognized it just fine.

The “Getting Started” experience is flexible and intuitive, but there are enough issues to make the process mildly frustrating for a first time user. 

The Analysis

Running an analysis was surprisingly fast.  Granted, I’m on a hefty workstation, but it still seemed blazingly fast considering what it was doing.  The analysis generated an HTML report that included metrics, visualizations, graphs, tables, and the results of numerous CQL queries. 

The HTML report is great for sharing the output of NDepend or for reviewing the analysis offline, but the NDepend tool itself enables you to interactively analyze your application.  Be warned, though, that the default view can be overwhelming at first:

AnalysisHome

Even with high resolution monitors and the window maximized, this view is probably not going to be all that useful.  Instead, you will likely find one of the configured alternative views more useful, such as the Dependency Matrix view:

DependencyMatrix

I still found this view to be too cluttered, but like Visual Studio, NDepend’s UI is very customizable.  However, unlike Visual Studio, it took a lot of trial and error to get things laid out the way I liked.  The docking behavior seemed much more finicky than Visual Studio, and on multiple occasions attempting to pin/unpin an item would cause the layout to shift in unexpected ways.  Even resizing the window caused strange behaviors at times.  Still, after some massaging, I arrived at a less overwhelming layout:

SimplifiedView

One feature I’d like to see in NDepend is a “Save Custom View” command, that way I can save and restore my preferred layout for use in the future.  Why is this feature important?  Because it took me all of about 5 minutes to screw something up after getting my view the way I liked it, requiring me to “Reset Views” back to the default. :(

Overall, in my opinion the UI itself is the weakest area of NDepend.  Yes, it’s functional, but there are some very noticeable usability problems here.  I’m sure it is quite challenge to develop and maintain a UI that exposes all the capabilities of NDepend, but I think some additional work is warranted here.

Visualizations

While the UI might need some work, it doesn’t detract (too much) from what NDepend actually does really well, and that’s analyze your code base.  The “Metrics” visualization gives you a map of sorts depicting your project by whatever metric you are interested in.  Want to see your types by number of instructions?

TypeByInstructions

How about your methods by lines of code?

MethodByLinesOfCode

Or by cyclomatic complexity?

MethodByComplexity

I can also generate a nice map of my project dependencies (again, I can customize the visualization to emphasize different metrics):

DependencyGraph

These visualizations make it very easy to find areas of your project that warrant attention by simply glancing at the graphics.  Unfortunately, the usability elephant raises his head here.  A few things stick out worse than others.  First, the behavior of the “Export to PNG” button is consistently inconsistent between the visualizations.  On one view, the button brings up a dialog to save a snapshot to the file of your choosing.  On another, it instantly exports the file and loads it up in Windows Media Viewer.  I also had to make frequent use of the “Fit to Window” command on the Metrics visualization because I would accidentally click on the visualization, causing it to scroll unintentionally.  These aren’t things that are going to turn someone off of using the tool, but they are still problems that should be addressed. 

The rich visualizations make it easy to spot areas of your code base that need attention.  While there are some usability problems here, they’re pretty minor and easy to overlook.

Code Query Language

The final piece that I want to talk about is CQL and the library of built-in constraints and checks that ship with NDepend.  According to the website, there are 83 metrics available in CQL, and NDepend ships with queries to help you find potentially problematic areas quickly: 

CqlReports

As you can see, this particular project has quite a few issues I might want to look into further. :)  A cool feature of the CQL queries pane is that selecting one will update the “Metrics” visualization, with types matching the query highlighting blue as in the following screenshot:

CqlMetrics

This lets you quickly assess how wide-spread an issue is in your codebase.  For details, you can use the CQL Query results window.  Double-clicking an item in the results will open the corresponding location in your source code, so it’s very quick and easy to drill down from a CQL query to the underlying code.

One thing to note: many of the constraints that I checked were actually configured only to return the top 10 methods/types/whatever, so a constraint with a “10” next to it usually means “at least 10”. Keep that in mind as you are glancing through the constraints. 

NDepend does seem to count properties as methods.  While technically true (even auto properties are implemented as a pair of methods that access an automagically generated field), this can lead to unexpectedly high values for metrics such as “lack of cohesion” on types that expose many properties (such as view models in an ASP.NET MVC application). 

There were a few things that I couldn’t figure out how to do (yet).  For example, I wanted to build a CQL query to find all public methods that were part of a class marked with the NUnit TestFixture attribute who didn’t have a Test attribute applied to them.  I suspect that there is a way to express this query, it just requires someone better with CQL than I am. :)

The built-in CQL queries can help you find trouble areas in your code base as well as determine how systemic a problem is.  The syntax is clean and SQL-like.  There are a few things that are difficult (at least for a novice) to express using the language, but the built-in queries are likely to cover 90% of what you would want to look at anyway.

Things I haven’t tried yet…

My review focused on the visual version of NDepend.  NDepend also has a command-line version, an MSBuild task, and a NAnt task.  There’s also an XLST transform for using NDepend output with CruiseControl.NET.  Since NDepend generates a nice HTML report, it can easily be integrated into other CI servers as well, such as TeamCity.

NDepend also has Visual Studio and Reflector integration.  While I use both tools, I did not (yet) test out the integration. 

Overall

NDepend is a very deep tool with a lot of functionality.  I feel like I’ve just scratched the surface.  You will probably be hearing more about NDepend in the future as I continue to dig deeper into its capabilities. 

Share or Bookmark this post…
  • del.icio.us
  • DotNetKicks
  • Digg
  • msdn Social
  • Reddit
  • StumbleUpon

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


The New Year – 2010 Edition

clock January 6, 2010 10:36 by author Matt

Wow, it’s actually been (a little over) a year since I posted my goals for 2009.  Going back and re-reading those goals, I’m a little surprised at my goals, and saddened that I made so little progress. I thought it might be a healthy exercise to look at how I did in meeting each of my 2009 goals.

Goal 1: Get the new layout integrated into this blog.
This one isn’t completely my fault, only mostly.  My friend actually decided that he didn’t like the layout he did and wanted to make another one, and I think he hasn’t had time to do that yet.  Sadly that was in like June, which means I failed to integrate the previous layout into this blog for a full 6 months.  :(

Goal 2: Learn Silverlight.
Ack, I really dropped the ball on this one.  I looked briefly at Silverlight, and I did learn some WPF and XAML, but I never actually sat down and did anything with Silverlight.  I have no excuse other than I had no pressing need and insufficient free time to tackle this.

Goal 3: Learn XNA.
… :(

Goal 4: Continue to make 3 blog posts per week, minimum.
I didn’t keep up a 3-per-week average, but I did ok.  The readership on my blog (according to Feedburner) grew from ~20 to over 100, so I’m actually fairly satisfied with my performance on this goal.  Yes, I did fall short of the 3-per-week I set out to maintain, but I think I made some useful contributions on a fairly consistent basis.

Goal 5: Write more.
I actually nailed this one, but not in the way I thought.  Aside from finishing my thesis (a 100+ page monster of technical writing), I also contributed to and authored numerous research publications.  Sadly only one has been accepted so far, but at least I’m getting lots of practice.  I still would like to do some CodeProject articles, but that’s taken a back seat to other things for now.

Goal 6: Maintain a more positive attitude towards work.
Again, I feel like I nailed this one.  I think I’ve stayed very positive despite a bumpy year.  Hiring a good friend and great dev in James helped, but I still tried not to let things here get to me too badly.

Overall, I’m disappointed that so many of my goals fell by the way-side, but I’m not surprised.  I failed to account for a several things that should have made my list, including finishing my thesis, graduating (in only 3 full semesters), and becoming a new dad. 

Goals for 2010

Time to set up my apologetic blog post for 2011!  I decided to set fewer goals this year than last year:

Goal 1: Move forward on ideas for new products. 
I have had several product ideas floating around in my head for many months now, and over the years I’ve had several great ideas that I procrastinated on only to see others implement them and become wildly successful (I’m looking at you, Facebook).  I don’t want to endure the pain of seeing another one of my ideas make someone else rich, so I’m focusing on maturing my ideas in 2010.  Already I’ve fleshed out a small handful of ideas, and I plan to move forward aggressively with one in the near future.

Goal 2: Read more technical material.
I feel like I’m falling behind a bit in terms of technical knowledge.  It takes constant vigilance and dedication to stay on top of what’s going on in the research world in my field (Information Retrieval), plus there’s always new things going on in software development in general.  In 2010, my goal is to read more technical books (already finished up Head First Design Patterns, now working through both Taming Text and ASP.NET MVC In Action) as well as to stay more current on what’s being done in the research world.

And that’s it.  I do have additional goals not related to development (sadly “relax more” didn’t make the cut), but I’m focusing on these two big weaknesses and hope to have a more positive review of 2010 one year from now.  See you then!

Share or Bookmark this post…
  • del.icio.us
  • DotNetKicks
  • Digg
  • msdn Social
  • Reddit
  • StumbleUpon

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Useful snippets

clock December 28, 2009 11:27 by author Matt

I had two small “breakthroughs” while coding today that saved me quite a bit of time.  The first dealt with mocking HtmlHelper<T> with Moq for unit testing purposes:

/// <summary>
/// A mocked-out <see cref="HtmlHelper{TModel}"/> that can be used for testing.
/// </summary>
/// <typeparam name="TModel">The view model type.</typeparam>
public class FakeHtmlHelper<TModel> : HtmlHelper<TModel> where TModel : class
{
    /// <summary>
    /// Creates the fake.
    /// </summary>
    public FakeHtmlHelper(TModel model) : base(new FakeViewContext(), GetMockContainer(model))
    {
        
    }

    /// <summary>
    /// Gets a mock view data container that returns view data for the specified model.
    /// </summary>
    /// <param name="model"></param>
    /// <returns></returns>
    private static IViewDataContainer GetMockContainer(TModel model)
    {
        var dataContainer = new Mock<IViewDataContainer>();

        ViewDataDictionary<TModel> dataDictionary = new ViewDataDictionary<TModel>(model);

        dataContainer.Setup(c => c.ViewData).Returns(dataDictionary);

        return dataContainer.Object;
    }
}

(Note that FakeViewContext is a similarly-designed fake class, but it could also be a Mock object.)

With this fake helper, you can now unit test extension methods for HtmlHelper<T>. 

The second “snippet” I found useful today was aligning a group of divs.  The desired layout was something like the following:

inlineBlockGood

However, setting the divs to display to inline-block resulted in something like this instead, where the div with less content did not line up with the other divs even though their heights were all set to the same value

inlineBlockBad

A quick scan of the CSS spec got me pointed back in the right direction, and I used a vertical-align of top to achieve the desired layout.

Share or Bookmark this post…
  • del.icio.us
  • DotNetKicks
  • Digg
  • msdn Social
  • Reddit
  • StumbleUpon

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


A day in the life of a developer

clock December 9, 2009 09:03 by author Matt

I just got off the phone from a very frustrating conference call.  Today’s call brought to light something that I want to address.  It’s a misconception that many non-developers have about software developers.  I know this misconception exists because of the way I’ve heard people refer to our profession; because of the way non-developers in our industry often seem to treat developers. 

I think there’s a misconception that our days are filled with free time, that we relax and chill, and that our jobs are so easy that they don’t even qualify as real jobs when compared to most other professions.  I mean, we sit in a chair and use a computer, how hard is that??  Developers lead easy lives, right?

The truth is, most people have no idea what our lives are like.

Background

Before I begin, let me clarify my situation.  I’m married with a 7 month old baby.  I have a masters degree in computer science and am planning to begin work on a PhD next fall.  I work for a (very) small company that seems to be in perpetual startup mode, meaning we have few resources and just can’t seem to break in to the big money needed to grow a mature company.  Still, I genuinely enjoy my work.  I’ve become very interested in the business domain (information retrieval/knowledge management), and I like working here.  There are a lot of perks to working here, including being able to live in a very small town while getting paid decent money to write code. 

Up and out of bed…

Here’s how my typical day goes.  I wake up early, around 5:30. As I get out of bed, my mind starts swimming with partial solutions to whatever I was working on the day before.  As if by magic, my brain somehow manages to come up with useful solutions (sometimes) while I’m sleeping.  Once I’ve woken up a bit, I help the wife get the baby up and fed while we both get ready for work.  If all goes well, I’m out the door and at the office by 7:00.  I spend the first little bit catching up on E-mail, planning my work for the day, and reviewing what I did the previous day so that I’m ready for the 8:00 scrum.  I scan a few development blogs for useful articles, too, and tag things to read later if time ever allows.

Morning Push

From scrum time until lunch time, I’m doing development.  That may involve testing, it may involve design, and it more often than not involves coding.  This is not easy.  If developing good software was easy, everyone would write perfect code, but it’s not.  It’s very hard.  It’s mentally taxing.  Unless I’m interrupted for a meeting, this is my entire morning: working as quickly as I can to create an efficient, maintainable solution to whatever story (AKA a feature for those not in the development business) I’m working on so that I can move on the next story.  There is no slack time here.  I use a Pomodoro timer to help keep me on task, trying to address IMs, E-mails, and other distractions in my 5 minute breaks.  I occasionally get distracted, some days more so than others, but I do my best to stay focused on the task at hand.

Lunch != break time

At 11:00, I take a “break” to eat lunch.  Usually this involves warming up the meal I cooked over the weekend, then eating it at my desk.  I’ve started taking the time to read one research paper (or chapter from a relevant e-book) during this period, too.  The papers and books I choose are all things related to my job.  It’s not like I’m sitting around reading sci-fi books, I’m spending my lunch time trying to learn something that’s going to make me more valuable to the company.  After I’ve finished reading today’s paper/chapter, I return to whatever task I was working on before lunch (note that I’m usually still physically consuming my meal at this point; it’s usually around 11:30 now). 

Sometimes after lunch, the team takes a 30 minute break to do something recreational together.  Other days, we may all go out for lunch.  Occasionally, we will all eat lunch together while we watch a webinar.  Again, we choose webinars that are going to help us contribute more value to the company.

Afternoon Push

After lunch/break, it’s right back to development.  This mirrors my morning: I use a Pomodoro timer, try to stay focused, and drive on through until the end of the day.  Again, there may be meetings or other interruptions, but most of this block of time is spent writing code.  I sometimes take a break to write a blog post, but my posts are (almost) always related to work, and often are used as a way to get feedback on things we’re doing internally.  We have a fairly small team, so I use my blog to try to gather feedback from a larger audience (see: liteGrid). 

“Life” outside of work

“The end of the day” comes at different times.  A couple of nights a week, I train kick-boxing and jiu-jitsu, and on those days I’m out of the office promptly at 5:00.  The days where I don’t have something to force me out of the office, I often find myself texting my wife that I’m running late when the clock says 6:30.   When I return home, I spend as much time as I can with the wife and baby.  The baby is usually out by 9:00, the wife is usually in bed by 10:30 or 11:00.  I usually take the next hour or so to (you guessed it) do development work.  Depending on how behind we are, I may work on the same story I was working on when I left the office.  If we’re not “OMFGWTFBBQ” levels of behind schedule, I may work on something that’s directly related to an active story, but I usually still work on something that’s going to benefit my employer.  Lately I’ve been working on Esenterate, which I hope will be used in the backend of a future product.  I also work on liteGrid when time allows (again, used by my employer). 

I finally decide to go to bed somewhere around 12:00 or 1:00.  Sometimes its earlier, depending on how tired I am, but I’d say 12:00 is about the norm.  If I’m not too sleepy yet, I’ll open up the book on my nightstand (always a development book; always something that’s going to make me a more valuable asset) and read a couple of pages.  Then the alarm goes off, and it’s 5:30.  I guess I slept somewhere in there.  It’s time to wake the baby up. 

The end… ?

As I typed this, I just realized how pathetic my life probably sounds. :)  It’s really not that bad, and my intent is not to paint a bad picture of the work environment here (it’s not great, but not horrible) or my life. Sure, it’s not easy, but I enjoy my work, I still spend time with my family (and occasionally my friends), and I’m content.  The moral of this post is simply this: software development is not easy.

In the past, I’ve worked quite a few jobs outside of software development.  My first job was in fast food.  From there, I took a job as a farm hand.  As an undergrad, I worked in the campus print shop (running old-school machines, not doing design or anything that involved a computer) and also at a retail department store.  It wasn’t until I was a junior that I started actually getting paid to do development work.  I’ve also helped remodel a house (though I sadly wasn’t paid for it).  In my opinion, without a doubt software development is far more taxing than any other job I’ve ever had.  A day of hard work on the farm can be offset by a hot shower and a hot meal, but I’ve yet to find something that can so easily replenish my mind at the end of a hard day of coding (though Red Bull does provide temporary relief).  With any other job I’ve had, I could mentally “check out”, but I can never, ever do that while developing. 

What brought this on…

Sadly today’s conference call included us (the developers) basically being told that our estimate for building a product for a completely new platform that none of us have experience with was too high and vague, and that the estimate should be lower because we should have already used our free time (ie: not paid for) to learn the platform already.  I found this to be extremely insulting (on a lot of levels) and completely inappropriate.  Things like this have happened a few times since I’ve been here, and I ran into it several times while doing consulting work.  I’ve also heard stories from others in the industry who have encountered similar attitudes.  I hope that this post will serve as a reminder that a) developing software is hard, and b) software development is often a thankless career path.  If you encounter someone who says “oh man, you developer guys have it sooo easy in your air conditioned offices”, remind them that many of us (me) work in offices with no windows, and send them a link to this post. :)

Share or Bookmark this post…
  • del.icio.us
  • DotNetKicks
  • Digg
  • msdn Social
  • Reddit
  • StumbleUpon

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Stack Overflow Careers

clock November 5, 2009 03:13 by author Matt

Joel just announced the launch of Stack Overflow Careers.  Like most things Joel, this seems to be built around his idea of how the world should be, which is actually pretty cool, since in his world we’d all be treated like super stars.  I do however take issue with one of his statements:

Instead of submitting a resume, you’ll fill out a CV, which links back to your Stack Overflow account, so that you can demonstrate your reputation in the community and show us all how smart you really are. To a hiring manager, the fact that you took the time to help a fellow programmer with a detailed answer in some obscure corner of programming knowledge, and demonstrated mastery, is a lot more relevant than the Latin Club you joined in school.

Maybe I’m wrong, but I actually disagree.  I don’t think having an uber Stack Overflow reputation means that you’re a great catch for a potential employer.  In fact, I think it may mean the opposite.  Along the same lines, I don’t think not having 50 bajillion points on Stack Overflow means you are not knowledgable and skilled. 

Why do I say these things?  Well, the day consists of 24 hours.  Let’s assume you sleep for 8 of those (I know that’s probably on the high side for most of us).  Let’s assume preparing for and commuting to/from work eats up another 2 hours a day on average.  We’re down to 14 hours.  Let’s assume we don’t work for all of that, let’s say we spend 4 hours doing things outside of work.  That leaves 10 hours a day.  Let’s say I don’t work much overtime, so my employer gets 9 of those hours.  That leaves me with one hour a day.  Exactly when am I going to fit in time to read and answer 50,000 questions on Stack Overflow to rack up some serious reputation?  I don’t think people are doing it in the “free time” on Saturday and Sunday.  Are they doing so on the clock for their employers?  I bet most of them are.  While I agree that participating in Stack Overflow can be a good thing, I see people that spend entirely too much time on there.  If I was their employer, I’d be cutting their pay. 

If I’m an employer, I’m paying people to add value to the business, not to chit-chat with their peers. If I see a resume that lists a ridiculously high Stack Overflow reputation, I’m throwing that resume in the trash, because I’m pretty sure that person is going to spend more time on Stack Overflow than on doing real work.

Let’s look at someone else (me).  I don’t spend much time on Stack Overflow at all.  I lurk on quite a few mailing lists and forums, I follow several good blogs, and I read any spare chance I get, but I don’t participate much.  If I can’t find an answer to a problem through other channels (such as newsgroups, forums, and mailing lists), I might post a question or discussion, but that’s about it.  I don’t spend a lot of time participating because I’m too busy doing real work.  Simply put, while I’d love to participate, I don’t have time.  I’m too busy adding value to our products.

The same goes for Twitter and blogs.  I actually know of several cases where someone was hired partly because they had a lot of followers either on their blog or on their Twitter account.  If I see someone that’s hyper-active on either Twitter or their blog, I’m going to have the exact opposite reaction. 

Thoughts?  Am I being totally selfish to use Stack Overflow (and other sites) in a mostly read-only manner?  How exactly am I a worse dev because I don’t spend time on Stack Overflow grinding out reputation points?

Share or Bookmark this post…
  • del.icio.us
  • DotNetKicks
  • Digg
  • msdn Social
  • Reddit
  • StumbleUpon

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Why I will never, ever buy another Apple Macbook

clock September 28, 2009 05:00 by author Matt

If you came to my blog today in the hopes of finding useful content, you are going to be sorely disappointed, because I have decided to waste your time today by telling you how wrong I was to ever buy something made by Apple.  Before I do that though, allow me to bring you up to speed on what I was thinking when I made this mistake last year.

A (not so) long time ago, in the same place I’m sitting now…

I was enrolled in a master’s program at Tennessee Technological University, and the fall semester was just about to get underway.  I had been lugging around a Dell Inspiron 9400 the previous semester.  This Dell was indeed a desktop replacement.  It had a nice video card, 4 GB of RAM, lots of storage, and a big, 17” widescreen, 1920x1200 LCD display.  As you might can imagine, this thing was anything but lightweight.  I dropped it on the scale at home, and it weighed in at a whopping 11 lbs (approximately).  Combine that with books and a long walk across campus, and you have me wishing I had something lighter to carry.

At the same time this was happening, I suppose I was starting to succumb to the allure of Apple and their products.  Virtually everyone on campus was using a Mac in some form or fashion and raving about how great they were.  When I decided to buy a smaller laptop to replace my mega-Dell, I did something I usually don’t do, and I spec’d out a machine from Apple in addition to Dell, HP, etc.  I expected the Macbook from Apple to be significantly more pricey than one from Dell or HP, but after a large student discount, the Macbook was actually slightly cheaper than the Dell and HP models I was looking at.  The Macbook also came with a free iPod, which my wife wanted anyway, so I gave in to the Apple bug and ordered one.

“Hey, let’s make everything not do what you expect it to do!”

A few days later my new Macbook arrived.  Keep in mind that I wanted to love this thing.  I was already the target of ridicule from some of my “friends”, and I wanted to be able to tell them how Apple had improved my life and made me a better person.  Unfortunately that isn’t what happened.  Despite what everyone had told me, I hated Mac OS with a passion.  You can read some of the reasons why here, I won’t get into them too much right now.  After limping along with Mac OS for a while, I finally started dual-booting Windows.  This worked fairly well except for one big problem: Macs have a single freaking mouse button.  It is 2009.  Apple, 1985 called, they want their mouse back. 

You get what you pay for…

I managed to get by using the crazy-ridiculous put-two-fingers-on-the-track-pad-and-click-for-right-mouse-button-but-be-careful-not-to-move-your-fingers-at-all-or-it-will-think-you-are-scrolling functionality for the last year.  It’s annoying, but it mostly works (except when you move your fingers at all).  Still, I couldn’t help but feel like maybe the $200 or so I saved cost me a lot in usability.  The Macbook started to seem like it wasn’t such a great deal after all.

Fast forward to August of this year.  We decided to try out some virtual office stuff here at my day job, so I fired up my Mac in the hopes of using the iSight camera for video conferencing.  There’s just one problem though: the camera isn’t registering.  It isn’t registering in Windows, and it isn’t registering in Mac OS, it’s just gone.  After Googling, I discovered that this is actually a very common problem, and that the cables that connect the camera to the motherboard are notorious for coming unhooked.  “Oh well,” I thought, “I paid for the most expensive warranty option, so I should be able to get this fixed tomorrow.”  See, I had previously dealt only with Dell and HP, both of which have great support (not counting the time I got stuck with an operator who couldn’t speak English very well, but that only happened once).  With either company, I could call, describe my problem, describe how I tried to trouble-shoot it, and I would have either a new part or a service technician waiting for me on-site the next day.  Amazing, especially when you compare it to what you get with your Macbook…

“We’re sorry, we’re booked for the next three days, and you can only schedule an appointment three days in advance…”

That’s a paraphrased quote.  Let me explain it.  With a Macbook, you basically have two service options: pack it up and ship it back for repairs, or find an Apple Store and take it in to the “Genius” Bar, which is “Genius” in the same was as ramming your face into a brick wall.  I don’t live in a major city, so I was looking at a 1.5 hour drive to the nearest Apple store.  Still, I actually needed to go that direction anyway, so I called to make an appointment.  After waiting on hold for 15 minutes before talking to a person, I was told that I would have to reserve a 15 minute slot at the bar, and that there were no slots available on the day I wanted to come.  I asked when the next opening was, and she couldn’t tell me, because you can only book 3 days in advance, and they were full for the next 3 days.  So my only option was to call back the next day and try to schedule an appointment.  Compare and contrast this with a Dell CompleteCare warranty.  My brother just had his video card die in his Dell.  He called on Friday, and a guy just left our office an hour ago after swapping the LCD, the motherboard, and the video card.  In less than one full business day, he basically got a brand new laptop, and he didn’t even have to leave the office. That is how you do service.  Apple likes to think that they’re innovating, but requiring someone to mail you a computer or bring it in for service is what I went through in the early 1990s.  It’s not what I expect in 2009.

So long, Macbook, you’ve been many things, but a good laptop isn’t one of them!

At this point I decided to say “Screw it.”  Getting my webcam working wasn’t worth the hassle.  And no matter what, it wasn’t going to solve my main complaint, which is THE LACK OF A FREAKING RIGHT MOUSE BUTTON.  This weekend I dusted off my old Inspiron 9400, formatted it with Windows 7, and enjoyed being able to right-click without having to think about how to position my fingers on the touchpad.

I hope this post serves as a warning to anyone else who is tempted to test the waters in Appleland.  Everyone there will tell you how awesome and warm it is, but it’s only warm because the water is full of piss, and they only think it’s awesome because they want to feel special because they were conned into buying something Apple made.  There is nothing about my Macbook that I will miss, aside from the sturdy case and the lightweight design (both of which Dell does nicely now).  I am very happy to be shelving that thing for the foreseeable future.

Apple, keep on “intuivating” it!

Share or Bookmark this post…
  • del.icio.us
  • DotNetKicks
  • Digg
  • msdn Social
  • Reddit
  • StumbleUpon

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


How to run and debug a Windows Service with Visual Studio .NET

clock September 24, 2009 08:26 by author Matt

I’m working on a Windows Service application at The Day Job, and while I’ve done the usual test-driven development approach, I still have a few things I’m testing and polishing that are integration-related (such as things behaving slightly differently when using SQL Server instead of a mock).  Deploying a service isn’t difficult thanks to installutil, but it is still an extra hoop that I didn’t want to jump through as I tweaked my service.  With .NET, services are mostly just regular Windows applications, the difference is in what happens inside of the Main method:

//For a service application...
static void Main(string[] args)
{
    ServiceBase.Run(new[] { new MyAwesomeService() });
}

...

//For a WinForms application
static void Main(string[] args)
{
    Application.Run(new MyWinForm());
}

//For a console application
static void Main(string[] args)
{
    Console.WriteLine("Hello, world!");
    
    //Do stuff;
    
    return;
}

In a service application, the service class is registered using ServiceBase.Run.  With a WinForms application, you would show your first form from Main.  With a Console application, you would do some stuff and return from Main when its time to quit. 

If you attempt to debug or otherwise start a service application directly, you will see the following message: “Cannot start service from the command line or a debugger…”  If you want to run the service, you have to install it, which again, isn’t hard, but it takes longer than just pressing F5 does.

The solution is simple: allow your application to run either as a service OR as a regular application.  I implemented this behavior by checking for the existence of a “—debug” argument.  If set, the service runs as a regular application.  When not set, it runs as a service.  To make it easy to debug in Visual Studio, I added the “—debug” flag as an argument under the project properties “Debug” tab, so now pressing F5 or clicking “Debug” runs my service project in application mode.

Here’s how I implemented it:

static class Program
{
    static void Main(string[] args)
    {
        if (args[0] == "--debug")
        {
            RunAsConsoleApplication();
        }
        else
        {
            RunAsService();
        }
    }

    private static void RunAsConsoleApplication()
    {
        MyAwesomeService service = new MyAwesomeService();

        service.Start();

        ManualResetEvent blocker = new ManualResetEvent(false);

        Console.CancelKeyPress += delegate
                                    {
                                        service.Stop();
                                        blocker.Set();
                                    };

        blocker.WaitOne();
    }

    private static void RunAsService()
    {
        ServiceBase.Run(new[] { new MyAwesomeService() });
    }
}

Note that I’m using a ManualResetEvent to block the thread until Ctrl+C is pressed.  If you run your service as a WinForms application, you will never see a console, so you can’t press Ctrl+C to kill the application.  Instead, you’ll have to use “Stop Debugging” to kill it.  If however you set your project to run as a console application, you can press Ctrl+C to stop your service and shutdown the application just as if you had pressed the Stop button in the Windows service manager.

One other thing to note: my service class exposes Start and Stop methods that encapsulate the logic of OnStart and OnStop (which are what’s run when you start/stop the service from the Windows service manager). 

The solution isn’t perfect, but it works.  Anyone know of any alternatives?

Share or Bookmark this post…
  • del.icio.us
  • DotNetKicks
  • Digg
  • msdn Social
  • Reddit
  • StumbleUpon

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Things I hate

clock July 27, 2009 07:40 by author Matt
  1. Internet Explorer 8
  2. Browsers that have rendering bugs (aka Internet Explorer)
  3. Browsers that have terrible CSS support (aka Internet Explorer)
  4. Browsers that have terrible developer tools (aka Internet Explorer)

Coincidentally, that’s also the list of reasons why there is no new blog post today.  In all seriousness, JavaScript and HTML have gotten a bad rap.  If you ignore IE, they’re a great to work with.  As soon as you start worrying about Internet Explorer though, you might as well go find a bus to lay down in front of, because that’s going to hurt less than getting IE to behave.

Share or Bookmark this post…
  • del.icio.us
  • DotNetKicks
  • Digg
  • msdn Social
  • Reddit
  • StumbleUpon

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


On the plus side…

clock July 22, 2009 23:37 by author Matt

I’ve been pretty down on Microsoft lately (and deservedly so since I’ve been developing JavaScript that has to work in the pile of trash they are passing off as a browser), but not all is doom-and-gloom from Redmond.  Yesterday, Microsoft RTM’d Windows 7, Windows Server 2008 R2, and Expression Studio 3.  I haven’t tried Expression Studio 3, but I can vouch for the high quality of the other two products.  I’m running Windows 7 RC (and beta before that) on a production machine, and I’ve had one, maybe two, hiccups the entire time.  It’s a great OS, and I have already pre-ordered my copies.  My only regret is that I have a new machine to build this weekend, and I won’t be able to put Windows 7 RTM on it.

So, congrats, Microsoft, on some great releases this week.  Now take all that positive energy, and channel it into creating a browser (based on Firefox) that doesn’t make me want to find a new profession.

Share or Bookmark this post…
  • del.icio.us
  • DotNetKicks
  • Digg
  • msdn Social
  • Reddit
  • StumbleUpon

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


About Matt

I am an overworked (and apparently overpaid) software developer with aspirations of acquiring a PhD in Computer Science. I started off coding in C over a decade ago.  Since then, I've migrated from C to C++ and branched out to C#, PHP, VB.NET, JavaScript, and worked with a wide assortment of other languages that I hope to never deal with again (I'm looking at you, COBOL). Oh, and yes, I've written some Java.  Does that make me a bad person?

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in  anyway.

© Copyright 2009

Sign in