Maintainability is an important factor in every software project. The costs of not getting it right run high. In fact, it is estimated that maintainability costs are often 70%-80% of a total project cost.

The main principle of maintainable code is to design loosely-coupled components with small number of connections to other functions. Factors such as solid Object-Oriented Analysis and Design (OOAD) and design patterns impact long term code maintainability.

Diomidis Spinellis [1] lists other important factors that affect maintainability. Among these factors are analyzability, consistency, length of expressions, functions, and methods, locality of dependencies and type checking.

If data abstraction is a policy promoting (among other things) a system’s stability and maintainability, type-checking is the enforcement mechanism. An implementation that takes advantage of a language’s type-checking features will catch erroneous modifications at compile time; an implementation based around loose types or one that circumvents the language’s type system can result in difficult-to-locate runtime errors.

The above statement while valid for stongly-typed languages like Java and C#, is falling short for dynamic languages. The simplicity and the dynamic nature of weakly-typed languages can not only be liberating during initial implementation, but can also have positive impact for long-term maintainability. For example, applications will no longer need big XML configuration files, because changes to the source code will not require recompilation. There are other substantial advantages of weakly typed languages as well [2].

Let’s take an example. In Groovy the entire language is based on weak types. Some argue that strong type checking at compile time helps more bugs to be caught early in the process. I agree with that in general. But the code simplicity that Groovy brings to the table and the whole notion of merging compile-time and run-time can also be seen as an important factor contributing to its long-term maintainability. According to the classical type checking principle, none of the Groovy code can ever be considered maintainable. I think this principle needs to be revisited for the age of weakly-typed scripting languages. What do you think?

References: