Wednesday, December 17, 2008

Shorty Twitter Award Recommendations

For those of you who have not yet heard, the Shorty Awards are now open for nominations...

What is the Shorty Awards?

The best producers of short* content in 2008 *140 characters or less, on Twitter

The Shorty Awards honor the world's top Twitterers. You can nominate as many people for as many categories as you'd like until midnight December 31st.

How it works...

Here are some nominations that I recommend...

Categories

Please leave a comment with your own recommendations...

... and again, if you've benefited from my blog or my tweets would you please consider nominating me for the #programming category in shorty twitter awards?

Thank you, and happy tweeting!

Monday, December 08, 2008

Customized .NET Coffee Cup

My wife and I went out on a much needed date after a dry spell of alone time. I thought either we could do the typical movie thing, or maybe we could do something more interactive in nature.

So, with the help of my tweeters we came up with the idea of Painting Pottery at All Fired Up in Nashville, TN.

Then comes the hard part what does a computer geek programmer paint on a piece of pottery? Ahh... well, computer geek terms of course!

Here are some pictures of the coffee mug that I painted. I plan to bring it to work and drink from it proudly :)

Although I am an avid coffee drinker... I think you can tell that I like to drink the .NET kool-aid too :)

Friday, December 05, 2008

The Next 20 People .NET Developers Should Follow on Twitter

My previous 20 People .NET Developers Should Follow on Twitter blog post seemed to have gained quite a bit of buzz around the Twitterverse. I initially had a hard time narrowing down my list to only 20 people, so I thought I would include the next 20 several people that I wanted to add, but didn't.

Note: My list of top 40 (last post and this one) aren't necessarily the most popular or famous twitter people around (although many of them are). Rather, they are top notch developers that I highly value their contribution and tweets and find them to be very beneficial in learning and my day to day work.

Here are the Top 21-40 .NET Developers You Should Follow on Twitter

Steve Andrews
386 Followers
Jason Barile
82 Followers
Jeff Blankenburg
520 Followers
Marc Brooks
408 Followers
Michael Feathers
698 Followers
Justice Gray
322 Followers
Steven Harman
677 Followers
Evan Hoff
242 Followers
Scott Koon
1,354 Followers
Boyan Kostadinov
64 Followers
James Kovacs
222 Followers
Dan Mohl
18 Followers
Craig Murphy
398 Followers
Chad Myers
431 Followers
Ted Neward
516 Followers
Tommy Norman
65 Followers
Robert Pickering
53 Followers
Matthew Podwysocki
413 Followers
Alan Stevens
622 Followers
Chris Woodruff
579 Followers

Ohh, and you are welcome to follow me as well on Twitter :)

Wednesday, December 03, 2008

20 People .NET Developers Should Follow on Twitter

I have been tweeting for quite some time now and I have found it to be a very interesting way to stay top of the technical pulse of .NET, jQuery, and numerous other technologies and tools.

For those of you developers that have recently started using Twitter, here is a brief list of 20 people that I think you would gain a lot of insight from by following.

Please understand that there are many others that I could list, but for brevity I chose only the top 20. The following individuals are in alphabetical order.

Please feel free to add a comment with your favorite top developer twitter individuals. I would love to follow them and I'm sure others would as well.

*Note: My interests mainly revolve around Microsoft ASP.NET, ASP.NET MVC, ASP.NET AJAX, other .NET Technologies, jQuery, JavaScript, XHTML, CSS, XML, etc...

Thursday, November 20, 2008

VSTS 2010 Local Microsoft Event

Last night I went to a local Microsoft Event demonstrating the cool new features of VSTS 2010 presented by Mark Mydland (Principal Group Manager of VSTS Test).

Mark demonstrated numerous new features of VSTS 2010 such as...

  • Allowing the tester to automatically capture data to eliminate no-repro bugs
  • Allowing the developer to immediately navigate to the problem code
  • Creating automating test cases with coded UI test
  • And much more...

In addition Mark demonstrated some products that have recently come out of Microsoft Research...

  • Pex
    "Right from the code editor, Pex finds interesting input-output values of your methods, which you can save as a small test suite with high code coverage. Pex performs a systematic analysis, hunting for boundary conditions, exceptions and assertion failures, which you can debug right away."

    If you are new to Pex, you might want to check out the following resources...


  • CHESS
    "CHESS is an automated tool for finding errors in multithreaded software by systematic exploration of thread schedules. It finds errors, such as data-races, deadlocks, hangs, and data-corruption induced access violations, that are extremely hard to find with current testing tools. Once CHESS locates an error, it provides a fully repeatable execution of the program leading to the error, thus greatly aiding the debugging process."

    If you are new to CHESS, you might want to check out the following resources...

Feel free to download Visual Studio 2010 and .NET Framework 4.0 CTP and start playing with it today.

Note: If you were unable to make this talk, then there is a PDC video covering most, but not all of the content entitled Microsoft Visual Studio Team System: A Lap Around VSTS 2010 by Cameron Skinner (Product Unit Manager on the VSTS team). Here is a brief description of the video...

"In the spirit of an agile sprint, see how to use the next version of Visual Studio Team System to manage user stories and re-factor existing architecture. Learn how to diagnose real production problems, debug in-production virtual labs, capture test data to eliminate the no-repro bugs, transparently plan, monitor, and adapt software projects."

Thank you Compuware for sponsoring the event!

Wednesday, November 19, 2008

Tech Twitterings via jQuery & Twitter

Several weeks ago, I decided to start a weekly blog entry compiling a list of my technical tweets from Twitter. After the second week, I noticed that it was taking me much too long to compile the list, so I decided to create a tool to make it easier.

My current solution involves several Firefox add-ons, jQuery, and Twitter. Eventually, it would probably be much easier if I used the Twitter APIs directly, but for now I have found this solution to be a fun learning exercise :)

