Archive

Author Archive

More Reasons For Testing: Prevent The Morning-After Syndrome

March 11th, 2010

Testing (Test Driven Design, Unit Testing, Mocking) is pretty much a part of developer popular culture - most developers understand that by writing the tests first we’re forced to focus on the important details as we build software, that by writing tests we prove that our software works as we build it, and that by running our test suite against our changes we gain assurance that our code still works, but did you know that testing is also a cure for the ‘morning-after syndrome’?

The ‘morning-after syndrome’ as described by Uncle Bob (Robert C. Martin):

Have you ever worked all day, gotten some stuff working, and then gone home, only to arrive the next morning to find that your stuff no longer works? Why doesn’t it work? Because somebody stayed later than you and changed something you depended on! I call this ‘the morning-after syndrome’. - Robert C. Martin, Agile Principles, Patterns, and Practices in C#

Bob makes the point that by writing tests we make our code more stable and brittle to change, which prevents our coworkers from making casual breaking changes. Sure-sure, brittle tests are frustrating when refactoring, but at the same time these brittle tests accentuate the importance that the code under test should not be modified. Core components that your system depends on should be stable and brittle.

Bob continues:

Many factors make a software component difficult to change: its size, complexity, clarity, and so on. But we are going to ignore all those factors and focus on something different. One sure way to make a software component difficult to change is to make lots of other software components [like tests] depend on it. A component with lots of incoming dependencies is very stable, because it requires a great deal of work to reconcile any changes with all the dependent components. - Robert C. Martin, Agile Principles, Patterns, and Practices in C#

Author: Adam Kahtava Categories: Book, Quality Assurance, Testing Tags:

Memcached On PowerShell

March 9th, 2010

Memcached has been around for a while, but it's still pretty neat.

Experiencing a bottleneck with your Object Relational Mappers, Services, Middleware, Database, or whatever? Then Memcached it!

Memcached was intially developed for LiveJournal by Danga Interactive in 2003, and is used by many large sites (YouTube, Amazon, Twitter, to name a few). Today, you can find a Memcached library for all your favourite languages (here's the list).

Now; cache testing is tough period, and testing Memcached (which is accessed through a telnet client) is even more difficult - it's fair to mention that there are a large number of wrappers for Memcached outside the .NET world, but I couldn't find one for that met my needs.

So... I wrote my own. :)

Introducing Memcached on Powershell

Sample usage and output

Loading the script (source can be found here)

PS C:\> .\memcached-on-powershell.ps1

Checking Memcached stats on an empty instance

PS C:\> memcached-stats 127.0.0.1 11211
Total items in cache:  0
No slabs found

Checking Memcached stats after items have been added to the cache

PS C:\> memcached-stats 127.0.0.1 11211
Total items in cache:  3
Stats for Slab:  1
         Key: 'resume-service:resume:adam-kahtava'
         Key: 'open-source-service:github:adamdotcom'
         Key: 'open-source-service:googlecode:adam.kahtava.com'

Clearing all Memcached items

PS C:\> clear-memcached-items 127.0.0.1 11211
Total items in cache:  0

Checking Memcached stats on a cleared instance

PS C:\> memcached-stats 127.0.0.1 11211
Total items in cache:  0
Stats for Slab:  1
         Empty

If your test obsessed then you might be interested in the Memcached tests.

As always feel free to contribute, view, or download the source here.

Author: Adam Kahtava Categories: .NET, PowerShell, Testing Tags:

Developers, Don’t Let Your Babies Grow Up To Be Programmers

March 2nd, 2010

Experts continue to warn of a looming shortage of North American scientists, engineers, developers, and IT workers in general. Efforts like the K-12 CS Model Curriculum attempt to introduce computer science concepts to children as they progress through grade / high school in hopes that they'll fill this void, but there's another issue in play. Developers don't let their children grow up to be programmers.

My hunch is that, most engineers, developer, or related IT professional would rather see their children succeed them - becoming doctors and lawyers and such, not an IT professional.

Malcom Gladwell (in Outliers) presents an interesting account of career progressions within family trees:

In 1982, a sociology graduate student named Louise Farkas went to visit a number of nursing homes and residential hotels [she was looking for] the children of people [who had immigrated] at the turn of the last century. And for each of the people she interviewed, she constructed a family tree showing what a line of parents and children and grandchildren and, in some cases, great-grandchildren did for a living.

Here is her account of "subject #18":

A Russian tailor artisan comes to America, takes to the needle trade, works in a sweat shop for a small salary. Later takes garments to finish at home with the help of his wife and older children. In order to increase his salary he works through the night. Later he makes a garment and sells it on New York streets. He accumulates some capital and goes into a business venture with his sons. They open a shop to create men's garments. The Russian tailor and his sons become men's suit manufacturers supplying several men's stores The sons and the father become prosperous. The sons' children become educated professionals.

