SlideShare a Scribd company logo
Dynamic Class
Loader in TypeScript
Asher Sterkin
A Software Engineer since 1978
“Ports and Adapters” in a Nutshell
Application Logic Isolated from Underlying Infrastructure
Well-Defined Ports for in- and out- Communication
Multiple
Adapters
upon
the
Need
Configurator to Plug Adapters into Ports
Multiple
Adapters
upon
the
Need
How Many is Many?
Port
Type
Port Direct
Call
CLI HTTP/Json HTTP/HTML RAM DynamoDB System
Local Remote Local Remote Local Remote
Driving IForParkingCars
IForIssuingFines
IForAdministering
Driven IForPaying
IForObtainingDateTime
IForStoringData
Not all Combinations are Valid!
Preserving the Same Acceptance Test Suite
cucumber.js
BuyTicket.feature.md
@ForParkingCars
…
configuration.json
BuyTicket.steps.ts
import { ForParkingCarsWorld } from './Worlds';
…
Worlds.ts
import { Configuration, Configurator } from '../outside';
import { ConfigWorld, setupWorld } from '@cucumber/config-world';
class BlueZoneWorldBase extends ConfigWorld<Configuration, Configurator>{
…
export class BlueZoneWorld extends BlueZoneWorldBase {
…
export class ForParkingCarsWorld extends BlueZoneWorld {
…
setupWorld("@ForParkingCars", ForParkingCarsWorld);
Configurator.ts
export type Configuration = {
readonly ForPaying?: string;
readonly ForStoringData?: string;
..
}
export class Configurator implements IConfigurator {
private classLoader: DynamicClassLoader;
…
}
Dynamic Configuration
Module path per port
Dynamic Configuration
Dynamic Configuration
Blame TS type erasure
Dynamic Class Loader
Using Dynamic Module Loader
Returns new(..) function for
this ClassType
Dynamic Module Loader
By convention
Module Path
Resolver
This is what happens
when one trusts
ChatGPT too much 😠
tsconfig-paths
Configuration
tsconfig.json
dynamodb-local-config.json
src
outside
dynamodb-local
ForStoringData.ts
…
Open-closed Principle
"software entities
(classes, modules,
functions, etc.) should be
open for extension, but
closed for modification"
Bertrand Meyer
To be Continued …

More Related Content

PDF
Ports and Adapters in TypeScript - NodeJS TLV MeetpUp - Nov 7 2024.pdf
PDF
Generic _Composite_ in Python_ PyWeb TLV Meetup 07.08.2024.pdf
PDF
Ported to Cloud with Wing_ Blue ZnZone app from _Hexagonal Architecture Expla...
PDF
Essence of Requirements Engineering: Pragmatic Insights for 2024
PDF
Cloud Infrastructure from Python Code: PyCon DE-23
PDF
PyCascades-23.pdf
PDF
PyConFR-23 Talk.pdf
PDF
pyjamas22_ generic composite in python.pdf
Ports and Adapters in TypeScript - NodeJS TLV MeetpUp - Nov 7 2024.pdf
Generic _Composite_ in Python_ PyWeb TLV Meetup 07.08.2024.pdf
Ported to Cloud with Wing_ Blue ZnZone app from _Hexagonal Architecture Expla...
Essence of Requirements Engineering: Pragmatic Insights for 2024
Cloud Infrastructure from Python Code: PyCon DE-23
PyCascades-23.pdf
PyConFR-23 Talk.pdf
pyjamas22_ generic composite in python.pdf

More from Asher Sterkin (12)

PDF
If your computer is cloud what its Operating System look like?
PDF
Serverless flow programming a new perspective (py web meetup, sept 2nd, 2019...
PDF
Documenting serverless architectures could we do it better - o'reily sa con...
PDF
Developing cloud serverless components in Python: DDD Perspective
PDF
Shaping serverless architecture with domain driven design patterns - py web-il
PDF
Shaping serverless architecture with domain driven design patterns
PDF
Domain driven design: a gentle introduction
PDF
Strategy toolbox for startsups
PDF
AI as a service
PDF
Serverless ddd
PDF
Software strategy for startups
PDF
What is exactly anti fragile in dev ops - v3
If your computer is cloud what its Operating System look like?
Serverless flow programming a new perspective (py web meetup, sept 2nd, 2019...
Documenting serverless architectures could we do it better - o'reily sa con...
Developing cloud serverless components in Python: DDD Perspective
Shaping serverless architecture with domain driven design patterns - py web-il
Shaping serverless architecture with domain driven design patterns
Domain driven design: a gentle introduction
Strategy toolbox for startsups
AI as a service
Serverless ddd
Software strategy for startups
What is exactly anti fragile in dev ops - v3
Ad

Recently uploaded (20)

PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PPTX
ai tools demonstartion for schools and inter college
PPTX
CHAPTER 2 - PM Management and IT Context
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PPTX
Transform Your Business with a Software ERP System
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PDF
System and Network Administraation Chapter 3
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PDF
Digital Systems & Binary Numbers (comprehensive )
PDF
Understanding Forklifts - TECH EHS Solution
PPT
Introduction Database Management System for Course Database
PDF
Nekopoi APK 2025 free lastest update
PPTX
L1 - Introduction to python Backend.pptx
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
ai tools demonstartion for schools and inter college
CHAPTER 2 - PM Management and IT Context
Navsoft: AI-Powered Business Solutions & Custom Software Development
How to Choose the Right IT Partner for Your Business in Malaysia
Transform Your Business with a Software ERP System
wealthsignaloriginal-com-DS-text-... (1).pdf
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
Odoo Companies in India – Driving Business Transformation.pdf
System and Network Administraation Chapter 3
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
Wondershare Filmora 15 Crack With Activation Key [2025
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
Digital Systems & Binary Numbers (comprehensive )
Understanding Forklifts - TECH EHS Solution
Introduction Database Management System for Course Database
Nekopoi APK 2025 free lastest update
L1 - Introduction to python Backend.pptx
Design an Analysis of Algorithms II-SECS-1021-03
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
Ad

Dynamic Class Loader in TypeScript - Node.js-il Open Mic- Dec 23 2024.pdf