Incomplete Pairs

Written by

in

Description

This smell arises when an abstraction fails to provide all complementary methods. For example, in the case of a data structure, the abstraction must support adding and removing elements. If either of these interrelated methods is missing, the abstraction is considered incomplete. If an abstraction does not support complementary or interrelated functionality completely, resulting in another component needing to complete said feature.

Context

Derived from: “Incomplete Abstraction”

Cause

Mainly caused by a lack of understanding that abstractions shall be self-contained, standalone functional components. A lack of communication in the development team can also lead to this antipattern, not adhering to language conventions or other standards.

Consequences

Functionality also has to be implemented multiple times for each user. Unit tests for such functionality (e.g. data validation) may fail or contain a lot of overhead code to properly test such a service.

Detection

Complementary feature pairs cannot be found in an EA process.

Solution

Refactor the functionality and aim for symmetric feature pairs.

Example

An element is named “start claim,” but a complementary element “stop claim” is missing.

Cypher query

WITH apoc.map.values($pairs, keys($pairs), true) as jsonValues <br /> MATCH(n) <br /> WHERE any (x in keys($pairs) <br /> WHERE toLower(n.name) starts WITH x) <br /> WITH n <br /> WITH [x in keys($pairs) <br /> WHERE  toLower(n.name) starts WITH x | x] as copmplementaryPair, n <br /> UNWIND copmplementaryPair as selectedKey <br /> WITH  collect(distinct selectedKey) as complementaryKey, n <br /> WITH n,  apoc.map.values($pairs, complementaryKey, true) as jsonValues, complementaryKey <br /> MATCH p=(n), (m) <br /> WHERE not exists { <br /> MATCH (j) <br /> WHERE m=j and toLower(n.name) contains complementaryKey and toLower(j.name) contains apoc.map.values($pairs, complementaryKey, true) <br /> } <br /> RETURN p

Cypher count query

WITH apoc.map.values($pairs, keys($pairs), true) as jsonValues <br /> MATCH(n) <br /> WHERE any (x in keys($pairs) <br /> WHERE toLower(n.name) starts WITH x) <br /> WITH n <br /> WITH [x in keys($pairs) <br /> WHERE  toLower(n.name) starts WITH x | x] as copmplementaryPair, n <br /> UNWIND copmplementaryPair as selectedKey <br /> WITH  collect(distinct selectedKey) as complementaryKey, n <br /> WITH n,  apoc.map.values($pairs, complementaryKey, true) as jsonValues, complementaryKey <br /> MATCH (n), (m) <br /> WHERE not exists { <br /> MATCH (j) <br /> WHERE m=j and toLower(n.name) contains complementaryKey and toLower(j.name) contains apoc.map.values($pairs, complementaryKey, true) <br /> } <br /> RETURN COUNT (DISTINCT n)

Diagram

Diagram for Incomplete Pairs

Tags

soa, microservices, business, application, technology, abstraction

Query parameters

[
    {
        "name": "pairs",
        "type": "map",
        "default": {
            "min": "max",
            "open": "close",
            "start": "stop",
            "create": "destroy",
            "get": "set",
            "read": "write",
            "print": "scan",
            "first": "last",
            "begin": "end",
            "lock": "unlock",
            "show": "hide",
            "up": "down",
            "source": "target",
            "insert": "delete",
            "push": "pull",
            "enable": "disable",
            "acquire": "release",
            "left": "right",
            "on": "off"
        },
        "description": "A list of complementary key-value pairs."
    }
]

Related smells

All smells