LINQ: Clarity, complexity, and understanding

This is part of a short series on the basics of LINQ:

At CareEvolution, we tend to develop using JavaScript on the front end, and C# on the back end (with some Python, PowerShell, CoffeeScript, R, SQL, and other languages thrown in when appropriate or technical debt dictates). We have hackathons every eight weeks where we get to be creative without the constraints of day-to-day work. We have a brown bag lunch talk every Wednesday. We work hard at embracing change, exploring new ways of doing things, and sharing what we have learned with each other. Quite often, leading figures in a particular technology emerge within our organisation: Brian knows JavaScript, Chris knows CSS, Brad knows SQL. While I doubt I know even half of the things about LINQ and its various implementations for database, Web API, or file interaction, I know enough to make it useful in my day to day work and I seem to be the one that employs it most in their code. I know LINQ.

I am certain this is going to sound familiar to many, but while my colleagues and I embrace all things as a collective, quite often a specific technology or its use will be avoided, derided, and hated by some. Whether driven by ignorance, a particular terrible experience, or prejudice1, these deep-seated feelings can create conflict and occasionally hinder progress. For me, my use of LINQ has been a cause for contention during code reviews. I have faced comments like "LINQ is too hard to understand", "loops are clearer", "it's too easy to get burned using LINQ", and "I don't know how to use it so I'd prefer not to see it". And that's all true; LINQ can be confusing, it can be complicated, it can be a debugging nightmare. LINQ can suck. Whether you use the C# language keywords or the dot notation (a debate almost as passionate as tabs versus spaces), LINQ can tie you up in knots and leave you wondering what you did to deserve this fresh hell. Yet any technology could be described the same way when one doesn't know anything about it or when early mistakes have left a bitter aftertaste.

Tabs vs Spaces

In response to these dissenting voices, I usually indicate the years of academic learning and professional experience it takes us to learn how to code at all. None of it is particularly easy and straightforward without some education. Don't believe me? Go stick your mum or dad in front of Visual Studio and, assuming they have never learned anything about C# or programming, see how far they get on writing Hello World without your help. Without educational instruction, we would not know any of it and LINQ is no different. When review comments inevitably request that I change my code to use less LINQ, none at all, or more understood language features like `foreach` and `while` loops, it frustrates me. It frustrates me because I usually feel that LINQ was the right choice for the job. I feel like I am being told, "use something I already know so I don't have to learn."

Of course, this interpretation is hyperbole. In actuality, when presented with opposing views to our own, it is easy to commit the black or white fallacy and assume one must be right and the other wrong, when really we should accept that we both may have a point (or neither) and learn more about the opposing view. Since I find, when used appropriately, LINQ can provide the best, most sublime, most elegant solution to problems that require the manipulation of collections in C#, I desperately want others to see that. It is as much on me as anyone else to try and correct for the disparity between what I see and what others see when I write LINQ. So, with my next post we will begin a journey into the basics of LINQ, when to use it2, when to use dot notation over language keywords (or vice versa), and how to avoid some of the more common traps. We will begin with the cause of many confusing experiences; deferred execution.

  1. we all know someone in the "That's new, I hate it" crowd []
  2. even I recognize LINQ is not a golden hammer; it's more of a chainsaw that kicks a little []

Five Things I Did In England That Might Surprise Americans

We all employ stereotypes to generalise groups of people. Often, a stereotype fills a gap between one cultural experience and another, making assumptions about others to provide an easy answer as to why others are different. It is not a particularly constructive approach to cultural differences, often being divisive to the point of pissing people off. Sometimes that is the intent, to troll people, other times it is a side-effect of ignorance.

That's about as deep as I want to get in this blog entry. However, it sets a basis for the following things I did in England that, due to assumptions (stereotypical or otherwise), may be surprising to my North American friends and neighbours.

1. Sound American

To the community I live in, my friends, my colleagues, and my neighbours, I sound British. It does not matter that there's no such thing as a British accent, the distinctions of Scottish, Welsh, Irish, and English (sometimes even Australian) and any variations thereof are irrelevant; we all sound British. Even now, after 10 years living predominantly in the USA, I sound British. Many are surprised that I have retained my British accent after spending so long here. It does not matter how often I might say to-MAY-toe, zee, or gas, to anyone overhearing me talk, I sound British. I believed them too, until I landed in the UK.

Selected languages and accents of the British Isles (CC BY-SA 3.0)
Selected languages and accents of the British Isles (CC BY-SA 3.0)

Everywhere I went, someone was ready to tell me I sounded American, that I had a twang, that I was losing my accent. Now, at first, I put this down to my saying the odd American word or using an American pronunciation, yet after a day or two, after settling back into my native dialect, the comments kept coming. It seems that immersion in US culture for 10 years does make a difference. Worse still, I could not hear it myself. I was so used to the way I talked, I had not even noticed a change, and I still can't. To one side of the Pond, I sound British, and to the other, American. It has left me a little culturally orphaned, a perennial outsider, a citizen of the mid-Atlantic, land of 80's radio DJ's, bad documentary narrators, and people in old movies1.

2. Eat Well

Possibly the most misleading stereotype I hear about the UK is that all our food is bad, awful, bland, terrible, sludge that no one in their right mind would ever let pass their lips. Though we certainly have some unusual dishes that I find pretty horrible (haggis, jellied eels, black pudding, and tripe), I know many who think otherwise, and it is not indicative of all British food. Every culture has its "acquired tastes" that others think are disgusting (Velveeta, Easy Cheese and corndogs, anyone?), but that is no reason to disparage every food that culture has to offer.

While I was back home, I enjoyed some amazing food: a steak and kidney pie at my old local pub, a home-cooked roast chicken dinner from my mum, and delicious chicken curry. "But wait, curry isn't British!" you may cry, but the curries served throughout the UK have diverged from their Indian or Bangladeshi origins to meet the palates of Britons. As American as apple pie? As British as a good curry.

Now, you may cry that I am biased and of course, I am. However, I am also a very fussy eater (ask my wife) and I do not take my food lightly, not to mention that we are all biased when it comes to our food; biased toward what we like. If you want to know if what I am saying about British food is right, you can ask my wife, Chrissy (though perhaps she may not agree on which dishes are best). Whether you believe me or not, be a little more open-minded and a lot more selective. Don't base opinions about British food on what you are told or on a single, awful or obscure meal; instead, get some recommendations, you might be pleasantly surprised.

3. Farm Programming

Contrary to the belief of the Comcast representative that sold me my first cable service, modern technology exists in the UK2. I realise that many people reading this, if not all, are already aware of this.

Shakespeare was not amused at the quality of the earring he bought on Etsy
Shakespeare was not amused by the quality of the earring he bought on Etsy

As our trip to the UK was to be a working vacation, I spent some of my time sat in the lounge of my parents' centuries old farmhouse, coding, emailing, and taking part in meetings. Even in the "quaint"3 English countryside, the modern engineer can push commits to GitHub, attend a conference call on GoToMeeting, and surf the Internet for cat photos. WiFi and broadband are everywhere in the UK; in fact, in some places, the speeds should embarrass Americans, who have some of the most expensive and slowest broadband Internet services in the world.

4. Not Meet The Queen

"And I said, Jeff? Of course I know Jeff!"
"And I said, Jeff? Of course I know Jeff!"

No, I don't know the Queen. I also did not meet your friend that lives in Lower Bumblecrap or your great Uncle Charlie from Arserottingham. What I am trying to say, though perhaps a little harshly, is that the UK is a big place. There are over 63 million people in the UK, over 53 million of them in England alone, one of which is the Queen4. She does not tend to hang around and have personal relationships with her millions of royal subjects. I understand the idea that there is some chance I may have met someone's friend or family member, no matter how unlikely, but when I get asked if I know the Queen (even in jest), I want to escape and go have a real conversation with someone else. Why is a country that fought so hard to get rid of the British Monarchy so apparently obsessed with it?

5. Not Stay

