⚙️ STARLARK RUNE DIFFICULTY: Apprentice Structural

The Facade

Providing a unified gateway to complex build sub-systems.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Facade
ARCANUM SCHOOL: Illusion // Simplification
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// STARLARK PATTERN //
# Complex, granular sub-systems
def _resource_allocator():
    return struct(reserve = lambda cores: "Reserved %s cores" % cores)
    
def _compiler_toolchain():
    return struct(compile = lambda src: "%s.o" % src)
    
def _linker_toolchain():
    return struct(link = lambda objs: "binary_executable")

# The Facade
def simple_build_facade():
    alloc = _resource_allocator()
    comp = _compiler_toolchain()
    link = _linker_toolchain()
    
    def _build_project(srcs):
        alloc.reserve(4)
        objs = [comp.compile(s) for s in srcs]
        return link.link(objs)
        
    return struct(build = _build_project)

# Usage
system = simple_build_facade()
output = system.build(["main.c", "util.c"])

When crafting .bzl extensions, exposing every intricate toolchain setting, resource allocator, and linking flag can overwhelm an apprentice. The Facade pattern masks the chaotic inner workings of a rule under a single, unified interface. Instead of invoking a dozen different macros, the end-user simply calls the facade, which intelligently orchestrates the underlying subsystems while maintaining hermetic integrity.

Runic Tags: #structural #starlark #hermetic