Steps to Create the Tech Twitterings Entry
  1. Search for my technical (#tech) tweets from Twitter
  2. Use the Firefox AutoPager add-on to automatically load the next several pages to capture all the tweets from the last week.
  3. Use the Firefox Greasemonkey add-on and run the Load jQuery Library script to load the jQuery library onto the Twitter search page
Load jQuery Library
// ==UserScript==
// @name           Load jQuery Library
// @namespace      http://webdevdotnet.blogspot.com
// @include        http://search.twitter.com/*
// ==/UserScript==

//Code taken from http://internetducttape.com/2008/05/08/greasemonkey-ninja-jquery/
var GM_JQ = document.createElement('script');
GM_JQ.src = 'http://jquery.com/src/jquery-latest.js';
GM_JQ.type = 'text/javascript';
document.getElementsByTagName('head')[0].appendChild(GM_JQ);

function GM_wait() {
   if (typeof unsafeWindow.jQuery == 'undefined') { 
      window.setTimeout(GM_wait,100); 
   } else { 
      $ = unsafeWindow.jQuery; letsJQuery(); 
   }
}
GM_wait();
    
function letsJQuery() {
   unsafeWindow.console.log('The jQuery Library has been loaded'); 
} 
  1. Use the Firefox Firebug add-on and use it's console (F12) to run the jQuery Twitter Script
jQuery Twitter Script
$('li.result .msg .msgtxt .expand').remove();
var categories = new Array();
var categoryKeys = new Array();
$('li.result .msg .msgtxt').each(function(i,tweet) {
   var tweetText = $(tweet).text();
   var regularExpression = new RegExp('.*#tech.*(#\\w+).*', 'gi');
   var matches = regularExpression.exec(tweetText);
   if (matches != null) {
      var match = matches[1];
      if (categories[match] == null ) {
         categories[match] = new Array();
         categoryKeys.push(match);
      }
      categories[match].push(tweetText);
   }
});
for (var i = 0; i < categoryKeys.length; ++i) {
   var categoryKey = categoryKeys[i];
   console.log('<h3>' + categoryKey + '</h3><ul>');
   var category = categories[categoryKey];
   for (var j = 0; j < category.length; ++j) {
      console.log('<li>' + category[j] + '</li>');
   }
   console.log('</ul>');
}
  1. Copy & Paste the contents from the console into Blogger
  2. Surround the auto-generated HTML content in a div and prepend the JavaScript to convert Text to Hyperlinks.
Text to Hyperlink JavaScript
<script type='text/javascript'>  
$(document).ready(function() {
   $('#tt4').html(replaceUrlWithHtmlLinks($('#tt4').html()));
});

function replaceUrlWithHtmlLinks(text) {
    var exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
    return text.replace(exp,"<a href='$1'>$1</a>"); 
}
<div id="tt4">
<!-- Insert Autogenerated jQuery Twitter HTML here... -->
</div>
</script>

Wednesday, November 12, 2008

New F# SyntaxHighlighter Brush

Ever since my previous blog about Code Highlighters For Your Blog, I have heard several people interested in implementing the SyntaxHighlighter on their blog. If so, there is a good article by Guogang Hu about integrating it into your Blogger blog.

One of those individuals was my friend, Daniel Mohl (via twitter... @dmohl). However, Daniel had a need to support F#, which is not one of the out-of-the-box languages that is supported by the SyntaxHighlighter. I saw this as a fun side project to support this language for him.

F.Y.I. If you like F#, his blog is definitely one you should check out!

Here is an example F# program that is only a proof of concept that Dan put together for me to exercise the F# brush sufficiently... it doesn't actually work! :) I am just starting to learn the language, so please give me some slack!

If you find any areas that I missed while supporting the language, please let me know and I'll fix it. Feel free to download and use the F# SyntaxHighlighter Brush and provide any suggestions or comments.

Note: The JavaScript file has been minimized with JSMin, so it might be a little difficult to read.

I'd like to contribute the F# Brush to the Google Code project, but I am not yet a contributor on the project. If I am able to become a contributor, then I will post the code as part of the main project.

#light
namespace testforElijah
module testModuleForElijah
open System
let multiple x = x * x
val CalculateSeqExample: seq<int> -> int
type ICustomerDao = interface
    abstract GetById: int -> ICustomer
end
type CustomerDao = class
    new: unit -> CustomerDao
    interface ICustomerDao
end
if
then
elif
else
@"c:\test\test.xml"
'c'
"xyz"B
"tes"+"t"
[for x in list -> expr]
type 'a option = 
  | None
  | Some of 'a

//This is a test
let showSomething (name, something)
  match name with
    | Some  (some, thing) -> (* do something*)
    | None
 
type node = 
  { Name : string;
    Links : list list;}
and link = 
  | Dangling
  | Link of node 

Tuesday, November 04, 2008

Enum Parse Extension Methods

When I write code I don't like to depend on catching exceptions to control my programming logic, so as much as I can I try to check for nulls, empty, etc...

When parsing one type into another there are usually TryParse() methods available so that an exception does not occur. I've always been a little confused why there wasn't such a method off the Enum class. So, I decided to make my own.

However, after I started to extend the TryParse method off of the Enum, the answer started to become clear why that was not a feature :) I could extend the actual specific enum, but that didn't really help me any. I wanted a Generic solution for all enums.

So, instead of making an Enum.TryParse(), I decided to extend the string class to add string.ToEnum() and string.TryToEnum(). The string is usually the class that I want to parse into a specific Enum after all.

The following is the Extension methods that I created...

using System;

