Nice to get noticed sometimes

Last year I had the privilege of working on a project for Johns Hopkins University. It was a suite of web applications that provides hospitals with tools for performing predictive analysis in a variety of disaster scenarios. The project was grant funded and as such was very limited in the time and resources available. It was an exciting project with a real sense of purpose, and I was very proud of what we were able to achieve in a short amount of time.

My contact at the client emailed me recently to let me know that the response to the applications has been very positive, and also that we made the news. According to the article, the apps were supposed to be featured at the DHS’s University Centers of Excellence Innovation Showcase on Feb. 11 in Washington, D.C.

The project had a dedicated designer who generated the HTML, CSS, and JavaScript resources for the UI. The client contact developed a set of server-side DLLs in MatLab, which is where the deep statistical analysis work takes place. My role in the development was to integrate these two into an ASP.NET MVC solution, with healthy doses of JavaScript, jQuery, and Knockout.

It was a challenging and rewarding project that has the potential to make a difference in the world. Those kinds of projects are rare, and I’m very happy to have been associated with it. It’s also rewarding that the app is getting some attention, because it’s nice to get noticed sometimes.

A new adventure

I should have posted this a few weeks ago, but as of January 20th, I became a Wintellectual! I am working with Wintellect as the Lead Developer for WintellectNOW, focusing primarily on the site itself. WintellectNOW is an on-demand video training service brought to you by the renowned world wide trainers at Wintellect. We have a host of great authors and content you simply won’t find anywhere else. Use the promo code COCHRAN-13 for a free 14 day trial.

The best news for me personally is that I will be working at home again. I’m hoping that being home will afford me the opportunity to blog and write more, and of course I’ll continue to be active in the Community. Speaking of which, check out my new page, Cruiser Log 2014. On that page I’ll be chronicling my community travel and attendance this year. See you on the road!

New video at WintellectNOW

I’m pleased as can be to announce that my first video has been published by!

WintellectNOW is a fairly new player in the on demand video training business, but as a division of Wintellect, a very well known and high ended software training and consulting firm, it has serious training credentials. You can read more about WintellectNOW at

Spicing up your ASP.NET MVC apps with KnockoutJS

In this video I cover numerous ways to integrate your server side MVC code with KnockoutJS on the client side.  The course includes a full working solution with all 11 demos from the video.

Here is the official description:

ASP.NET MVC is a robust and powerful framework for creating Web applications, but it is a distinctly server-side technology. KnockoutJS is a popular JavaScript library included with Visual Studio’s MVC templates that implements MVVM on the client side. The marriage of MVC on the server and KnockoutJS on the client yields a great combination, but you’ll need to learn some techniques for integrating the two in order to fully take advantage of this awesome pairing.  In this video, you’ll learn how to do just that through a series of hands-on demonstrations.

And of course here is the link to the video’s home page:

I’m very excited to be a part of this effort, and I look forward to producing many more videos for WintellectNOW!

The stand up desk rises to the occasion

Like most Americans, I lead a largely sedentary lifestyle. I’ve never been particularly athletic. The closest I’ve ever been was 5 years of forced physical training courtesy of the United States Army. That experience drilled in me a particular distaste for exercise, so with the exception of some fair weather golf, I don’t get much exercise. Between my disdain for exercise and my hectic schedule, carving out time to go to the gym just ain’t happening. Naturally, this creates a vicious cycle: I’m too sedentary, so I get heavier, which only makes me more sedentary, so I get heavier still, and so on.

I sit too much

I recognized some time ago that like most American office workers, I sit far too much. I sit at work, I sit in the car when I travel, I sit in my recliner when I’m home watching TV or playing on the XBox.  Basically, I’m sitting my life away, and over the last few years I’ve really started to notice the difference. My legs, hips, and back hurt most of the time to some extent or another. And of course it doesn’t help that I passed the magical 40 barrier.

