this.Blog.Find(entry => entry.IsHelpful);
 Wednesday, January 28, 2009
Atlanta Alt.Net User Group Meeting
agile_book

Tonight we are going to have another meeting of the Atlanta alt.net user group.  We are meeting at Manuel’s Tavern again, but we are supposed to be in a different room this time.  I know the last meeting at Manuel’s was a little hard to find (if you weren’t there, last time they put us in a side room off another room that was holding a meeting, which had closed its outer doors to the rest of the restaurant). 

This week were are going to be in the “Eagle’s Nest” room, which is located on the other side of the restaurant off the main dining area on its southern side.  Look for the small stairs in the corner of the room.

We are going to be discussing the book, “Agile Estimating and Planning” by Mike Cohn.  If you haven’t read the book, it’s no big deal.  We will be discussing lots of other things, too.  

Hope to see you there!


Kick it on DotNetKicks.com
Wednesday, January 28, 2009 10:01:32 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0]  .Net | alt.net | User Groups

 Wednesday, January 14, 2009
Put Down That Golden Hammer!

In case you’ve been living in a cave on Mars with your fingers in your ears for the last year, you’ve probably heard we just ended a little election here in the United States.  I’m not big on the whole politics scene, so I’ll spare you much further discussion on the subject, except that I just don’t *get* why people blindly pledge their allegiance to extremist political views (no matter which side they’re on).   Yet people by the millions are quick to eat up the junk spooned out by people like Rush Limbaugh, (fellow Cornell alum) Keith Olberman, (fellow Cornell alum) Ann Coulter, Sean Hannity, Bill O’Reilly, etc.  If you ask me, they’re all equally wackos.

The same phenomena happens in the software development community.  We as an industry are very divided on what we hold to be the best technology, whether it be operating systems, programming languages, IDEs, frameworks, etc. 

Maybe it’s the middle child in me or the fact that I’m a Libra, but I tend to take a more centrist view on things.

I’ll share two quick items about my past:

  1. At one time, I was a snobby Java programmer at the height of the dot-com boom.  If you told me during the early part of this decade that I would be making my living doing (egad!) Microsoft development for a living, I would have called you bat-shit crazy.  But a funny thing happened … I got exposed to C# on a project I was on (i.e. it was mandated we use it), and it turned out to be (IMO) a better version of Java.  And .Net was a wonderful development environment!  It wasn’t at all like going to “the dark side” as I would have been led to believe by my Java brethren.
  2. I’ve known my friend Brad, another software developer, since college.  Though neither of us were CS majors, somehow we both ended up in the software development field.  Here we are close to 15 years removed from school and both have taken much different routes to get to where we are in our careers.  While I have toed the corporate line and always stuck to “enterprise” software development (i.e. Java and .Net), Brad has been fascinated with open source technologies, functional programming languages, alternative databases, and highly concurrent systems (way before any of these gathered mainstream momentum).  In short, about 180 degrees from my development background.  Now that he has moved to Atlanta, in the last few years he has been a great influence on me and my view of the software development world.  In fact, part of the reason I so quickly latched on to the new dynamic-language-type features introduced in .Net 3.0 (e.g. lambda expressions, closures, extension methods) was directly because of his influence since he had been telling me about them in other languages for so long.  Once I finally was exposed to them first hand, I quickly understood where he was coming from.

The lesson I’ve learned is to keep an open mind when it comes to software development.  Too many times, we let pre-conceived notions and technology prejudices influence our decisions.  (Want to know a dirty little secret?  I like Vista … a lot, actually.)

I’m finally reading the Pragmatic Programmer (I know, I know, lay off me!), and though I’ve heard it re-told many times by many people, there is a classic adage in the book about learning a new programming language every year.  There’s a reason it’s re-told so often.  It’s because it’s really excellent advice.  If nothing else, it will help broaden your horizon when it comes to tackling problems in your day-to-day programming language.   It can open your mind to an entirely different way of thinking.  As humans, we’re creatures of habit.  We need something to shake things up occasionally.

The reason I’m writing this post now is that within the last few weeks, I’ve been exposed to technologists wielding “Golden Hammers”.  If you’re not familiar with the term, it refers to people who get so focused on a particular technology, they think it will solve every problem thrown at them.  “Sharepoint can do that!”  “You need to employ a 100% SOA so your website can scale, no matter how many users you are projecting!”  “Let’s write an iPhone app for this niche blue-collar customer base!”  When you have this Golden Hammer, everything looks like a nail.

It’s perfectly fine to have your convictions.  Being passionate about something, whatever that thing may be, is one of the highest highs you can get in life.  But don’t stick your head in the sand when it comes to technology.  There is no “one technology to rule them all”.  Try to be objective in your decisions.  Use common sense.  Weigh trade-offs for choosing one technology over another.  Practice pragmatism.  And use the right tool for the job.


Kick it on DotNetKicks.com
Wednesday, January 14, 2009 12:23:06 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0]  Agile | Programming

 Monday, January 12, 2009
Minimizing Accessibility And Testing Internal Classes in C#
Effective_Java

There is a great book on the Java programming language called Effective Java by Joshua Bloch.  Even if you don’t use Java as your primary coding language, this book contains innumerable software engineering tips and design patterns that will help you improve in no matter what language you code.  It’s a great reference guide that I continuously go back to, even though I haven’t done much Java coding in the last few years.  The fact that I bought the second edition when it came out despite the fact I no longer really do Java should tell you something.  Josh, if you’re reading this post, you can contact me to see how you can send me the referral fees.

The first item in the “Classes And Interfaces” section of the book is: “Minimize the accessibility of classes and interfaces”. The idea is to not just think of encapsulation in terms of class internals, but to also take it to the next level - meaning up to your API in general.  As Bloch says,

"The single most important factor that distinguishes a well-designed module from a poorly designed one is the degree to which the module hides its internal data and other implementation details from other modules.  A well-designed module hides all of its implementation details, cleanly separating its API from its implementation.  Modules then communicate only through their APIs and are oblivious to each others’ inner workings."

It’s a principle I strive for in all my software design.  By making your API strong and weakening your implementations, you are effectively decoupling your module from the rest of the system.  This decoupling allows you to easily develop, test, and refactor your module in isolation without affecting the rest of the system.  It’s a concept that falls right in line with “The Open/Closed Principle”.  This principal states you should make your software modules “open” for extension, but “closed” for modification.

One of the easiest ways to accomplish encapsulation in an object-oriented language is through the use of access modifiers (e.g. public, protected, internal, private).  Anything you declare as public is open to the whole world.  Therefore, Bloch says that when design your software, “make each class or member as inaccessible as possible.”

I am the author of an open-source project called Miado.  It’s an API that sits on top of ADO.Net and attempts to simplify data access and remove the repetitive, error-prone, boiler plate code we write over and over again in our data access modules.  In building my API, I’ve tried to adhere to good OO design principles.  I’m a big fan of coding to interfaces, using dependency injection, unit testing, and mocking.  Therefore, I’ve exposed most of the API as interfaces rather than concrete classes.  Since I want to abide by the tenants I’ve talked about already, I’ve restricted the corresponding class implementations of these interfaces.  They are declared as “internal”, which in C# terms means they are only exposed to classes in the same assembly in which they are defined.  Since no external assembly can reference my implementations, the “black box” of my interface is upheld, yet allows the consumer to override their own implementations (even if it is only in a mock).

Now this is all well and good, but there’s one more thing of which you need to be aware.  Remember that when you mark a class as “internal” in C#, only classes in that same assembly can reference that class.  Like I said, I’m a big fan of unit testing.  How do you test a class in a test assembly when you can’t even see it???  You could move your test classes to the declaring class assembly, but that’s really just a bad idea.  It adds extra overhead to an assembly and provides no real value to its consumer.  It’s just extra noise taking up space.  And jumping through hoops to remove those test classes as part of a build step reeks of wasted effort.

Java has a nice way to get around this gotcha.  In Java, “protected” scope is somewhat similar to “internal” scope in C#, with one important distinction.  Protected accessibility in Java allows any subclass to access that member, as well as any other class in the same “package” (a close cousin to a “namespace” in C#).  So when you write your unit tests in Java, you merely have to declare your unit test class as belonging to the same package as the class being tested, which then allows you to access any of that class’s internal state and behavior, even if it gets deployed as a separate jar file.  Unfortunately, C# has no similar “namespace” accessibility modifier.

But .Net does have some aces up its sleeve.  There is a way to declare another assembly as a sort of “friend” assembly so that it can see the original’s internal members.  In the original assembly (the one being tested), add the following line to your AssemblyInfo.cs class:

   1:  // let the unit tests see internals of this assembly
   2:  [assembly: InternalsVisibleTo("Miado.Test")]

Now, this is not something I would regularly do (it defeats the whole purpose of hiding implementation details in the first place!), but it does get around the problem of being able to unit test internal code modules.  Simply adding this one line to your assembly can allow you to improve your API immensely.  Now you don’t have to sacrifice the accessibility of your modules just to make them easier to unit test!
Kick it on DotNetKicks.com
Monday, January 12, 2009 4:46:33 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0]  .Net | C# | Java | Miado