namespace Web.Helpers {
    public static class EnumHelper {
        public static bool TryToEnum<T>(this string obj, out T parsed) {
            bool isParsed = false;

            if (Enum.IsDefined(typeof(T), obj)) {
                parsed = (T)Enum.Parse(typeof(T), obj);
                isParsed = true;
            } else {
                parsed = (T)Enum.Parse(typeof(T), Enum.GetNames(typeof(T))[0]);
            }

            return isParsed;
        }
        
        public static T ToEnum<T>(this string obj) {
            return (T)Enum.Parse(typeof(T), obj);
        }
    }
}

I created a set of 4 MS Unit tests to exercise different scenarios that might exist. Let me know if you see any other tests that I should test.

using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Web.Helpers;

namespace WebTests.Generic {
    [TestClass]
    public class EnumTest {
        public enum Color { Red, Orange, Yellow, Green, Blue, Indigo, Violet };

        [TestMethod]
        public void TryToEnumWorksWithValidEnum() {
            Color parsedColor = Color.Blue;

            string realColor = "Yellow";
            bool canParse = realColor.TryToEnum<Color>(out parsedColor);
            Assert.AreEqual(true, canParse);          
        }

        [TestMethod]
        public void TryToEnumWorksWithInvalidEnum() {
            Color parsedColor = Color.Blue;

            string fakeColor = "Elijahish";
            bool canParse = fakeColor.TryToEnum<Color>(out parsedColor);
            Assert.AreEqual(false, canParse);
        }

        [TestMethod]
        public void ToEnumWorksWithValidEnum() {
            Color parsedColor = Color.Blue;

            string realColor = "Yellow";
            parsedColor = realColor.ToEnum<Color>();
            Assert.AreEqual(Color.Yellow, parsedColor);
        }

        [TestMethod, ExpectedException(typeof(ArgumentException), "Unable to parse enum")]
        public void ToEnumThrowsExceptionWithInalidEnum() {
            Color parsedColor = Color.Blue;

            string fakeColor = "Elijahish";
            parsedColor = fakeColor.ToEnum<Color>(); 
        }
    }
}

Have you found yourself doing some sort of the same thing? If so, how?

Friday, October 31, 2008

Code Smell Riddle #22

q. I have two sets of methods
that basically do the same work.
Change their name and code to match
Or I will certainly go berserk!

a. Parallel Inheritance Hierarchies

If you need help, here is a LIST of the remaining 2 Code Smells for this riddle series.

For a list of the 22 Code Smells feel free to visit the Code Smells website.

Post a comment with your guess :)

~/riddle by me

Code Highlighters For Your Blog

I recently tweeted that I thought the SyntaxHighlighter is the best way to display code on your blog. In response, I had some who were a little confused how to get started with the tool. The tool isn't as straight forward as some other tools. There are several steps you will need to take in order for it to work on your blog.

Since my tweet, I have reconsidered my initial recommendation for new users. The look and features of SyntaxHighlighter are nice, but it does take some setup on your blog, some manual manipulation of your code, and presents a slight delay during render time (since it is dynamically manipulated via JavaScript).

I plan to start using SyntaxHighligher from now on and I would recommend it for bloggers that post a lot of code, but if you an occasional code poster, then one of the following Windows Live Writer plug-ins might be a better solution for you (they are much simpler and faster to render and takes no setup on your blog). All that said, you might even like the plug-ins better than SyntaxHighlighter... and hey, that's fine by me :)

The Windows Live Writer plug-ins that I recommend are...

Thursday, October 30, 2008

An NDepth Look @ NDepend

Synpopsis

I've been wanting to review NDepend for quite some time, but I figured it was bad form to run it against my production code from work.

So, instead of running the tool against my work code, I thought I'd use the PetShop ASP.NET MVC project that I created for the .NET User's Group.

NDepend provides many ways to visualize the architecture of any particular project.  To create the following pictures and diagrams all I did was point NDepend to my Visual Studio solution file.

Dependency Graph

A useful way to get an understanding of how your application architecture is to generate a Dependency Graph based off your code. The following graph shows show the PetShop pieces relate to one another.

 

Dependency Matrix

For those of you who are graphically challenged, there is a Dependency Matrix that does a nice job of showing how many dependencies there are between 2 particular areas of your design.

  

Code Metrics

The next diagram has always impressed me. Even if you didn't know what it meant... it is pretty impressive to just look at :) The following diagram is actually showing the Code Metrics for your project. The following image represents the number of lines of code (LOC) in your project.  


CQL Queries

In addition to all these cool graphs, matrices, and images, there are some hard core queries that you can perform against your assemblies. NDepend has something called Code Query Language (CQL) that allows you to write custom queries to identify numerous statistics such as:
  • Which public methods have more than 30 lines of code?
  • Which classes implement System.IDisposable?
  • Which methods have been refactored recently and is not thoroughly covered by tests?
  • etc...

 

The following is an example of what a CQL query looks like. This query identifies the methods that are too big in your assembly. NDepend comes with a library of already created queries, such as this one, but you are able to add to or customize these quieres as well. 


Conclusion

There is so many more features that I haven't covered that NDepend provides, but I wanted to highlight some of the features that I thought are very useful and could help you in your current projects.

I think this tools adds some great functionality that dovetails nicely with the features of from the various Visual Studio suites.

Don't just take my word for it, I encourage you to download a trial version of NDepend and check it out for yourself.

Then if you like it, make a list of the features that are useful for your project, show it to your boss, and see if your work will pay for it :)

Code Smell Riddle #21

q. A collection of reusable methods,
Can be extremely handy when in a bind,
But can be all together aggravating,
When the desired one, you can not find!

a. Incomplete Library Class

For a list of the 22 Code Smells feel free to visit the Code Smells website.

Need help? Here is a list of remaining Code Smells for this riddle series.

Post a comment with your guess :)

~/riddle by me

Monday, October 20, 2008

Code Smell Riddle #20

