October 27, 2010 tools

LINQ Has Changed Me

In the old days, the post-colonial, pre-LINQ days of yore, I’d have written a one-way MD5 encryption like so:

static string GetMD5String(string s) {
  MD5 md5 = new MD5CryptoServiceProvider();
  byte[] hash = md5.ComputeHash(Encoding.ASCII.GetBytes(s));
  StringBuilder sb = new StringBuilder();
  foreach( byte b in hash ) sb.AppendFormat("{0:x2}", b);
  return sb.ToString();
}

This implementation is fine and has served me well for 10 years (I pulled it out of the first .NET project I ever really did). However, after using LINQ for so long, it’s hard not to see every problem as an operation over sets:

static string GetMD5String(string s) { 
  return (new MD5CryptoServiceProvider()). 
    ComputeHash(Encoding.Unicode.GetBytes(s)). 
    Aggregate(new StringBuilder(), (working, b) => working.AppendFormat("{0:x2}", b)). 
    ToString(); 
} 

I can’t say that the LINQ version is any better, but it felt better. However, you’ll notice that I’m not using any of the LINQ keywords, e.g. select”, where”, etc. I find that I don’t really use them that much. It’s too jarring to mix them, e.g. (from f in foos select f).Take(3)”, since not everything has a LINQ keyword equivalent. I tend to do LINQ-less LINQ more often then not.

P.S. I assume someone will be able to tell me how I can do it better. : )

P.P.S. I’m using the Insert Code for Windows Live Writer add-in. I love WLW!

October 27, 2010 spout

A Function That Forces

Far Side - Midvale School for the GiftedAt Microsoft, there’s this passive-aggressive cultural thing called a forcing function,” which, to put it crudely, is an engineering way for us to control the behavior of others. The idea is that you set up something to happen, like a meeting or an event, that will force” a person or group to do something that you want them to do.

For example, if someone won’t answer your email, you can set up a meeting on their calendar. Since Microsoft is a meeting-oriented culture (even though we all hate them), a softie will be very reticent to decline your meeting request. So, they have a choice — they can attend your meeting so that they can answer your question in person or they can answer your email and get that time back in their lives. This kind of forcing function can take larger forms as well. I can’t say that our execs make the decision like this (since they don’t talk to me : ), but it is the case that signing up a large number of Microsoft employees to host and speak at important industry events does have the effect of making us get together to ensure that our technologies and our descriptions of those technologies holds together (well, holds together better than they would otherwise : ).

Unfortunately, this way of thinking has become so much a part of me that I’ve started to use it on my family (which they very much do not like). Worse, I use it on myself.

For example, I have been holding back on half a dozen or more blog posts until I have the software set up on my newly minted web site to handle blog posts in a modern way, namely via Windows Live Writer. In other words, I was using the pressure inherent in the build up of blogging topics to motivate me to build the support I wanted into sellsbrothers.com to have a secure blogging endpoint for WLW. Before I moved all my content into a database, I could just pull up FrontPage/Expression Web and type into static HTML. Now that everything is data-driven, however, the content for my posts are just rows in a database. As much as I love SQL Server Management Studio, it doesn’t yet have HTML editing support that I consider adequate. Further, getting images into my database was very definitely a programming task not handled by existing tools that I was familiar with.

So, this is the first post using my new WLW support and I’m damn proud of it. It was work that I did with Kent Sharkey, a close friend of mine that most resembles Eeyore in temperament and facial expressions, and that just made it all the more fun!

Anyway, I’m happy with the results of my forcing function and I’ll post the code and all the details ASAP, but I just wanted to apologize for my relative silence on this blog and that things should get better RSN. XXOO.

P.S. I’m loving Windows Live Writer 11!

October 25, 2010 conference

Data at PDC 2010

There are lots of great data talks at PDC 2010, all of which are available for online viewing:

  • Code First Development with Entity Framework
    Jeff Derstadt, Tim Laverty
    Thursday, 2:00 PM-3:00 PM (GMT-7)
  • Creating Custom OData Services: Inside Some of The Top OData Services
    Pablo Castro
    Thursday, 3:15 PM-4:15 PM (GMT-7)
  • Enabling New Scenarios and Applications with Data in the Cloud
    Dave Campbell
    Thursday, 4:30 PM-5:30 PM (GMT-7)
  • Building Scale-Out Database Solutions on SQL Azure
    Lev Novik
    Friday, 2:00 PM-3:00 PM (GMT-7)
  • Building Offline Applications using the Sync Framework and SQL Azure
    Nina Hu
    On Demand

