Shared posts

27 May 15:39

Holy shit.


Best shit ever

Holy shit.

07 May 20:00

eyeonspringfield: “Ooohhh my demo tape!”


how i feel with every band i've ever been ever


“Ooohhh my demo tape!”

07 May 19:59


07 May 19:59


07 May 19:59




07 May 19:53

I wrote two lines of code yesterday

by Raymond Chen - MSFT

They were both wrong.

24 Apr 20:40


by phil

I really hate prototype inheritance because its confusing and easy to get wrong, but still this is a neat proof of concept

JavaScript is good, so as part of JavaScript the Good Parts, prototypal inheritance must be really, really good.

JS The Good Parts

Some time ago while I was working on a supply chain management system for a large UK based department store I came across some interesting C# code, here’s an example:

public class Customer : Address 


Unfortunately Clarence above has no address, but thanks to Homeless Hotspots he is a Mac address. A stark warning of the implications of favouring inheritance over composition.

When asked the C# programmer said that they preferred inheritance as it was quicker to implement in C# than composition. For a single object it is easier to favour inheritance over composition in C#, even more so with C# 2.0 before the advent of auto-implemented properties. Here’s the somewhat more verbose Customer has an Address:

public class Customer
    private readonly Address _address = new Address();

    public Address Address 
            return _address; 

The Gang of Four in their seminal Design Patterns book postulated in the first chapter that good object-orientated design should favour composition over inheritance. Unfortunately most people seem to skip the first chapter and dive head first into specific patterns like singleton, proxy and factory. Spring’s AbstractSingletonProxyFactoryBean shows the way:


Arbitrary misuse of inheritance is not confined to enterprise developers, we only need to look at the Button class in WPF to see a long hierarchy and over 160 members.

Button Inheritance

Thankfully the Intellisense in Visual Studio 2012 has an intelligent search to help you find the needle in the haystack. In the future it may be possible to apply machine learning approaches for prediction so that we can scale from hundreds to thousands of members.

Prototypal Inheritance

Programmers often find JavaScript inheritance hard to understand. This is probably a good thing, creating a pit of success where composition is by default favoured over inheritance.

To this end I have implemented Prototypal Inheritance for C#. The source is available on BitBucket and I will publish a Nuget package for enterprise developers in the near future.

Prototype-based programming is actually quite a natural fit for C# particularly with the dynamic support introduced in C# 4, combined with the var keyword introduced in C# 3, it’s often hard to distinguish C# from JavaScript. 

Now for the science: in prototypal inheritance every object is a clone of another object.



Let’s start with the pseudoclassical JavaScript example from Douglas Crockford’s book:

var Mammal = function (name) { = name; };
Mammal.prototype.get_name = function () { return; };
Mammal.prototype.says = function () { return this.saying || ''; };
var myMammal = new Mammal('Herb the Mammal');
var name = myMammal.get_name(); // 'Herb the Mammal'

