Welcome back! In the previous chapter, Stub Module Definition, we built a safe, empty placeholder for our project. We created a "Coming Soon" sign that does nothing and stays hidden.
Now, we are going to look closer at that sign. specifically at the text written on it.
Imagine you are at a large conference. You are wearing a badge. If your badge is blank, people know you are a human attending the conference, but they can't call you by name, they can't assign you to a specific workshop, and they can't deliver mail to you.
In software, our application is the conference, and the Component Identity is your name badge.
In Chapter 1, we named our module 'stub'. This is like wearing a badge that says "Guest". It works, but it's generic.
Now, we want to formally introduce our Context Visualization tool to the system. Even if the tool is broken, turned off, or hidden, the system needs to know exactly who is turned off.
The Goal: Change the generic identity 'stub' to a unique identifier: 'ctx_viz'.
The Component Identity is defined by a single property in our code: name.
This string acts as a unique key (a fingerprint) for the module. No two modules in the entire application are allowed to have the same name.
Let's update our index.js file. We are keeping the logic disabled (for now), but we are updating its ID card.
// File: index.js
export default {
isEnabled: () => false,
isHidden: true,
// OLD: name: 'stub'
// NEW:
name: 'ctx_viz'
};
What happens now?
ctx_viz module here. It is currently disabled."By changing this string, we allow the system to log specific errors like "Error in ctx_viz" instead of "Error in stub," which makes fixing bugs much easier.
How does the application use this name? Think of the application core as a Librarian organizing books.
When the application starts, it doesn't just pile modules in a heap. It sorts them into a catalog using their names.
Here is the conversation between the System Core and your Module during the setup phase:
Even though the module is disabled, it must be registered first. The system cannot check if a module is enabled if it doesn't know the module's name to look it up.
Let's look at a simplified version of the code that runs inside the Application Core (the code that consumes your module).
The system likely uses an object (a dictionary) to store all modules.
// Inside the Application Core logic
const moduleRegistry = {};
function register(module) {
// We use the .name property as the Key
const id = module.name;
// Store it in the registry
moduleRegistry[id] = module;
console.log(`Registered: ${id}`);
}
Explanation:
module.name (which is 'ctx_viz').moduleRegistry['ctx_viz'].Once the module is stored in the registry by its name, we can do powerful things:
'ctx_viz' in a database. We will see how this powers the isEnabled check in Feature Flagging Strategy.You have successfully graduated your module from a generic placeholder to a specific identity!
name string property.'ctx_viz', even though it is still sleeping (disabled).Now that our module has a name, the system can check its specific permissions. It's time to learn how to turn the module ON and OFF safely.
Next Chapter: Feature Flagging Strategy
Generated by Code IQ