There are plenty of articles supporting the idea that sitting is killing us, and really it’s just common sense.  For the office professional, the question becomes “how do I work on my computer all day without sitting?” There are many suggestions but ultimately they all boil down to one idea: get out of your chair. Whether you are stretching, walking, or doing pushups, you have to get out of your chair first. When I wrote about the Pomodoro Technique back in 2009, one of my key points was that during breaks you need to get out of your chair and walk around:

Breaks are essential to the success of the system.  While it may not count as exercise, getting out of your chair is physically good for you.

Getting out of your chair is much harder than it sounds. I was successful when I was strictly following Pomodoro, but otherwise I find it really difficult to tear myself away, especially in the afternoons. Even with the best of intentions, after lunch I can sit for 3 to 5 hours sometimes before I realize it. Sure, it can be done, but you have to have more discipline than me to make it work.

A simple solution

Surprisingly, the answer is drastically simple: don’t sit, stand instead. It turns out that there are a lot of options out there for stand up desks.  I read about them in several articles, and I was curious, but had little to compare it to and plenty of questions. How does that work in a real setting? Won’t your feet hurt? Where do I buy a stand up desk? What if I need to sit for a while? I was also taken back a bit by the cost of some of the stand up desks on the market, and I wasn’t about to invest a bunch of money in something like that without testing it first.

I skirted around the idea for quite a while, talking to people, getting opinions, and generally avoiding actually trying it out. For one thing, I didn’t have access to one of these desks, which is a convenient excuse.  Then I visited a local co-working space and there was a guy there with a stand up desk. More accurately, there was a guy there with a cardboard box on a table, using it like a stand up desk. It dawned on me that I was procrastinating for no reason, so only a couple of months later, I decided to give it a try for myself.

A simple box desk

The box was a fruit box, which was sturdy and large enough for my laptop, mouse, and coffee cup.  The 2nd monitor is on a shelf behind the box. I already had the box, so it really gave me a chance to try it out for free.

Making the move

The biggest challenge for me was that all the recommendations say not to overdo it. I have a tendency to go whole hog, so I tried really hard the first couple of days to only stand half the time.  The first couple of days, I could feel it in my feet and legs, but my hips and back felt much better. I did worse on days 3 and 4, I ended up standing all day each day. Yes, by the end of each day I was ready to sit, and yes my feet hurt a bit more, but otherwise I felt great. What I figured out was that this is not just about not sitting, or even standing: it’s about movement. Being on my feet all day forces me to move around a lot. I’m constantly shifting my weight, or stretching muscles that normally lie dormant. And the momentum is already there, so walking around the room a bit or even out of it comes naturally. My favorite part is on phone or Internet calls. I use a headset, so I can move around during the call, use regular body language, and basically get more involved in the conversation. This all may sound minor, but it eventually adds up to a superior experience.

Also, I have slept even better than ever since I started, because at the end of the day I’m tired – not from sitting on my rump all day, but from physical activity, which is a very rewarding kind of tired. Oh, and the best thing of all? At the end of the day, sitting down feels really good!

By the morning of day 5 I was hooked and ready to commit, the only decision left was which desk to buy. I did some research and found that there are a lot of options when considering a stand up desk. You can get a gadget that hooks to your existing desk, you can get a desk that is all stand up all the time, you can get a sit-stand desk, you can even get a Treadmill Desk. For a while, I seriously considered a treadmill desk, but it really wouldn’t work in the space I have and since I hadn’t tried one I wasn’t willing to commit to the idea.  I may work up to one some day, just not yet.

What most of the articles I read said was that you still need the option to sit, so to me that meant buying a sit-stand desk. Again, there are plenty of desks out there to choose from with a wide range of styles and prices. One important issue for me is that my work space is in my bedroom, so it has to look nice as well, and unfortunately a lot of the options out there look rather industrial.

At that point, I still had a choice to make: manual or power.  The manual desks either have preset heights that you can adjust to, or have hand cranks to allow finer settings. The preset desks would not be conducive to adjustments during the day, or with a full complement of computer equipment on them. I did not relish the idea of a crank-up desk, and besides, what self-respecting geek doesn’t want power? So I decided to find a power desk.

The problem with power desks is they seem very expensive. I found some that were more than $3,000, but don’t worry those were extreme examples. I needed something sturdy, reliable, and attractive that wouldn’t break the bank. Fortunately, I found it at UpDesk.

The UpDesk PowerUp

Several things impressed me about UpDesk. First, they have a great website. I love the video section – short, funny, to the point. I even watched the “how to assemble” video before I purchased (more on that later). Second, I emailed them and received a response from an actual person in under 30 minutes. Finally, their prices won’t break the bank: I bought the largest one (72″ x 30″) and it was less than $1,000 not including shipping. Shipping was $139 which is perfectly reasonable considering it comes in three boxes and weighs over 70lbs.

The design is simple and very well thought out. There are two leg posts that are set back out of the way, each with its own motor. They are connected by a stretcher that you can use as a cable run, which I’ve also found I can prop my foot on when standing.

Legs and stretcher
Legs and stretcher

The top is thick and sturdy, with an curved front, and all the corners are rounded. And it is definitely attractive with a clean and elegant look that my wife does not protest having in the bedroom. You can choose from 4 different colors, Maple (the one I chose), Mahogany, Black, and Orange (limited to 60″ x 30″).

A word about price

If it seems excessive to spend that much money on a desk, I understand the thought, and I balked at the idea at first myself. Here are a few thoughts I had on the matter. The Money Factor: office furniture is not all that cheap to begin with, and nice office furniture is very expensive. Sure, you can buy cheap laminated particle board furniture, but as the old saying goes “you get what you pay for”. The Time Factor: I don’t know about you, but I spend more time every day at my desk than I do in my bed, so I should be willing to make an investment in a great work space. The Health Factor: ultimately this is about my health, and this seems a small price to pay for something that will make me healthier.

And don’t forget, there are manual options as well that are more affordable. In fact, UpDesk’s crank (video) system seems far better than any of the others I saw in my research, and several hundred dollars less expensive.

Assembling your desk

I ordered the desk on Friday, it shipped on Monday, and I received it on Wednesday. It comes in three boxes, one large heavy one for the desktop, one medium heavy one for the legs and power system, and one long light one for the stretcher. The design is so simple that assembly is really easy. Basically, you connect the legs together with the stretcher, connect the legs to the desktop, and add the power supply and cables. I followed the great installation video and had it put together in about an hour. It took me a little longer because my power drill is broken, so I used manual tools.

And speaking of tools, here’s what you’ll need: a #3 Phillips head screw driver, a 1/4″ Hex drive (if you don’t have one of these, a #2 Phillips head screw driver should work), and a #1 Phillips head screw driver. Add in a little elbow grease and you’ll be done in no time. The biggest challenge I had was unpacking all the parts. Let’s just say that if your desk arrives damaged, call the authorities because the delivery guys ran over it with their truck several times. Oh, and if you love bubble wrap (and who doesn’t?), you’ll get a years supply gratis.

Enough already, where are the pics?

Here are some pics of my assembled desk.

Standing position
Standing position
Sitting position
Sitting position

I learned something else that I never realized: my old desk was too tall. Even with my adjustable chair all the way up, I never realized I was holding my arms at an uncomfortable angle. With this desk, even sitting I am able to get the desk at just the right height for me.

Push button height adjustment with digital display
Push button height adjustment with digital display

The underside is very neat and tidy, thanks to the supplied cable holders.

Cable management
Cable management

And of course, I wrote this entire article standing at my new desk.

Additional reading

Phil Haack – Sitting is making you fat and killing you

Steve Smith – Walking while working

The power of walking while working

Standing desks better for kids too

Working while standing proves beneficial for health

Prolonged sitting shown to be bad for your health

The Wheel in the Sky Keeps Turning

Time marches, the seasons change, and so do our lives.  And so, once again, my life is changing.  Today is my final day with Lotic Factor, Inc.  I have thoroughly enjoyed my time with the team at LFI: they are intelligent, dedicated, and a whole lot of fun, both on and off the job.  Unfortunate financial realities may have brought our partnership to an end, but the friendships will certainly endure.  I wish them all the best, they deserve it.

As for my next chapter, on Monday I begin working as a consultant at Sogeti (pronounced “sew-JET-ee”), an international consulting firm.  Sogeti has a stellar reputation and the projects I will be working on promise to be diverse, challenging, and rewarding.  I am very excited about this opportunity and am looking forward to getting to know my new team.

Finally, after much thought on the matter, I have decided to resign as a ComponentOne Influencer.  I feel that with my new obligations, along with plenty of existing ones, that I am no longer able to meet the needs of the program.  I am deeply grateful to ComponentOne for its community support and for letting me be part of their program. Speaking of C1, be sure to check out the new 2013 release of their Studio Enterprise.

A Sudden Move: one developer’s journey from C# to JavaScript

I was very fortunate recently to have my first article for Simple Talk published.  Simple Talk is an online magazine operated by redgate.  The article is titled “A Sudden Move: one developer’s journey from C# to JavaScript“.  In it, I discuss the reasons that JavaScript is so compelling and try to dispel some of the unfair treatment JavaScript get from developers.

Please pop over and give it a read, feel free to leave comments there or here.

CORS, AJAX, and POST data in Web API

Last week was quite possibly the most frustrating week of my 15+ year software career. Stuff that was working stopped and stuff that should work didn’t. Hours of research on  the Internet and miles of code trying anything and everything to get over this one small hurdle, but all to no avail.  The good news, if you can call it that, is that I wasn’t alone. As my Grandmother always said “misery loves company”, so I shared the problem with my co-workers at Lotic Factor Inc, Brian Lanham and Chris Atienza, and we all suffered together. And then we suffered some more.

For 3 days we rode an emotional roller coaster, hopefully trying new solutions only to end in failure. I don’t see how Edison survived 2,000 attempts at creating the light bulb.  By the end of day 2 I was thinking of inflicting bodily harm on somebody, and by the middle of day 3 I was ready for that person to be me.  If I’ve painted a depressing picture for you, then as a writer I have done my job: I think this is the first time that a software problem has actually depressed me.

However, as evidenced by the fact that I have yet to do myself in, we did finally manage to put together a solution. I just hope it’s a long time before something so frustrating crosses our paths again.

CORS, AJAX, and Chrome

Brian already wrote about the issue in detail, so I’m not going to rehash the specifics. You should go read his post first.

Here are the highlights (my version):

  • Accessing resources across domains (also known as CORS, or “Cross-Origin Resource Sharing”) requires the remote domain to grant permission to the requesting domain. This makes perfect sense.
  • The server must be configured to acknowledge said permission. You can do this through the Response Header or server configuration. This also makes sense.
  • Google Chrome ignores these settings. This sucks. Hard.

OK, the last point may be a little unfair. Chrome doesn’t ignore them so much as makes you do a magic dance and stand on three toes of your left foot under a full moon during a month beginning with a vowel before it will recognize them. Also, it may actually be web-kit causing the issue and not Chrome per se, but as Chrome is my browser of choice for development I’m going to aim all my angst at Google. On the plus side, had I not been using Chrome for development, we wouldn’t have discovered the issue any time soon. Better to suffer now than later I suppose.

The CORS AJAX Handlers

Brian mentioned the CORS AJAX code we wrote, the core of which came from Zoiner Tejada’s article on CORS with Azure. We also found lots of other help from many places, and as always I am grateful for the awesome software development community.

Here is the completed version of our CorsAjax JavaScript file. Just drop this script into your page and it will automatically create a global variable called “corsAjax” which you can use to issue GET and POST requests.

The problem of POST data