q. I'm not fond of your scavenger games;
I like my things to be easily found.
So please move your code in such a way,
That change doesn't require a look around!

a. Divergent Chang

For a list of the 22 Code Smells feel free to visit the Code Smells website.

Need help? Here is a list of remaining Code Smells for this riddle series.

Post a comment with your guess :)

~/riddle by me

Tuesday, October 14, 2008

Code Smell Riddle #19

q. Between you and me I tend to be quite the conundrum;
A side effect of complexity way beyond my own good.
Unless you extract me from my overly convoluted mess,
I will forever be thoroughly dazed and misunderstood.

a. Temporary Field

For a list of the 22 Code Smells feel free to visit the Code Smells website.

Need help? Here is a list of remaining Code Smells for this riddle series.

Post a comment with your guess :)

~/riddle by me

Monday, October 13, 2008

Code Smell Riddle #18

q. I love to be on the cutting edge of ignorance;
Black boxes are the greatest thing since sliced bread.
But if the smoke and mirrors point to another box,
Then you might as well just send me there instead.

a. Middle Man

For a list of the 22 Code Smells feel free to visit the Code Smells website.

Need help? Here is a list of remaining Code Smells for this riddle series.

Post a comment with your guess :)

~/riddle by me

Friday, October 10, 2008

Code Smell Riddle #17

q. When you link method to method,
I can get super long really quick.
You should cut out the middle man;
Breaking the hierarchy is the trick.

a. Message Chains

For a list of the 22 Code Smells feel free to visit the Code Smells website.

Need help? Here is a list of remaining Code Smells for this riddle series.

Post a comment with your guess :)

~/riddle by me

Nashville .NET User's Group Presentation

Yesterday I gave my first User's Group (UG) presentation at the Nashville .NET UG entitled... "A Crash Course in ASP.NET MVC".

In the presentation I gave an overview of what MVC is, explained some pros & cons of using it, answered some common questions, presented a demo application that I developed (Pet Shop 5), and then I dived into the demo's code.

You can download the content that I presented at the User's Group below... *Note: There is some additional slides at the end of the slide show that you might find interesting.

You also might want to check out a blog post I created a month or so ago intended for ASP.NET Web Form developers to quickly get up to speed on the concepts of ASP.NET MVC. A lot of the material is about pre-Preview 5 releases of ASP.NET MVC, but I still think it would be beneficial for most developers. If you so choose, you can directly link to the document hosted on Google Documents.

You might be interested in keeping up with me via:

Email elijah.manor@gmail.com
Twitter http://twitter.com/elijahmanor
.NET Tech blog http://webdevdotnet.blogspot.com
Stack Overflow http://stackoverflow.com/.../elijah-manor
Tech Riddle blog http://manorisms.blogspot.com
Personal blog http://elijahmanor.blogpot.com

Thanks for everyone who came... there was an awesome crowd!

Tuesday, October 07, 2008

Code Smell Riddle #16

q. I store lots of information goodies,
But I take no action whatsoever.
You should find whoever uses me,
Plan to move their logic, and sever!

a. Data Class

For a list of the 22 Code Smells feel free to visit the Code Smells website.

Need help? Here is a list of remaining Code Smells for this riddle series.

Post a comment with your guess :)

~/riddle by me

Monday, October 06, 2008

Code Smell Riddle #15

q. You might consider me small potatoes,
but I'm just as qualified as the rest.
Instead of using those elementary types,
why don't you add some tiny object zest!

a. Primitive Obsession

For a list of the 22 Code Smells feel free to visit the Code Smells website.

Need help? Here is a list of remaining Code Smells for this riddle series.

Post a comment with your guess :)

~/riddle by me

Thursday, October 02, 2008

Code Smell Riddle #14

q. You should really learn to keep to yourself;
There are certain places you should never be.
My private places aren't meant for your eyes,
In regard to your behavior, I highly disagree!

a. Inappropriate Intimacy

For a list of the 22 Code Smells feel free to visit the Code Smells website.

Need help? Here is a list of remaining Code Smells for this riddle series.

Post a comment with your guess :)

~/riddle by me

Tuesday, September 30, 2008

Code Smell Riddle #13

q. It's one thing to view the future proactively,
And then strategically plan accordingly.
But it's an entire other thing completely,
If you over-architect a system excessively!

a. Speculative Generality

For a list of the 22 Code Smells feel free to visit the Code Smells website.

Need help? Here is a list of remaining Code Smells for this riddle series.

Post a comment with your guess :)

~/riddle by me

Monday, September 29, 2008

Code Smell Riddle #12

q. When you want to update your precious program,
Be prepared to embark on a curious coding quest.
Many different pieces certainly need to change;
To find them all you'll need to deeply invest.

a. Shotgun Surgery

For a list of the 22 Code Smells feel free to visit the Code Smells website.

Need help? Here is a list of remaining Code Smells for this riddle series.

Post a comment with your guess :)

~/riddle by me

Friday, September 26, 2008

Code Smell Riddle #11

q. Whoa whoa module global variables,
I think you've propagated like a rabbit.
In addition to the redundant snippets,
You should cut it out like a bad habit.

a. Large Class

For a list of the 22 Code Smells feel free to visit the Code Smells website.

Need help? Here is a list of remaining Code Smells for this riddle series.

Post a comment with your guess :)

~/riddle by me

Thursday, September 25, 2008

IE8 Beta 2 Pros


I do like the Developer Tools that are embedded in IE 8 Beta 2. They are about equivalent to what Firebug is to Firefox, which is a great step in the right direction.

I have also noticed that the errors returned from JavaScript exceptions are much more descriptive and accurate compared to IE7 or before.

Code Smell Riddle #10

q. I'm screaming to be carved into pieces;
I have way too much func inside myself.
If you don't do something relatively soon,
Then time to modify, you'll kick yourself!