The idea of leaving the gorgeous countryside and history of England to live in the US seems unimaginable to some. Like Madonna, Kevin Spacey, and Tim Burton, many Americans would jump at the opportunity to live in the UK. I can see why, it is filled with amazing people, history, and free healthcare, not to mention everyone talks like Dick van Dyke got elocution lessons, but I lived there for nearly three decades, I've done that. Although my family and many amazing friends are there, I don't fit. I never really fit. The culture of cynicism, the Tall Poppy Syndrome, the overcast weather; it just does not suit me, and in the long term, it doesn't make me happy. Although the US is far from perfect and there are many things I miss from my native land5, since moving here I have been happier, more satisfied, more successful, and more accepted. When we returned to the US, the immigration officer said, "Welcome home," and he was right.

Today's featured image is by Lunar Dragoon and is licensed under CC BY-SA 3.0.

  1. Okay, not quite, but I wanted to include the video []
  2. "Do you have computers in England, yet?" he had asked, earnestly []
  3. This over-used description of the UK, or parts thereof, always feels dismissive, like it's just a theme park []
  4. http://en.wikipedia.org/wiki/Demography_of_the_United_Kingdom#Population []
  5. Worry-free (or at least worry-less) healthcare, pubs (no, they don't exist in the US), proper fish and chips, cask-conditioned ale, and the steak and kidney pies from my old local, to name a few []

Community

I am pretty selfish. I would like to think I can be wholly altruistic, but I cannot remember a deed I did for someone else where I was not rewarded by a general feeling of well-being. Perhaps this is normal and we kid ourselves that true altruism exists because, well, it feels good to believe that. Recently, I realised it is because of this feeling that I volunteer as part of the local developer community.

I have been involved in the Ann Arbor area developer community for just under five years. A couple of colleagues had suggested I attend an Ann Arbor .NET Developer (AADND) meeting, but oddly, a woodworking class is what led me there. In that class, I met fellow developer Steve Meagher, we became friends, and he eventually persuaded me to tag along with him to a .NET meeting. Like many within the developer community, I avoided user groups and other community events for fear of not fitting in or some other perceived discomfort. At that first meeting, I met David Giard as he was the speaker that evening. Meeting David turned out to be a gateway into the wider community and volunteering. At the time, he was the president of the Great Lakes Area .NET group (GANG) and he invited me to attend a meeting there the following week. Just as with Steve at woodworking class, another connection was made and so it was that my adventures in the developer community continued. Through the friends I made attending the local groups, I ventured to far off places like CodeMash and Kalamazoo X. Through the friends I made attending those far off places, I ventured to electronic wonderlands like Twitter, StackOverflow, and my own blog. And eventually, through the encouragement I received from this amazingly supportive community, my family, and my friends, I found the courage to look inward, to seek help for the demons that fostered my low self-esteem, and to grow.

I have volunteered on the board of AADND, as a participant and team leader at Give Camp, and as a speaker at CodeMash; having thoroughly enjoyed every second, I can tell you that volunteering is 100% pure fun.

OK, that is utter bollocks; volunteering is hard. There is no pleasure in finding content for newsletters and slide decks, no joy in the conflicts a team faces when you have less than a day to get a database migrated, no comfort in preparing and rehearsing a talk1. Volunteering is often stressful, sometimes boring, and always built upon a foundation of compromise and sacrifice. If those things were the rewards of volunteering, I cannot imagine anyone who would do it. Every year, Michael Eaton tells a tale of how he declares that this Kalamazoo X will be his last. That it is too much work. Too much worry. Too much sacrifice.

Thankfully, the hard work leads to gratitude: the emotional words of a non-profit director overwhelmed by the generosity of local developers; a room of people applauding at the end of a talk; or a simple "thank you". Regardless of its delivery, seeing or hearing that someone is grateful makes all the effort worthwhile. It feels good. For community volunteers like Michael Eaton it is the gratitude shown by attendees, speakers, and co-organizers that ultimately leads to more events (like just one more Kalamazoo X).

So, next time you enjoy something that someone volunteered to do, show your gratitude. And if the opportunity arises, try volunteering; you have no idea who might be grateful and how good that might feel.

  1. or a last minute Pecha Kucha that your friends then make sure will get heard while you are busy searching for that lost sleep []

Ten Years

This month marks ten years since I first set foot in the US. As I waited in line at immigration, tired from the flight and daunted by everything that might happen next, it was easy to forget everything that came before. Just three weeks earlier, my workplace had been tense with news that another wave of redundancies was sweeping through and I was unsure in what direction I was heading1. I was ready for a change, but did not want the uncertainty of finding a new job or the certainty of choosing to leave the one I had. I was living a step ahead of my means with little attention paid to the future. I was smoking. I was making dubious decisions or avoiding decisions entirely. I was feeling disenfranchised, misplaced, and numb.

One afternoon our manager called us all into a meeting room. There, he informed us of two positions available in the US and asked if any of us were interested. It felt like the silence lasted a long time although it was probably only a few seconds. No one was volunteering. I do not know the trigger  — my desire for a change, the allure of working in the US, or my need to get control of my life, but slowly, I raised my hand. I remember rationalizing it as no big deal, after all, I was only expressing interest, it was not like I would be whisked away to a plane immediately. With the raise of my hand, so began a series of small, easy decisions that led to the biggest self-directed change of my life so far.

Within the three weeks from when I raised my hand to when I stepped off the plane in Detroit, I packed, paused, and displaced my life. Boxes were filled, paperwork was filed, and farewells were planned. There was no time to stop and think about what I was doing, just lots of small decisions to make — accept or negotiate the contract, pack or throw away my things, take or leave my guitar, stay or go, sink or swim. All along the way, I kept telling myself it was not forever, it was no big deal. I was only going for a couple of months to meet the customer face-to-face; work (and a longer stay) was always going to be dependent on the acquisition of appropriate work visas. It was no big deal.

And so it was. Three weeks flew by. My sister, my parents, my new boss in the US, my old colleagues in the UK, my friends (including my housemate, who was seriously ill at the time), and many more all helped in some way. I am incredibly grateful to their support, it was amazing. During the whole experience, trepidation wrestled with excitement. Seconds after the taxi pulled away, leaving my parents and friends as they waved goodbye, excitement turned to panic.

What the hell am I doing?

I repeated that phrase in my head many times between London and Detroit. When the taxi left my old home. When the taxi left me at the airport. When I was pulled from the security line for "special screening". When I sat on the plane. When the plane took off. At least once per hour during the flight. When I landed. When I got into the immigration line. Over and over.

What the hell am I doing?

I am pretty sure I was terrified, but just like the small decisions that got me there, I focused on the immediate situation and did my best to ignore everything else. I think excitement and terror are pretty much the same thing but with different interpretations. As I accepted the situation as an adventure, the terror would subside and excitement returned.

Blimey, I'm actually going to America!

That was how my first few weeks in the US continued. A mixture of terror and excitement, depending on the situation and how I let myself accept it. It was the beginning of something new and ten years on, I cannot imagine doing any differently if it were to happen all over again. It was by far the best decision I ever made because I learned the value of making a decision instead of letting fate decide. I faced my own anxieties head on and made a decision to challenge my fear. The amazing sense of achievement that came from deciding for myself was life-affirming. While it took me another nine years to take that moment of control over my anxiety and begin learning how to harness it on a day-to-day basis, I still look back on that decision and the many ways it has changed my life. In a moment, I went from feeling disenfranchised, misplaced, and numb, to engaged, excited, and driven.

Of course, that first day in the US was merely the beginning, a lot has happened since and a lot more will happen yet. Though my move was certainly no panacea to my problems — there were many difficult challenges to over come, it was a catalyst for solutions, an opportunity to grow, and a clear example that fear alone could not stand in my way if I could find the courage to face it. It is a lesson that I have applied many times since; from winning the CodeMash Pecha Kucha contest, to marrying my amazing wife, so many achievements began in an otherwise unremarkable moment where I pushed my fear aside and made a decision to try.

So, whatever the next ten years hold for me, it is not fear, but small moments like raising my hand in that meeting room that will shape them. Can you say the same? Where will your decisions take you?

  1. Unlike in places such as Michigan, where employment is considered "at will" and can be terminated at any time, if a company in the UK wants to downsize, they must go through a process of making positions redundant. That means the position will no longer exist and as such, the organisation cannot hire someone else to perform that job. For a better explanation and more information, check out https://www.gov.uk/redundant-your-rights/overview []