Enjoy!

September 27, 2010 tools

Time to check the donuts

Time to check the donuts

One day when I was supposed to be writing, I needed something to do (as often happens). In this particular case, I built a little tray icon app using the new (at the time) tray icon support in Windows Forms (this was a while ago : ). The data I was checking was my gmail account and whenever there was new mail, I’d pop up a notification. All very simple, so to be funny, instead of saying “You’ve got mail,“� my program said I’s time to check the donuts.”

Over time, I came to rely on this app but lamented the lack of features, like seeing who the email was from or marking an email as read w/o logging in, etc. Over time, I came to wish I had something like Gmail Notifier. I’s free and while it doesn’t contain an ’80s commercial reference, it has way more features than I ever built into mine. Oh, and the noise it makes when you get an email is priceless. Recommended.

August 26, 2010 fun

The Downside Of Working At Home

I’ve been working at home off and (mostly) on for 16 years…

From theoatmeal.com. Recommended!

August 8, 2010 spout

Why can’t it all just be messages?

Why can’t it all just be messages?

My mobile device is driving me crazy.

I have an iPhone 4.0. Normally when it’s driving me crazy, it’s standard stuff like the battery life sucks or that the iOS 4.0.1 update didn’t fix the proximity detection or stop emails I send via Exchange from just disappearing into the ether.

This time, it’s something else and I can’t blame the iPhone; I think all modern smart phones have the same problem. The problem is that I constantly have to switch between apps to see my messages. Here are screenshots for 5 of the messaging clients I use reguarly:

Voicemail Exchange Email SMS/MMS Facebook Twitter

This list doesn’t include real-time messages like IM, or notifications like Twitter or RSS. I’m just talking about plain ol’ async messaging. We used to think of it as email,” but really voicemail, email, SMS, MMS, Facebook messages and Twitter Direct Messages are all the same — they are meant to queue up until you get to them.

Now, some folks would argue that SMS/MMS aren’t meant to be queued; they’re meant to be seen and handled immediately. Personally, I find it annoying that there is a pop-up for every single text or media messages I get on my phone and there seems to be no way to turn that off. On the other hand, if I want that to happen for other types of messages, e.g. voicemail, I can find no way to turn it on even if I want to. Why are text messages special, especially since most mobile clients let you get over the 160 character limit and will just send them one after the other for you anyway?

iOS 4 takes a step in the right direction with the universal” inbox:

iOS4 "universal" inbox

Here I’ve got a great UI for getting to all my email messages at once, but why can’t it handle all my messages instead?

super-universal inbox

Not only would this put all my messages in one place at one time, but it would unify up the UI and preferences across the various messaging sources. Do you want your text messages to quietly queue up like email? Done. Do you want your voicemail to pop to the front like an SMS? Done. Do you want the same swipe-to-delete gestures on your voicemail as you have with your email? Done!

Maybe someone with some experience on the new Windows Phone 7 can tell me that there is a messaging” hub that manages all this for me. Since they’re already doing things like bringing facebook pictures into the pictures” hub (or whatever they call it), that doesn’t seem completely out of the realm of possibility. If that’s the case, I’ll say again what I’ve been saying for a while — I can’t wait for my Windows Phone 7!

June 18, 2010 interview

David Ramel Asks About Interviewing at Microsoft

David Ramel from 1105media.com is writing an article that includes the Microsoft interviewing process and he send me some questions:

[David] How would you succinctly sum up the Microsoft interview process as compared to those of other tech companies?

[Chris] MS does some things similarly to other high-tech companies I’ve worked with, e.g. having each interviewer focus on an aspect or aspects, e.g. team skills, people skills, technical skills, etc., expecting a candidate to ask questions, communicating between interviewers to push more on one area or another, etc. The riddle questions are a uniqueness at Microsoft (at least they were when I last interviewed), but theyire pretty rare these days. Coding on the whiteboard also seems pretty unique to Microsoft (myself, I prefer the keyboard : ).

[David] How has the Microsoft interview process changed over time? (Microsoft seems to have shaken up the tech interview process some years ago with those brain-teasing puzzle� questions, but now seem to be much more technically-oriented and job-specific. Just wondering about your thoughts on this observation.)

[Chris] While I have had them, puzzle questions were rare even when I was interviewed 7 years ago. Since then, I haven’t run into many people that use them. However, when they are used, an interviewer is often looking for how a candidate works through an issue as much as the solution that they come up with. In an ever changing world, being able to learn and adapt quickly is a huge part of how successfully you can be in the tech industry at all and at Microsoft specifically. I prefer technical design questions for these kinds of results, however, and it seems that most ’softies agree.

