DEV Community

Aragoni Michels
Aragoni Michels

Posted on Edited on

Modeling shared carpet scope as a data structure with per-building overrides

A procurement group wants one carpet concept across several buildings. The temptation is to model this as a single spec object cloned per site. That breaks as soon as two operators have different cleaning contracts. A better fit is a shared base plus per-building records, and the interesting engineering problem is deciding what belongs in the base.

Consider a small synthetic example. Two buildings inherit the same colour scheme. Building A's operator runs machine cleaning weekly; Building B's operator spot-cleans daily with a contracted crew. The shared part is appearance intent. The building part is room use, furniture plan, construction conditions and cleaning method.

In this Python 3 example, the shared record accepts only appearance fields. Each site has its own list of rooms. A room with no cleaning decision leaves a question open. If a cleaning method does not apply, the responsible person can record that explicitly.

def open_items(shared, rooms):
    issues = [key for key in shared if key not in {"palette", "pattern"}]
    for field, (value, owner) in shared.items():
        if not value or not owner:
            issues.append(f"shared/{field}/approval")
    for site, site_rooms in rooms.items():
        for room, (method, owner) in site_rooms.items():
            if not method or not owner:
                issues.append(f"{site}/{room}/cleaning")
    return issues

shared = {"palette": ("sand", "design"), "pattern": ("linear", "design")}
sites = {"A": {"lobby": ("weekly_machine", "ops_a")},
         "B": {"reception": ("daily_spot", "ops_b")}}
assert open_items(shared, sites) == []
assert open_items({**shared, "fibre": ("wool", "design")}, sites) == ["fibre"]
assert open_items(shared, {"B": {"lobby": (None, "ops_b")}}) == ["B/lobby/cleaning"]
assert open_items(shared, {"B": {"lobby": ("not_applicable", "ops_b")}}) == []
assert open_items(shared, {"B": {"lobby": ("daily_spot", None)}}) == ["B/lobby/cleaning"]
Enter fullscreen mode Exit fullscreen mode

A duplicate room name in A and B causes no collision because it sits under a different site key. Each decision has one owner in this example; a production workflow with several approvers would need a separate sign-off record for each person.

What this model cannot tell you: it does not verify that the shared appearance is achievable across different cleaning regimes. That remains a judgement to confirm against selected product documents. The structure only makes ownership visible, which is the part software can actually enforce.

By ADA CARPET

Top comments (0)