Maintainability

Why ?

Because software is an always-running  evolving solution to still-unknown and changing problems

What ?

Maintainability is inversely proportional to the amount of time it takes to make a change and the risk that change will break something

How ?

  • design

  • documentation

  • tests

  • process

  • architecture

Maintainable architecture

Limit brain RAM needed

Contracts

  • explicit responsibility

  • stable interface

  • deliberate evolution

3 principles

  1. functional design

  2. coupling as hierarchy

  3. domain abstraction layer

1. Functional design

The problem with object-oriented languages is they’ve got all this implicit environment that they carry around with them. You wanted a banana but what you got was a gorilla holding the banana and the entire jungle.

Joe Armstrong

Show me your code and conceal your data structures, and I shall continue to be mystified. Show me your data structures, and I won't usually need your code; it'll be obvious.

Fred Brooks

Values & Functions

  • no hidden context

  • controllable side effects

  • clear encapsulation

  • easy composition

2. Coupling as hierarchy

  • parent

  • children

Only talk to your

  • module interface

  • re-exports

  • wrapped delegation

How ?

class Engine::Docs
    def self.default_list(project)
        if Engine.early?(project)
            Engine::Docs::EarlyList.build(project)
        else
            Engine::Docs::List.build(project)
        end
    end
end
class Engine
    def self.docs(project)
        Docs.default_list(project).map(&:slug)
    end

    def self.early?(project)
        project.maturity.in? Engine::Project::EARLY_MATURITIES
    end
end

Immediately identify impacts of change

3. Domain abstraction layer

Less code is better

int countSubstring(const char *str, const char *sub)
{
    int length = strlen(sub);
    if (length == 0) return 0;
    int count = 0;
    for (str = strstr(str, sub); str; str = strstr(str + length, sub))
        ++count;
    return count;
}
def countSubstrings(str, sub)
  str.scan(sub).length
end

Global coupling

Stability

The domain is the most stable candidate in the face of changing requirements

Questions ?

Maintenability

By David Ruyer

Maintenability

  • 80