Programming Tips, Tricks, Rants and Raves
Refocusing Techniques

[This is part of the Control Your Focus To Increase Efficiency series.]

Interruptions happen! Frequently if you work in a team environment.

Getting into a groove can be time consuming for most programmers, so recovering from interruptions is a crucial skill. Over the years Robert has learned a few tricks to help him combat these necessary evils. His tricks aren’t mind blowing or complete — just the opposite — they are simple and available for anyone to use.

Before Robert shares his tricks, it’s a good reminder that this post was create to help recover from interruptions not to remove them. As discussed in the prior posts of this series limiting interruptions by stopping them before they happen is a topic of its own and one worth exploring as it benefits everyone.

Now here are Roberts tricks:

Continue Reading »

Dependency Inversion Principle is a Must for Object-Oriented Programming

Traditional procedural programming creates a dependency structure in which policy depends on detail. This is unfortunate, since the policies are then vulnerable to changes in the details. Object-oriented programming inverts that dependency structure such that both details and policies depend on abstraction, and service interfaces are often owned by their clients.

Indeed, this inversion of dependencies is the hallmark of good object-oriented design. It doesn’t matter what language a program is written in. If its dependencies are inverted, it has an OO design. If its dependencies are not inverted, it has a procedural design.

The principle of dependency inversion is the fundamental low-level mechanism behind many of the benefits claimed for object-oriented technology. Its proper application is necessary for the creation of reusable frameworks. It is also critically important for the construction of code that is resilient to change. Since abstractions and details are isolated from each other, the code is much easier to maintain.

Robert C. Martin and Micah Martin
Agile Principles, Patterns, and Practices in C#
Prentice Hall 2006

Overcomplicating the Simple – String.IsNullOrWhiteSpace

Today’s overcomplicating the simple covers a new framework method that was introduced in .Net 4.0. This method is very simple, however it seems that not many people know about it, or they are creatures of habit and still prefer the old way.

This new method is String.IsNullOrWhiteSpace and it’s very similar to String.IsNullOrEmpty, however in addition it returns true when the string being checked is white space.

Here’s a common example of where this new method could have been used:

private void Foo( string bar )
{
  if( string.IsNullOrEmpty( bar ) )
  {
    throw new ArgumentException(
      "Parameter cannot be null or whitespace", "bar" );
  }
  else if( bar.Trim().Length == 0 )
  {
    throw new ArgumentException(
      "Parameter cannot be null or whitespace", "bar" );
  }
  ....
}

Continue Reading »

How to Inspire Others to Produce Clean Code

Are you disappointed with the quality of source code that is being produced by your team? Wish there was something you could do? With a bit of hard work, perseverance, and people skills you can start influencing the team towards better programming practices.

In order to influence your fellow developers, you will need to build a vision that they will accept. The process of building this vision will be a difficult. You will need to navigate multiple hurdles.

Hurdle 1
You need to define what you mean by the term “clean code”. If you’ve been following my blog for any time, you should have an idea what I think clean code means. I was introduced to this term by Uncle Bob’s book similarly titled book, Clean Code. In summary clean code means that we pay careful attention to the details of software to make the code readable and maintainable: good names, good comments, small methods, eliminated dead code, and basic object-oriented principles.

Continue Reading »

Get Updates

Make sure you don't miss new posts. Subscribe via RSS or email today.

Email:  
Resource Articles