var Cat = function (name) { = name;
    this.saying = 'meow';

Cat.prototype = new Mammal();

Cat.prototype.get_name = function () {
    return this.says() + ' ' + + ' ' + this.says();

var myCat = new Cat('Henrietta');
var says = myCat.says(); // 'meow'
var name = myCat.get_name();

You can’t beat a good taxonomy of the animal kingdom to show the awesome power of OO. Now you can create almost exactly the same code in C# using the Prototype library:

var Mammal = Prototype.Constructor<string>((that, name_) => that.Name = name_);
Mammal.Prototype.GetName = (System.Func<dynamic, string>)(that => that.Name);
Mammal.Prototype.Says = (System.Action<dynamic>)(that =>
    string saying = that.Saying;
var myMammal = Mammal.New("Herb the Mammal");
string herb = myMammal.GetName();

var Cat = Prototype.Constructor<string>((that, name_) =>
    that.Name = name_;
    that.Saying = "meow";

Cat.Prototype = Mammal.New();

var myCat = Cat.New("Henrietta");

string name = myCat.GetName();


Again starting with a JavaScript prototypal example:

var myMammal = {
    name: 'Herb the Mammal',
    get_name: function () {
    says: function () {
        return this.saying || '';

Now in C# taking advantage of anonymous objects:

var Class = Prototype.FromObject(new
    Name = "Hello",
    GetName = (System.Func<dynamic, string>)(that => that.Name)
dynamic myMammal = Class.New();

There it is, prototypal inheritance for C#, you’re welcome!

24 Apr 20:37

The Blairs to be Brought into the 21st Century

by Sligo

whaaaaaaaaaaaaaaaaaaaaaat? 2 decades? seriously? common moco!

The Washington Business Journal has details today of a planned $625 million revamping of The Blairs apartments that includes demolishing some existing buildings and getting rid of the Giant Food. The project is expected to take two decades (LOL, this is MoCo - actual time: four decades) and include features like a dog grooming station and something called "bioswales". I could regurgitate more information here, but you're better off just reading the article yourself.

The renderings sure do look nice, but don't they always?


24 Apr 20:36

Official Report: Transit Center "Severely Compromised"

by Sligo

More from the Gazette here.

According to Foulger-Pratt, they're just looking out for the people of their community. Why didn't the county just have a beer with F-P's clearly stellar engineers and hash this all out?
In a response to the report, Foulger-Pratt said, “The way in which this report was developed, however, is indicative of the county’s conduct throughout this entire process. Everyone in this community — including us — has been waiting for more than a year for the county to act. During that time, we made numerous requests for meetings between our engineers and the county’s engineers in order to sit down, as professionals, address any concerns and more forward for the benefit of the community.
You're doin' a heckuva job, Folger-Pratt! (Corporate motto: "We Build to Last")

Interestingly, the banner of FP's corporate website features a transit center-free downtown Silver Spring and the banner that once proudly hung from the worksite has been unceremoniously removed. Maybe they are trying to whitewash the whole project out of existence.


24 Apr 20:31

Pasting images from clipboard in FogBugz comments

by fmansoor

Life changing


FogBugz supports embedding image in case comments, but, you have to save the image to a file first, even then it appear at the end of the case comment. It would have been great if FogBugz used HTML5 clipboard API and allowed users to paste image directly from clipboard on supported browsers.

The good news is that FogBugz allows javascript customizations, so I came up with a small script to support for pasting images from clipboard myself. To apply the script, navigate to customizations from My Settings > Customizations on the top right hand corner of the page, add a new customization and paste the code from this script.


Now you should be able to paste images in FogBugz cases directly without having to save them to file. Clipboard support along with a screen capture software like GreenShot makes embedding images in case comments much more simpler and faster.

The script creates a new img element and sets base64 image data to its src property. This significantly increases the size of the html page, but, upon post, FogBugz rips out this base64 data and creates an actual image attachment from it, so this technique does not cause page bloating.


24 Apr 20:19

When Answering Email Is A Career Setback

by Drake Baer

It's minimally rewarding to get lost in a sea of email--both for your psyche and your career development. Here's what to do about it.

Cal Newport caught our attention with one insight: Don't follow your passion.

So how about another: "Knowledge workers are bad at working."

Why? You probably already have an idea: because we're mired in tasks. Like Newport says, if you're a chess player, you'll spend thousands of hours dissecting games of better players. If you're a violinist, you'll practice until your fingertips get calluses. If you're a knowledge worker, you try to get to inbox zero.

Are there any rules?

Let's go back to the violinist. It's tempting to make the conclusion that musician do things like nutso music camps to inch closer to the 10,000 hours that Malcolm Gladwell said is the secret of success. Let's avoid that.

As Frans Johansson observes in The Click Moment, the 10,000-hour approach only really works in fixed environments. In tennis, chess, and classical music, the rules are reasonably set, so over enough time, a talented and assiduous student can technically master them.

But most of the world isn't so fixed. The start of the Twilight series literally came to the as-yet-unpublished Stephanie Meyer in a dream. Then, of course, there's startups: The Internet collectively went green with envy when Summly--whose founder Nick D'Aloisio is a ripe 17 years old--got acquired by Yahoo for $30 million.

If there is a pattern, what is it?

Similar to productivity master Bob Pozen's ethos of step-by-step optionality--where you maximize your chances for the next, better gig by developing in-demand skills at your present job--Newport espouses what he calls career capital theory. By making stuff that people want--not necessarily by following your passion--you make wealth.

So how do you build career capital? Newport wrote a whole book about it. But, to begin, give yourself enough time to immerse yourself in your big projects--that's where you'll be able to do the work that stretches your skillset and creates new value for your team.

And if you feel like you'd never have to do that, you might want to talk to your boss--and put away your phone.

How do you give yourself a situation where you can do your best work? Tell us in the comments.

How to Write Six Important Papers a Year without Breaking a Sweat: The Deep Immersion Approach to Deep Work

[Image: Flickr user Vincent Lock]

21 Apr 14:53

Use pseudovariable $exception rather than declaring an unused exception variable

by fmansoor

Occasionally, I see catch blocks with unused exception variables.


Probably developer declare the variable so that they can inspect the exception while debugging, but, then forget to delete it. Since the unused variable results in a compiler warning (”The variable ‘ex’ is declared but never used”), its better to use pseudovariable $exception rather than declaring variable, if you need it just for debugging.


Visual studio also adds the variable to locals variables window by default.