a. Long Method

For a list of the 22 Code Smells feel free to visit the Code Smells website.

Need help? Here is a list of remaining Code Smells for this riddle series.

Post a comment with your guess :)

~/riddle by me

Wednesday, September 24, 2008

Code Smell Riddle #9

q. If you look through your vast code base,
And notice code repeated here and there.
You might consider refactoring soon,
Or you'll experience maintenance despair!

a. Duplicated Code

For a list of the 22 Code Smells feel free to visit the Code Smells website.

Need help? Here is a list of remaining Code Smells for this riddle series.

Post a comment with your guess :)

~/riddle by me

Tuesday, September 23, 2008

Code Smell Riddle #8

q. I am the pickiest child that you may ever know.
I only want part of what you gracefully extend.
Many programmers think that I'm not all that bad,
But sharing with a sibling could help to amend.

a. Refused Bequest

For a list of the 22 Code Smells feel free to visit the Code Smells website.

Need help? Here is a list of remaining Code Smells for this riddle series.

Post a comment with your guess :)

~/riddle by me

Monday, September 22, 2008

Code Smell Riddle #7

q. I don't really do all that much for you;
You probably shouldn't even care about me.
It'd be best to move my code elsewhere;
it will save you maintenance, I guarantee.

a. Lazy Class

For a list of the 22 Code Smells feel free to visit the Code Smells website.

Need help? Here is a list of remaining Code Smells for this riddle series.

Post a comment with your guess :)

~/riddle by me

Friday, September 19, 2008

Code Smell Riddle #6

q. I tend to be out of date with your work;
You should rename instead of report.
And if you must then just answer why,
Let the business rules assert support.

a. Comments

For a list of the 22 Code Smells feel free to visit the Code Smells website.

Need help? Here is a list of remaining Code Smells for this riddle series.

Post a comment with your guess :)

~/riddle by me

Thursday, September 18, 2008

Code Smell Riddle #5

q. Given two hierarchies with similar code,
Shotgun surgery can be quite tragic,
But if you move stuff here to there,
Then the result consolidation is magic!

a.

If you need help, here is a LIST of the remaining Code Smells for this riddle series.

For a list of the 22 Code Smells feel free to visit the Code Smells website.

Post a comment with your guess :)

~/riddle by me

Code Smell Riddle #4

q. I'm an unmanageable statement;
Frankly, I clutter and I am frail.
Refactor me to the strategy pattern,
and there is hope your will prevail.

a. Switch Statements

For a list of the 22 Code Smells feel free to visit the Code Smells website.

Need help? Here is a list of remaining Code Smells for this riddle series.

Post a comment with your guess :)

~/riddle by me

Wednesday, September 17, 2008

Code Smell Riddle #3

q. You can find me in a lot of different places;
I tend to live in a distinguishable clique.
I am proliferated across your code base;
extract me to an object, if you're a geek.

a. Data Clumps

For a list of the 22 Code Smells feel free to visit the Code Smells website.

Need help? Here is a list of remaining Code Smells for this riddle series.

Post a comment with your guess :)

~/riddle by me

Monday, September 15, 2008

Code Smell Riddle #2

q. I like to know what's going on elsewhere.
So, I spy on my neighbor object's inside.
I'm a green-eyed monster on the prowl.
I don't know what I'd do if I was denied.

a. Feature Envy

For a list of the 22 Code Smells feel free to visit the Code Smells website.

Need help? Here is a list of remaining Code Smells for this riddle series.

Post a comment with your guess :)

~/riddle by me

Friday, September 12, 2008

Code Smell Riddle #1

q. Using me can be overly cumbersome and result in a brittle implementation,
But I am better than using numerous global variables to help you proceed,
I might actually be acceptable, but you shouldn’t think you’re the exception;
A fragrant approach would be to pass just enough data to get what you need.

a. Long Parameter List

For a list of the 22 Code Smells feel free to visit the Code Smells website.

Need help? Here is a list of remaining Code Smells for this riddle series.

Post a comment with your guess :)

~/riddle by me

Wednesday, September 10, 2008

AntiPattern Riddle #14

q. Depending on the color of your tinted glasses,
The model that you are using may be contrary.
OOA&D is a great approach to design a system,
But your results can most assuredly vary.

a. Ambiguous Viewpoint

For a list of the 14 AntiPatterns feel free to visit the Software Development AntiPatterns website.

Need help? Here is a list of remaining AntiPatterns for this riddle series.

Post a comment with your guess :)

~/riddle by me

Monday, September 08, 2008

IE8 Beta 2 Cons

After much internal debate, today I decided to finally install IE8 Beta 2 on my local development machine.

Unfortunately, my initial experience was filled with annoyance and disappointment.


I first became frustrated by a crazy warning that stated that "Internet Explorer is currently running with add-ons disabled. Click here to manage, disable, or remove your add-ons." Since it said all my add-ons where disabled I thought I'd go check them out, but when I looked all my add-ons were enabled!

After some trial, error, and Googling, I found that the Google Toolbar was the cultrpit and I needed to upgrade to Google Toolbar 5 Beta to resolved the crazy yellow warning. After upgrading, this error went away, and I was actually able to use the Google Toolbar, wheww...


As the day progressed, I started to notice some weird horizontal lines appearing in my browser. Apparently, IE8 Beta 2 wasn't fast enough to redraw certain parts of the web page, so I would these horizontal lines as I scrolled up and down.

I wasn't very impressed with the speed of the rendering as well. It did seem faster than IE7, but I guess I have been spoiled after using Google Chrome for the past week or so.

Stayed tuned and I will give you 'IE8 Beta 2 Pros' in my next post.

AntiPattern Riddle #12