[David] What would you say was the biggest factor in your being offered a job at Microsoft?

[Chris] I had a reputation outside of MS before I interviewed, but that almost didn’t matter. If I hadn’t done well during the interview, I would not have been offered the job. When in doubt, a team generally prefers to turn away a good candidate rather than to risk taking on a bad one, so if there’s anything wrong, team fit, technical ability, role fit, etc., a candidate won’t get an offer.

[David] What’s the single most important piece of advice you can offer to those preparing for a Microsoft job interview?

[Chris] You asked for just one, but I’m going to give you two anyway. : )

  1. If you need more information to answer a question, ask for it. Thatis how the real-world works and many questions are intentionally vague to simulate just this kind of interaction.
  2. Try to answer non-technical questions based on your personal experience, e.g. instead of saying “here’s how I would deal with that situation,“� say I had a similar situation in my past and hereis how I dealt with it.“� This is a style of interviewing known as behavioral� and even if your interviewer doesn’t phrase his questions in that way, e.g. “give me an example of how you dealt with a situation like blah,“� it’s helpful and impressive if you can use your own history to pull out a positive result.

[David] Could you please share any other observations you have on the Microsoft interview process that may not be covered in your site or the Jobsblog?

[Chris] I run a little section of my web site dedicated to the MS interviewing process and the thing I will tell you is this: don’t prepare. Be yourself. If you’re not a fit for MS, no amount of preparation in the days before an interview will help and if you are a fit, that will come through in the interview. Also, make sure you ask questions. Working at Microsoft isn’t just a job, it’s a way of life, so make sure you’re sure you want the team and the job for which you’re interviewing.

[David] Does MS provide training for interviewers? If so, what do they stress most?

[Chris] I’m sure MS does provide training for interviewing, but Iive never been to it. At Intel, I learned the behavioral interviewing technique, which Iive used in every interview since, both as an interviewer and as a job candidate.

[David] Do you have standard questions, or do you tailor them to the situation? If the latter, is it usually tailored for team fit, to a specific open position, particular skills, etc.?

[Chris] I have once standard technique question and a few standard behavioral interview questions. The technical question is to ask them what their favorite technology is and/or what they consider themselves to be an expert� in and then drill in on their understanding. If they can answer my questions deeply, this shows passion about technology and the ability to learn something well, both of which are crucial for success at MS.

My behavioral interviewing questions are things like Tell me about a time when youive been in conflict with a peer. How did you resolve it? What was the result? What did you learn?“� and “Tell me about a time when you had much too much work to do in the time you were given. How do you resolve that issue? What was the result? What did you learn?“� The core idea of behavioral interviewing is that past behavior indicates future behavior, so instead of asking people things like “How would you deal with such-and-such?�” you ask them How did you dealt with such-and-such in the past?“� This forces them to find a matching scenario and you get to see if they way they dealt with the issue in real life matches what you want from a team mate in that job.

[David] How would you describe the kinds of coding questions you ask? A couple of real examples would be perfect!

[Chris] I don’t often ask coding questions, but when I have, I let them use a keyboard. I hate coding on the board myself as it’s not representative of how people actually code, so I don’t find it to be a good indicator of what people will actually do. I guess I even use behavioral techniques for technical questions, now that I think about it. : )

May 23, 2010 .net

Spurious MachineToApplication Error With VS2010 Deployment

Often when I’m building my MVC 2 application using Visual Studio 2010, I get the following error:

It is an error to use a section registered as allowDefinition=‘MachineToApplication’ beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS.

On the internet, this error seems to be related to having a nested web.config in your application. I do have such a thing, but it’s just the one that came out of the MVC 2 project item template and I haven’t touched it.

In my case, this error in my case doesn’t seem to have anything to do with a nested web.config. This error only started to happen when I began using the web site deployment features in VS2010 which by itself, rocks (see Scott Hanselman’s “Web Deployment Made Awesome: If You’re Using XCopy, You’re Doing It Wrong” for details).

 If it happens to you and it doesn’t seem to make any sense, you can try to fix it with a Build Clean command. If you’re using to previous versions of Visual Studio, you’ll be surprised, like I was, not to find a Clean option in sparse the Build menu. Instead, you can only get to it by right-clicking on your project in the Solution Explorer and choosing Clean.

Doing that, however, seems to make the error go away. I don’t think that’s a problem with my app; I think that’s a problem with VS2010.


← Newer Entries Older Entries →