Farkas's ... family trees go on for pages, each virtually identical to the one before

From my observations, many developers / IT workers are first generation middle class, first generation post secondary educated, immigrants, or all of the above (myself included). Being a developer or IT professional is a small step up the ladder in helping our successors succeed.

Author: Adam Kahtava Categories: Musings Tags:

The Project Badge: Show The World Your GitHub and Google Code Projects On Your Blog

February 24th, 2010

The Project Badge displays your GitHub and Google Code projects in a badge that can be displayed on your site. This widget was built on the data being returned from my Open Source Service.

View this post outside your RSS reader to see it in action or view it here.

The source for the Project Badge can be found here and the source for the accompanying service can be found here. A list of all my publicly available web services can be found here.

Using The Project Badge On Your Website or Blog

1. Add The Asset References

Add the following asset references, and a reference to jQuery (if you don't have one already).

<link rel="stylesheet" type="text/css" href="http://github.com/AdamDotCom/project-badge/raw/master/project-badge.css" />
<script type="text/javascript" src="http://github.com/AdamDotCom/project-badge/raw/master/projectBadge.js"></script>

2. Configure Your Accounts

Set your project accounts (it's OK if you only use one host) then optionally set the appropriate filters - in my case my Google Code projects were prefixed with adamdotcom and I had duplicate projects on both GitHub and Google Code. By specifying remove:adamdotcom,remove:duplicate-items in my filters I filter out the duplicates and removed adamdotcom from the project name.

<script type="text/javascript">
  projectBadge.load({
      gitHub: 'AdamDotCom',
      googleCode: 'adam.kahtava.com'
    },{
      filters: 'remove:adamdotcom,remove:duplicate-items,remove:-'
    });
</script>

3. Add The Widget Hook
Add an element to your site or blog with the id of project-badge.

<div id="project-badge">
  Loading...
</div>

That's it!
If you have any issues, use the the working example as a reference, or send me a message.

Introducing my Open Source Projects Service: Grab Your Project Details From GitHub or Google Code

February 11th, 2010

Say hello to the newest member of my service family; the Open Source Project Service. This service lets me (and you too my friends) grab our project details from either Google Code, or GitHub.

How it works

If you have a project on GitHub or Google Code, you can retrieve your project details.

Single project host retrieval URI:

http://adam.kahtava.com/services/open-source/projects/{project-host}.{xml|json}?user={username}

Multiple project host retrieval URI:

http://adam.kahtava.com/services/open-source/projects.{xml|json}?project-host:username={project-host1:username1,project-host2:username2}

Example, requesting projects from Google Code in XML format:

Request: http://adam.kahtava.com/services/open-source/projects/googlecode.xml?user=adam.kahtava.com

Response:

<Projects xmlns="http://adam.kahtava.com/services/open-source" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
  <Project>
    <Description>The site source in use on Adam.Kahtava.com / AdamDotCom.com (http://adam.kahtava.com/)</Description>
    <LastMessage>More code coverage on controllers required!! :)</LastMessage>
    <LastModified>2010-02-26</LastModified>
    <Name>website</Name>
    <Url>http://code.google.com/p/adamdotcom-website</Url>
  </Project>
  ...
</Projects>

Example, requesting projects from GitHub in JSON format:

Request: http://adam.kahtava.com/services/open-source/projects/github.json?user=adamdotcom

Response:

[
  {
    "Description":"A collection of my etcetera, so forth, and so on. Contains a PowerShell script for Twitter, a programming exercise in Ruby, a programming exercise for Google done in JavaScript.",
    "LastMessage":"Bing-bing, changing filenames",
    "LastModified":"2009-06-08",
    "Name":"scripts",
    "Url":"http:\/\/github.com\/AdamDotCom\/scripts"
  },
  ...
]

Example, requesting projects from both GitHub and Google Code in a single request in XML form:

Request: http://adam.kahtava.com/services/open-source/projects.xml?project-host:username=github:adamdotcom,googlecode:adam.kahtava.com

Response:

<Projects xmlns="http://adam.kahtava.com/services/open-source" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
  <Project>
    <Description>Displays your public source code repositories from Google Code and GitHub.</Description>
    <LastMessage>Added http://code.google.com/p/adamdotcom-services/ link</LastMessage>
    <LastModified>2010-02-23</LastModified>
    <Name>project badge</Name>
    <Url>http://github.com/AdamDotCom/project-badge</Url>
  </Project>
  ...
  <Project>
    <Description>The site source in use on Adam.Kahtava.com / AdamDotCom.com (http://adam.kahtava.com/)</Description>
    <LastMessage>More code coverage on controllers required!! :)</LastMessage>
    <LastModified>2010-02-26</LastModified>
    <Name>website</Name>
    <Url>http://code.google.com/p/adamdotcom-website</Url>
  </Project>
  ...
</Projects>

And Now What?

View my sidebar widget that uses this service to display the latest updates from my source code repositories here.

Contribute, view, or download this openly available source code here.

Author: Adam Kahtava Categories: .NET, ADC Services, Open Source, RESTful, Services, WCF, XML Tags:

Tired of Strong Opinions Weakly Held

February 9th, 2010

Strong opinions weakly held is a common conversational / debating approach within IT. Basically you defend your opinion until someone disproves it, at which time you adopt the more correct opinion. This approach works well in IT where allotted time for debates are limited and the cumulative knowledge of the team outweighs the individual. This approach doesn't work as well in the real world. Using this technique with unsuspecting civilians (especially new acquaintances) can results in the victim thinking you're a) high strung, b) psychotic, c) egotistical, d) possibly a jerk. Actually, this approach can get tiresome in the IT realm too.