q. Be wary of a simian and a keyboard;
A work of Shakespeare he will not smash.
I perform the best in typic scenarios,
But if you get dotty then I may crash.

a. Input Kludge

For a list of the 14 AntiPatterns feel free to visit the Software Development AntiPatterns website.

Need help? Here is a list of remaining AntiPatterns for this riddle series.

Post a comment with your guess :)

~/riddle by me

AntiPattern Riddle #13

q. I am a dinosaur relic extant in an OO world;
trying to subsist in my old procedural ways.
I am adroit at finding a byzantine solution,
but in the end it may be one gargantuan haze.

a. Functional Decomposition

For a list of the 14 AntiPatterns feel free to visit the Software Development AntiPatterns website.

Need help? Here is a list of remaining AntiPatterns for this riddle series.

Post a comment with your guess :)

~/riddle by me

Friday, September 05, 2008

AntiPattern Riddle #11

q. I encourage you to be cognizant of your surroundings,
because you never know where the next peril may arise.
You'll navigate with a can of Raid Deep Reach Fogger;
Before you know it, the system will need your revise.

a. Walking through a Minefield

For a list of the 14 AntiPatterns feel free to visit the Software Development AntiPatterns website.

Need help? Here is a list of remaining AntiPatterns for this riddle series.

Post a comment with your guess :)

~/riddle by me

Thursday, September 04, 2008

AntiPattern Riddle #10

q. I'm the best tool you've got,
There is no use looking elsewhere.
Use me in each and every situation;
Resist all other options, beware!

a. Golden Hammer

For a list of the 14 AntiPatterns feel free to visit the Software Development AntiPatterns website.

Need help? Here is a list of remaining AntiPatterns for this riddle series.

Post a comment with your guess :)

~/riddle by me

Wednesday, September 03, 2008

AntiPattern Riddle #9

q. I don't actually know what the user wants,
Requirements were taken and then handed to me.
I suppose I'll guess what needs to be done,
because my requirements apparently disagree.

a. Mushroom Management

For a list of the 14 AntiPatterns feel free to visit the Software Development AntiPatterns website.

Need help? Here is a list of remaining AntiPatterns for this riddle series.

Post a comment with your guess :)

~/riddle by me

Friday, August 29, 2008

AntiPattern Riddle #8

q. You better watch me while you are able,
Considering my unique ephemeral lifespan.
I have a limited scope of responsibility;
My purpose is to do the little that I can.

a. Poltergeists

For a list of the 14 AntiPatterns feel free to visit the Software Development AntiPatterns website.

Need help? Here is a list of remaining AntiPatterns for this riddle series.

Post a comment with your guess :)

~/riddle by me

Thursday, August 28, 2008

Special Riddle #2abcd

Note: The answer to the following 4 riddles is the same.

q #2a.
In your mind’s eye envision that you see Bigfoot,
and now change his hair color from brown to red.
Sit him in front of a computer, and let him code;
Rather than Sasquatch, you described me instead!

q #2b.
I overhear your conversations,
At least the last phrase or two.
I always go with the answer...
Of the one whom is not you!

q #2c.
I'll protect you in battle,
I'm your shining armor guitar.
I'll take the heat when it's time,
I stand up for who you are.

q #2d.
I get wrapped up in a lot of meetings,
Much more than I used to back when.
They can take my time and effort,
But they can’t take the Coder within!

a. Dan Mohl

Add a comment with your guess and which of the 4 riddles you liked best!

~/riddle by me

Wednesday, August 27, 2008

AntiPattern Riddle #7

q. Higher management thought I was a great idea,
Of course without any technical evaluation.
You were encouraged to use me lock, stock, and barrel;
But soon it was realized I was a huge frustration.

Then I was shelved with the other misfit silver bullets;
To be replaced with something that really works.
Now I'm just a memory of what should not have been,
and the only mention of me is with disdain and smirks!

a. Boat Anchor

For a list of the 14 AntiPatterns feel free to visit the Software Development AntiPatterns website.

Need help? Here is a list of remaining AntiPatterns for this riddle series.

Post a comment with your guess :)

~/riddle by me

Tuesday, August 26, 2008

Special Riddle #1

q. I'm not a type of insect, although Abe Lincoln might call me so.
I'm an expert with the keyboard, with XSL, and SQL as you know.
I have an internal heater therefore I can never get a hint of cold;
I've been shot numerous times by bands that I've gotten quite bold.
I'm leaving the country now, but I'll still be somewhere around;
You might not see my face, as such, but I can be digitally found.

a. Ananthalvan Soundarajan

~/riddle by me

Monday, August 25, 2008

AntiPattern Riddle #6

q. I'm so easy to slide into your code
I'm sure I had a purpose in my day
For now, I'm forgotten and not used
You can smell the stench of my decay

a. Lava Flow

For a list of the 14 AntiPatterns feel free to visit the Software Development AntiPatterns website.

Need help? Here is a list of remaining AntiPatterns for this riddle series.

Post a comment with your guess :)

~/riddle by me

Thursday, August 21, 2008

AntiPattern Riddle #5

q. I'm apathetic towards the principles of OO;
I'd rather contrive a system with a monolithic brain.
I'm a hodgepodge of properties and methods
But, unfortunately I'm a bear to maintain.

a. The Blob

For a list of the 14 AntiPatterns feel free to visit the Software Development AntiPatterns website.

Need help? Here is a list of remaining AntiPatterns for this riddle series.

Post a comment with your guess :)

~/riddle by me

Wednesday, August 20, 2008

AntiPattern Riddle #4

q. I modify 3rd party code when the need does arise.
I transfer responsibility from them to me,
When a new release of the 3rd party comes out,
I have to seek the modification and then revise.

a. Dead End

For a list of the 14 AntiPatterns feel free to visit the Software Development AntiPatterns website.

Need help? Here is a list of remaining AntiPatterns for this riddle series.

Post a comment with your guess :)

~/riddle by me

Monday, August 18, 2008

AntiPattern Riddle #3

q. You better watch out, you better not cry.
The tech you now use will soon be stale.
I prefer not to upgrade my programs.
The longer I'm behind the more I become frail.

a. Continuous Obsolescence

For a list of the 14 AntiPatterns feel free to visit the Software Development AntiPatterns website.

Need help? Here is a list of remaining AntiPatterns for this riddle series.

Post a comment with your guess :)

~/riddle by me

Friday, August 15, 2008

AntiPattern Riddle #2

q. I have no need for complex structure;
Extensive global variables you will find.
You should forget about code reuse,
Because I'm a program pasta intertwined.

a. Spaghetti Code

For a list of the 14 AntiPatterns feel free to visit the Software Development AntiPatterns website.

Need help? Here is a list of remaining AntiPatterns for this riddle series.

Post a comment with your guess :)

~/riddle by me

Thursday, August 14, 2008

AntiPattern Riddle #1

q. If you want a lot of code, then I'm the way to go.
The control key combination is my very best friend.
Be prepared to fix the same bug more than once,
because when it comes to maintenance, there is no end.

a. Cut-and-Paste Programming

For a list of the 14 AntiPatterns feel free to visit the Software Development AntiPatterns website.

Need help? Here is a list of remaining AntiPatterns for this riddle series.

Post a comment with your guess :)

~/riddle by me

Wednesday, August 13, 2008

Design Pattern Riddle #23

a. If you need a new method across a structure of classes,
Then I have the design pattern for you.
If you aren't overly concerned about encapsulation,
Then I can be useful despite my OO taboo!

a. Visitor

Need help? Here is a list of remaining Design Patterns.

Post a comment with your guess :)

~/riddle by me

Tuesday, August 12, 2008

Design Pattern Riddle #22

q. You might consider me a picture,
a snapshot of an object taken in time.
Then pick me up where you left off,
and launch the object into his prime.

a. Memento

Need help? Here is a list of remaining Design Patterns.

Post a comment with your guess :)

~/riddle by me

Monday, August 11, 2008

Design Pattern Riddle #21

q. I take your words and construe them into rules.
After I'm settled I can take anything you please.
I massage the words with my internal representation,
Then I comprehend the meaning and reveal it with ease.

a. Interpreter

Need help? Here is a list of remaining Design Patterns.

Post a comment with your guess :)

~/riddle by me

Friday, August 08, 2008

Design Pattern Riddle #20

q. When you have a plethora of objects,
and superfluous memory you can't ignore.
Then make use of my smoke and mirrors,
to conjure one item into objects galore!

a. Flyweight

Need help? Here is a list of remaining Design Patterns.

Post a comment with your guess :)

~/riddle by me

Thursday, August 07, 2008

Design Pattern Riddle #19

q. Instead of writing messy message modules,
I provide a much better approach instead.
I'll untidy the talk if you put me in the middle,
However, there is a danger I might get a big head.

a. Mediator

Need help? Here is a list of remaining Design Patterns.

Post a comment with your guess :)

~/riddle by me

Wednesday, August 06, 2008

ASP.NET MVC 101


This is definitely a work in progress, but I put together a document of resources (videos and blog posts) that helped me get up to speed on ASP.NET MVC.

Hopefully, this can help you get acclimated to MVC quickly.I plan to continue to update and reorganize the document as I learn more.

If you know of any other helpful links or resources, please leave a comment.

Design Pattern Riddle #18

q. I understand one class can't do it all,
So I don't mind passing the buck.
The work should eventually get done,
But if not, then you are out of luck.

a. Chain of Responsibility

Need help? Here is a list of remaining Design Patterns.

Post a comment with your guess :)

~/riddle by me

Tuesday, August 05, 2008

Design Pattern Riddle #17

q. When there are items that share a creation process,
Them I’m a shoe in to follow that through
Like the foxtrot, I follow a set of steps,
Then I launch them on their dancing debut.

a. Builder

Need help? Here is a list of remaining Design Patterns.

~/riddle by me

Monday, August 04, 2008

Design Pattern Riddle #16

q. If you need a bunch of something,
And you know which one to reap.
Then I'll copy it over and over,
Like the woolly dolly sheep.

a. Prototype

~/riddle by me

Friday, August 01, 2008

Design Pattern Riddle #15

q. I split a class from what it does and how it goes,
So they can each grow in their isolated silo.
I keep you dry from the waters that flow,
And shelter you safe from falling below.

a. Bridge

~/riddle by me

Thursday, July 31, 2008

Design Pattern Riddle #14

q. There once were two incompatible classes,
they were mismatched and unable to commune.
Then along came a extraordinary pattern,
that allowed them to sing the same tune.

a. Adapter

~/riddle by me

Wednesday, July 30, 2008

Design Pattern Riddle #13

q. I'm all about creating families;
The kinds that have a common subject.
There is no need to provide specific details,
When using this conceptual mill project.

a. Abstract Factory

~/riddle by me

Tuesday, July 29, 2008

Design Pattern Riddle #12

q. I flip through the Rolodex of objects;
You don't have to know how their made.
I give a way for each object to shine,
As they walk down the object parade.

a. Iterator

~/riddle by me

Monday, July 28, 2008

Design Pattern Riddle #11

q. I'm in the business of procreation,
But I'm not the kind who likes to crow.
I gladly give power to those that inherit;
I'm the first to tell the object, "hello!"

a. Factory Method

~/riddle by me

Friday, July 25, 2008

Design Pattern Riddle #10

q. I make a group of objects seem as one;
behind the scenes I resemble a deep rooted plant.
I contain a family of parents and children,
but no where in me can you find an aunt.

