HomeToolsAbout

Structural Considerations

Domain Isolation?

If a domain isolation is strong, you don't necessarily have to extract out the module the same structure as other domains

  • e.g. if you're using a service/repository/gateway split
    • you don't have to extract out gateway from the same directory as a service when the domain isolation is strong

Public Contract

Export symbols through public contract (index.ts)

  • avoid deep imports and only use public exports
    • don’t reference file, reference folder names
      • index.ts is a JS feature to reference default export of a directory

What does this mean: export/import of type references only in index

  • If the referenced is not in index, it shouldn’t be referenced and abstracted away

Class as Type

Class itself can be an interface contract

Since instantiation of class is an object (what essentially Interface achieves), you can use the Class directly as the interface

// Bclass.js import Aclass from "./Aclass.js"; export class Bclass { constructor(private a: Aclass) { ... } }

Another Valid Example

class Person { "name": "sam" } let s = "hello"; let n: Person; n = { "name": "sam", }
AboutContact