Use namespacing for apps and events

We deploy one app to Heroku. But it’s a big Rails app and there are smaller apps within the larger app.

Some examples of these apps:

When evolving cross cutting concerns, we think in terms of namespaces.

Problem πŸ”—

With one global namespace:

Solution πŸ”—

Namespacing allows us to:

What is namespacing? πŸ”—

Describe an entity (event, app, feature, components) by using period separated namespaces.

Examples:

Where do we use namespacing? πŸ”—

  1. Classes - Marketplace::AgentFinder::Searching::Search - classes won’t always fit into this exact structure - but where it fits we should use it
  2. Events - useful for domain events we send to Segment. We include the namespace in context.app.namespace which allows BI to filter events by app
  3. Components - inside LookBook, we have app specific components in nested directories that mirror this structure where possible
  4. Features - when defining features, we can define which part of the app they belong to

We have lots of other potential ideas where namespacing could be used over time - UTM tracking, campaign naming, email naming etc.

How do I construct a namespace? πŸ”—

Event namespaces πŸ”—

  1. Area - marketplace, calculators
  2. App name - agent_finder, forum, blog
  3. Bounded context - optional - searching, billing, leads
  4. Domain object - search, subscription, lead, company
  5. Event action - requested, shown, hidden, performed

App namespaces πŸ”—

  1. Area - marketplace, calculators
  2. App name - agent_finder, forum, blog

Feature namespaces πŸ”—

  1. Area - marketplace, calculators
  2. App name - agent_finder, forum, blog
  3. Feature name - report_limit, show_advanced_signature

Component namespaces πŸ”—

  1. Area - marketplace, calculators
  2. App name - agent_finder, forum, blog
  3. Component name - featured_agents, latest_news

Concepts explained πŸ”—

Area πŸ”—

Location analogy - country

App name πŸ”—

Location analogy - city

Bounded context πŸ”—

Namespacing best practices πŸ”—

Bad

Good

Examples πŸ”—