Author: Adam Kahtava Categories: Musings Tags:

Preaching to the Choir

February 1st, 2010

I go for a walk every day (yeah-yeah, I'll be a mall walker one day). My route takes me by a series of automated parking payment machines - the ones where you punch in your license plate along with a parking quadrant. Surprisingly enough, these machines provide endless comedic relief as people talk, grumble, and curse these inanimate objects - some people go as far as to physically assault them, jam their keys in them, give 'em a good kick. It's funny to watch a level headed business man break his cool as he uses a car key to fish around in the coin slot while cursing. My favorite responses are the talkers; grumbling about the price of parking or technology in general. I'm sure they know the machine can't hear them, but yet they give that box of wires a piece of their mind.

If these talkers and grumblers were on the internet they'd most certainly be on Twitter or have a blog.

Author: Adam Kahtava Categories: Musings Tags:

Algorithm Analysis and Asymptotic Complexity / Big O Notation Is Important

January 21st, 2010

Algorithm Analysis (Asymptotic Complexity / Big O Notation) courses are the bane of computer science students everywhere. These courses were mandatory, dry, and lacked real world pragmatism for students who just wanted to get stuff done. Well, that's what we told ourselves; that's the theory we presented to our friends - we were convinced that framework vendors or the hoogie-boogie man would figure out the most efficient way to performance tune / compile our code. We looked to Sun, Microsoft, or IBM to figure out the details. In truth we were lazy-naive students and Algorithm Analysis was tougher than we'd like to admit - much harder than programming in 4th generation programming languages, more difficult than computer theory, or operating system theory.

As I brush up Algorithm Analysis I found these perspectives interesting:

to be a good programmer, you just program ever day for two years ... to be a world-class programmer, you can program every day for ten years, or you can program every day for two years and take an algorithms class - Introduction - Analysis of Algorithms, Insertion Sort, Mergesort

Having a solid base of algorithmic knowledge and technique is one characteristic that separates the truly skilled programmers from the novices. With modern computing technology, you can accomplish some tasks without knowing much about algorithms, but with a good background in algorithms, you can do much, much more - Introduction to Algorithms, Second Edition

It's unfortunate that our professors never mentioned that Algorithm Analysis would be an integral part of academic type interviews and a prerequisite for getting a job at Google, but then again who would have listened?

Author: Adam Kahtava Categories: Musings Tags:

Sending Email With Attachments In PowerShell

January 19th, 2010

Here's an example on how to send email with attachments via PowerShell:

# A Mailer script that makes use of System.Net to send email with attachments
#
# Sample usage:
#  PS C:\> Send-Mail-With-Attachment 'email@domain.com' 'Hello world!' 'Filename.txt'

function global:Send-Mail-With-Attachment($to, $subject, $file){

  $filenameAndPath = (Resolve-Path .\$file).ToString()
  $from = 'Automated Powershell Mailer'

  [void][Reflection.Assembly]::LoadWithPartialName('System.Net') | out-null

  $message = New-Object System.Net.Mail.MailMessage($from, $to, $subject, $subject)
  $attachment = New-Object System.Net.Mail.Attachment($filenameAndPath, 'text/plain')
  $message.Attachments.Add($attachment)

  $smtpClient = New-Object System.Net.Mail.SmtpClient
  $smtpClient.host = 'mail.domain.com'
  $smtpClient.Send($message)
}

Contribute, view, or download the script here: Mailer.ps1

Author: Adam Kahtava Categories: .NET, PowerShell Tags:

Life’s Creative Circle: Creativity Isn’t About Art or Design

January 14th, 2010

The most popular conception of creativity is that it's something to do with the arts.

Nonsense. - Paul Arden, It's Not How Good You Are, It's How Good You Wan't To Be.

This year marks a new decade for me (I'm saying goodbye to the late 20's). According to Arden's Creative Circle this blog was written during my era of Maturity and for the next 10 years I'll be Hell Bent On Success. Thanks for putting up with my growing pains and griping.

Author: Adam Kahtava Categories: Creativity, Musings, Personal Tags: