archetypic.dev
The Observer
The Observer pattern defines a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically. In Jungian terms, the Observer is the archetype of awareness -- the pattern that says: to know is to be connected.
class Subject {
constructor() {
this.observers = [];
}
subscribe(observer) {
this.observers.push(observer);
}
notify(data) {
this.observers.forEach(obs => obs.update(data));
}
}
The Singleton
The Singleton ensures a class has only one instance and provides a global point of access to it. In archetypal terms, the Singleton is the Self -- the integrating center of the psyche, the one pattern that governs all others. There can be only one.
class Singleton {
static #instance;
static getInstance() {
if (!Singleton.#instance) {
Singleton.#instance = new Singleton();
}
return Singleton.#instance;
}
}
The Factory
The Factory pattern provides an interface for creating objects without specifying their concrete classes. In archetypal terms, the Factory is the Great Mother -- the generative force that produces new forms from a template. It abstracts creation itself, separating the act of making from the knowledge of what is made.
function createArchetype(type) {
const archetypes = {
hero: { role: 'transform', strength: 9 },
sage: { role: 'understand', wisdom: 10 },
shadow: { role: 'integrate', depth: 8 }
};
return archetypes[type] || null;
}
The Strategy
The Strategy pattern defines a family of algorithms, encapsulates each one, and makes them interchangeable. In the psyche, this is the Shapeshifter -- the archetype that adapts its approach to the situation, understanding that there is no single correct response, only a correct response for the current context.
About
archetypic.dev explores the intersection of software design patterns and Jungian archetypes. Every code pattern is a crystallized solution to a recurring problem. Every archetype is a crystallized response to a recurring situation in human existence. The parallel is not metaphorical -- it is structural.