May 23 2009

Agile Is Not A Process

Category: Agile Project ManagementJeff @ 22:07

Lately I'm hearing a lot about agile "processes" and teams that claim to be adopting an agile "methodology".  This sort of language speaks as if certain structures and procedures can be adopted which will make a team agile. This thinking is misguided at best, damaging at worst. When Kent, Bob, Ward and the other 17 "Apostles of Agile" crafted the Agile Manifesto, they did not publish a list of procedures or processes.  Instead they provided a set of values and priorities.

Are you part of a team that is striving to be agile?  If so, ask yourself, what is the primary driving force behind your efforts?

  • Structures
  • Procedures
  • Processes
  • Methodologies

or

  • Values
  • Priorities
  • Principles

Do we need structures and procedures?  Absolutely! They are the context in which we perform concrete actions in order to fulfill the values and priorities to which we are committed. However, it is the ability to adapt these structures and procedures that makes an Agile team. When methods and structures are rigid and unchanging, agility has ceased.

Agile is not a process, but it is about how we create, shape and adjust our processes. The real question to ponder is this: "Do current structures, procedures and metholodogies enable us to maximally operate according to our values, priorities and core principles?" This is the question of alignment (a concept I will explore further in future posts). If the answer is "no" then are you willing to do something about it?

Tags: , ,

Mar 18 2009

Patterns & Practices - Part 2

Category: Software DevelopmentJeff @ 06:37

In my previous post on Patterns & Practices, I discussed the fact that in order to learn P&P, you have to be willing to make mistakes.  In the early stages, it is beneficial to look for opportunities to apply patterns to your development so that you can begin to see how they take shape.  You may not understand their benefit in the early stages, but this is a vital step, akin to the experience of the "Karate Kid" as he was told to "wax on / wax off".  He spent weeks practicing the same moves over and over again, not really understanding the purpose of such repetitive tasks.  What he failed to realize was that he was developing muscle memory and creating well worn neural pathways that would prove vital in his development process.  This holds true for us as software developers as well. [For this early development stage, a key resource is a book such as Head First Design Patterns].

Eventually you gain some proficiency with the repetitive tasks.  You begin to realize that certain patterns work better than others in certain circumstances.  You might discover that some patterns can paint you into a difficult corner (Singleton is of course the prime example, though Static Gateway has its pitfalls as well). At this stage you are beginning to deconstruct the value and utility of particular patterns for certain situations and contexts.  You awaken to the realization that code can have a "smell" that communicates whether a design is fitting or not.  While you cannot necessarily name the "smell" it is clearly there.  [At this stage, you're ready to tackle Refactoring to Patterns].

Take time to identify patterns that fit well for addressing particular smells.  Look for examples in code written by others (you are taking time to read code written by others, right?).  And start looking for ways that improper use of patterns can introduce smells of their own.

In my next post in this series, I will switch gears and discuss the relationship between Patterns and Practices and why you ultimately want to emphasize the Practices over the Patterns.  Stay tuned!

Tags: ,

Nov 27 2008

Lazy Init VS Constructor Init

Category: Software Developmentemilioc @ 01:18

One of my favorite things about programming is also one of the most frustrating things about programming. There's always more than one way to solve a problem.  Software developers are faced with many choices.  There is much to consider at every phase in the process.  Efficiency, deadlines, performance, maintainability and scalability are all important topics to consider.  So what criteria should you use to choose the correct convention or pattern?  I'm here to let you know, there is no definitive answer (surprise).  Also, this versus article is not meant to declare a victor.  I wanted to use this example to illustrate my point on the choices developers have to make and the criteria that affect those choices.

Let's take on lazy init first.  Below is a simple class with a Names property.  Instead of initializing the list when the object is created, initialization is delayed until the property is needed.  The if block is there to protect against the creation of a new list every time you retrieve the Names property.  Performance is the most common argument I hear for using lazy init.  Performance is a very good reason to use lazy init.  As you can see, there is quite a bit going on for a simple object initialization.  At minimum, you need a field and a property, not to mention the null object precaution.  If you've been developing for a while, it is easy to get in the habit of starting with optimized code.  Shouldn't the goal be to start simple and refactor as required?  Is this common convention needless complexity?

 public class SimpleClass {

        private IList<string> _names;
        public IList<string> Names {
            get {
                if (_names == null) {
                    _names = new List<string>();
                }
                return _names;
            }
        }

        public SimpleClass() {

        }

    }

And in this corner we have the challenger, constructor init.  Using this approach, the Names property will be initialized when SimpleClass is initialized.  One benefit of constructor init, as seen in the example below, is simplicity.  There is no need for a field or an if statement.  What about performance?  Performance is a valid concern but it should be weighed against code efficiency.  Simply put, a developer has a lot less code to write when using constructor init.  The need to optimize for performance may never arise.  In fact, if lazy init improves your code's performance, you might have a problem with SRP (zing).

    public class SimpleClass {

        public IList<string> Names { get; private set; }

        public SimpleClass() {
            Names = new List<string>();
        }

    }

It's probably obvious that I prefer simplicity over complexity.  I acknowledge that complexity has its place in development and is appropriate at times.  I believe the priorities and factors that lead to code complexity are an important and overlooked part of software development.  If you're not sure why you need it, maybe you don't.  The complex solution should answer the why.

Note: a similar comparison can be made for Service Locator and Constructor Injection but I will save that for another post.

Tags: