Showing posts with label Story-Telling. Show all posts
Showing posts with label Story-Telling. Show all posts

Saturday, October 17, 2009

OOP Semaphores
Byline: Smoke signals from one developer to another.

I would like to point out the very obvious, that too often gets lost in the shuffle.  The code choices we make when designing components act as a series of “signals” that we send to the next developer working on the library or to the developer who is applying and implementing the objects we have created.  When we are crafting our code, our choices of class and parameter names, member protection levels, and constructors act as the primary method of disseminating the indented usage of our code.

If an organizations code base is the most inclusive repository of business process knowledge of an organization, then our code libraries supply the nouns, verbs, and adjectives of the business process.

Name for global business understanding
Most business processes have a generally accepted internal name.  This is the name that the stakeholder community will call something when telling their business story.  Using a different name, as in the statement, “to me blank is this,” when your user community has consolidated on a defined designation, is obfuscation, and to me, smacks of hubris.

Sometimes, you must rename, for elucidation, like when swapping out an acronym or abbreviation for a “Plain English” term that more fully explains the intended usage.  But this means you will have to disseminate the new term and usage throughout the hierarchy you are involved in.

One of the best reasons I can think of to develop documentation artifacts before the creation of a code base, is so that you have a more complete set of thoughts on the business processes, so that the names you choose will be indicative of the actual use of your objects in the wild.

Code the meaning of your Intended Usage into your implementations
So lets talk about the following code:
  
 Fig.1  
    interface iAnimal
    {
        string Name { get; set; }
        object Vocalize(object SpeechType);
    }



The Plain English meaning of this code is that all objects that implement iAnimal will have at least one string type property called Name, and a method called Vocalize that takes a parameter of type object and returns an object.  By creating an interface (a code pattern that set a base contract of what will be contained in an object) the architect of the code, signals to other human beings implementing his work, that this is the minimal acceptable level of code to implement this functionality.  If you implement from this interface, the assembler will only compile your object, if your code object contains all the members specified in the interface. Those the contextual meaning of the code is “you must have all these pieces.”

Fig.2
    public class Animal : iAnimal
    {
 private object _vocalization;       
 private string _name;

        public string Name
        {
            get { return _name; }
            set { _name = value; }
        }
       
        public object Vocalize()
        {
            return _vocalization;
        }

    }


Figure 2 shows the terms of the code contract being met in full. So we have a cycle of intention and usage, playing out into fulfillment, Contract spelled out by the interface, and then Contractual Obligations met in full by the implementing class.

“What I would like to stress here, is this is not just a series of assembly instructions, this has inherent intended meaning from one human being to another”
So how about when a developer sets up a class as abstract, the Plain English meaning is that the object must be inherited to be used. The compiler will not build if you try to call new on the abstract object.  But the contextual meaning that the code’s architect is attempting to send to the implementing developer is that the architect’s intended usage of this code is as a base class that is meant to be inherited.

Sunday, June 15, 2008

Code as "Story-Telling" Introduction

Computer code is a language of expression. The core purposes of a programming language are to articulate rules and actions. This expression of the rules is done by people, who have the purpose of sending instruction sets to the computer in such a way as to get the computer to execute a series of tasks that achieve a desired and mostly likely testable result.

But the life cycle of programs goes beyond the extent of the first publication. Some computer code exists in a modified state for over 30 years. This life expectancy of code impacts how the written instructions should be targeted. It is not just enough for a program to be designed so that it does exactly what was desired, another aspect of a programs is its human maintainability over its full life-cycle.

When developing code, the business processes are laid out in documents, these documents amount to the intention of what a program should do. The industry is getting better at producing these documents and putting together scope. The problem with the scope is when a change request is applied to the original scope the request amounts to an errata of the scope. Over the life of development of an item the original intention of the software is greatly modified, and you get errata, of errata, of errata and so forth. The issue comes into play that not even the documentation of the business process adequately defines what the true in production business process actually is.

I sometimes view software through the conceit of the software being the real story of a business and that reading a businesses’ software is an exercise in exploring an enterprises’ set of practices. This story telling view of software, when I am reading someone else’s programs or writing the software myself helps me to get into a mind frame while I am developing to know that there will be (most likely) many other people who will work on a piece of software before it’s useful life expires.

This view, as it has achieved fullness has led me to be slightly discouraged with the state of enterprise software that I have worked with. On the web, the software instruction set is usually just dog-pile. In-line code directives (line by line processed very similar to an old BASIC program) piled into pages that are not even organized well into directories, without even the use of basic programming plumbing like methods. In all the organizations I have worked at these code repository’s code could be best summed up by naming them “Silly Buggers.”

A large part of the software writing community strives only to get the exact desired result from software. If the desired result is achieved then software is deemed to be successful. This can be summed up best by programmers who are asked about their software and they reply in its defense with “It Works,” which somehow absolves the software from any necessity of organization, well-craftedness, or maintainability.

If software is the one true repository of the business processes of an enterprise, I wonder how a business can afford to have its’ processes stored in a manner that other human beings are not able to readily understand, or replicate. Additionally if the usage of code goes beyond just getting the correct result, but includes that code has a status as both a rules repository and a dynamic living document, then perhaps the way that the code itself is written should be looked at.