a. Composite

~/riddle by me

Thursday, July 24, 2008

Design Pattern Riddle #9

q. I let you take charge of the various implementations;
I am highly abstract, but generically planned.
A superclass can localize your common behavior,
but there is plenty of room for you to command.

a. Template Method

~/riddle by me

Wednesday, July 23, 2008

jQuery Flexigrid Using C# 3.0 (.NET 3.5) & LINQ

When I developed my first ASP.NET MVC application, I was a little disappointed with my options for a rich grid. I initially used the grid that is part of the MVCContrib project, but it is pretty simple and there aren’t many features out of the box.

I was very pleased with the code of my MVC application, but the presentation was so 1990's. With all of this new technology I thought the presentation deserved something snappy. That is when I found Flexigrid.

As I mentioned in my last blog entry, I started to use jQuery. To my joy, Flexigrid is a jQuery plugin! Flexigrid uses jQuery to asynchronously populate the contents of the grid using either XML or JSON input.

The following is an example of what the grid looks like. It contains features to sort, page, search, move columns, resize, etc…

flexigridExample

The User Interface portion was pretty straightforward to put together. You just need to define your columns, the data source, and some additional parameters (such as: search terms, size, etc…).

   



I wanted to use this opportunity to try out some new features of .NET 3.5, so I wanted to incorporate LINQ and JSON serialization.

To do this, I needed to setup some classes that the Flexigrid will recognize once serialized. Here is what I came up with.
   1: public class FlexigridViewData
   2: {
   3:     public int page;
   4:     public int total;
   5:     public List<FlexigridRow> rows = new List<FlexigridRow>();
   6: }
   7:  
   8: public class FlexigridRow
   9: {
  10:     public long id;
  11:     public List<string> cell;
  12: }
Now is the part where the fun begins. I had already retrieved the content I needed from the Middle Tier. I use LINQ to query the generic list to obtain the correct page subset and then use a helper extension method to serialize the contents to JSON.
   1: public void Page_Load()
   2: {
   3:     Response.Clear();
   4:     Response.ContentType = "text/x-json";
   5:     Response.Write(GetPagedContent());
   6:     Response.Flush();
   7:     Response.End();
   8: }
   9:  
  10: private string GetPagedContent()
  11: {
  12:     var pageIndex = Convert.ToInt32(Request.Params["page"]);
  13:     var itemsPerPage = Convert.ToInt32(Request.Params["rp"]);
  14:     var sortName = Request.Params["sortname"];
  15:     var sortOrder = Request.Params["sortorder"];
  16:     var query = Request.Params["query"];
  17:  
  18:     IEnumerable<Contact> pagedContacts;
  19:     if (string.IsNullOrEmpty(query))
  20:     {
  21:         pagedContacts = sortOrder.Equals("asc") ?
  22:             Contacts.OrderBy(contact => contact.GetPropertyValue<IComparable>(sortName)) :
  23:             Contacts.OrderByDescending(contact => contact.GetPropertyValue<IComparable>(sortName));                
  24:     }
  25:     else
  26:     {
  27:         Func<Contact, bool> whereClause = (contact => contact.GetPropertyValue<string>(sortName).Contains(query));
  28:         pagedContacts = sortOrder.Equals("asc", StringComparison.CurrentCultureIgnoreCase) ?
  29:             Contacts.Where(whereClause).OrderByDescending(contact => contact.GetPropertyValue<IComparable>(sortName)) :
  30:             Contacts.Where(whereClause).OrderBy(contact => contact.GetPropertyValue<IComparable>(sortName));
  31:     }
  32:     int count = pagedContacts.Count();
  33:     pagedContacts = pagedContacts.Skip((pageIndex - 1) * itemsPerPage).Take(itemsPerPage);
  34:  
  35:     const string imageLinkFormat = @"<a href=""{0}""><img src=""{1}"" border=""0"" /></a>";
  36:     const string imageFormat = @"<img src=""{0}"" border=""0"" />";
  37:     var flexigrid = new FlexigridViewData {page = pageIndex, total = count};
  38:     foreach (var contact in pagedContacts)
  39:     {
  40:         flexigrid.rows.Add(new FlexigridRow
  41:         {
  42:             id = contact.ID,
  43:             cell = new List<string> 
  44:             { 
  45:                 string.Format(imageLinkFormat, ResolveUrl("~/Contact.mvc/Detail/" + contact.ID), 
  46:                 ResolveUrl("~/Images/Detail.gif")), 
  47:                 contact.ID.ToString(), 
  48:                 contact.FirstName, 
  49:                 contact.LastName, 
  50:                 contact.DateOfBirth.ToShortDateString(), 
  51:             }
  52:         });
  53:     }
  54:  
  55:     return flexigrid.ToJson();    
  56: }
Here are some helper extension methods that I used to complete the above code snippets.
   1: public static class JsonHelper
   2: {
   3:     public static string ToJson(this object obj)
   4:     {
   5:         var serializer = new JavaScriptSerializer();
   6:  
   7:         return serializer.Serialize( obj );
   8:     }
   9:  
  10:     public static string ToJson(this object obj, int recursionDepth)
  11:     {
  12:         var serializer = new JavaScriptSerializer();
  13:  
  14:         serializer.RecursionLimit = recursionDepth;
  15:  
  16:         return serializer.Serialize( obj );
  17:     }
  18: }
   1: public static T GetPropertyValue<T>(this object component, string propertyName)
   2: {
   3:     return (T) TypeDescriptor.GetProperties(component)[propertyName].GetValue(component);
   4: }
As a side note, I did have to dive into the JavaScript and fix two issues that I came across, but other than that it works like a charm.
I would prefer if the developer of the product had a better system of tracking bugs and maintaining a forum, but in the meantime what is setup is sufficient.