Getting past the dreaded origin issue was a major relief, but it led to another problem sending POST data to the Web API controller actions. These actions have object parameters, which should automatically map the incoming data. What we found is that depending on how you prepare the data for the POST submission, sometimes this will work and sometimes it won’t.

If you send JSON, the mapping should occur automatically:

This will result in the object being correctly initialized with the JSON data.

Another common approach is to serialize the data first. In the following example, we’re using KnockoutJS’s ko.toJSON method:

If you POST the data in this manner, jQuery will create a Form object, serialize the form, and submit it. When you do this, the parameter object in the Action method will be initialized to default values.

This means you will need to first extract the serialized string from the Request and re-serialize it as JSON:

Next you will need to deserialize the JSON into your object:

This is a little on the ugly side, so naturally we wrote  a GenericDeserializer<T> class that takes an HttpContext instance and returns the deserialized object:

Using the GenericDeserializer, here is the completed Action to deserialize POST data:

How to tell if the data was serialized

The problem with the preceding approach is that the controller doesn’t inherently know whether the data was serialized or not. If you call the GenericDeserializer when there is no data in the HttpContext to deserialize, it will throw an exception. Rather than relying on try/catch I would prefer to only call the GenericDeserializer if necessary. To that end, I dug around in the Request object and discovered a useful little tidbit that we can use to solve this problem.

The solution is in the Request.Params.AllKeys property. When the data is passed as regular JSON, the sent parameters will be the first ones in this list. If, however, the data was serialized, the first item in the AllKeys list will be null. I wrapped this up in an Extension Method to make reuse more palatable:

Now I can decide when to try and deserialize based on this Extension Method. If the data does not need to be deserialized, it will fallback on the default parameter object.

Putting it all together

The final solution Action code includes the correct method attributes (see Brian’s post referenced previously), a call to determine if the data is serialized, and if needed call GenericDeserializer:

While there are several places this could be streamlined, like using the Request object instead of HttpContext, I can now implement a consistent way to handle POST data in Web API Action methods without the client implementation being aware of specifically how to send the data.

Weekly roundup 10/12/12

Since I started at Lotic Factor I’ve been sharing a list of links with my coworkers we call “The Weekly Roundup”. There is no set schedule but typically I send out a list about once a week. The links mostly come from Twitter and various newsletters. The concept is nothing new, but it saves them from needing to spend as much time on twitter as I do! I’m sharing them in the hopes that some readers may find them interesting as well, and also as an archive of past links. DISCLAIMER: The only qualification for inclusion is that I found them interesting. In no way are the links or articles vetted, nor does their inclusion constitute agreement with, adherence to, or support of any claim, position, prognostication, or statement contained therein, by either myself or my employer.












Weekly roundup 10/3/2012

Since I started at Lotic Factor I’ve been sharing a list of links with my coworkers we call “The Weekly Roundup”. There is no set schedule but typically I send out a list about once a week. The links mostly come from Twitter and various newsletters. The concept is nothing new, but it saves them from needing to spend as much time on twitter as I do! I’m sharing them in the hopes that some readers may find them interesting as well, and also as an archive of past links.

DISCLAIMER: The only qualification for inclusion is that I found them interesting. In no way are the links or articles vetted, nor does their inclusion constitute agreement with, adherence to, or support of any claim, position, prognostication, or statement contained therein, by either myself or my employer.










Weekly roundup 9/28/12

Since I started at Lotic Factor I’ve been sharing a list of links with my coworkers we call “The Weekly Roundup”. There is no set schedule but typically I send out a list about once a week. The links mostly come from Twitter and various newsletters. The concept is nothing new, but it saves them from needing to spend as much time on twitter as I do! I’m sharing them in the hopes that some readers may find them interesting as well, and also as an archive of past links.

DISCLAIMER: The only qualification for inclusion is that I found them interesting. In no way are the links or articles vetted, nor does their inclusion constitute agreement with, adherence to, or support of any claim, position, prognostication, or statement contained therein, by either myself or my employer.