Slide 1

Slide 1 text

Ahmad Nassri  CTO @ npm, Inc. Modern Patterns in Modular Software Architectures

Slide 2

Slide 2 text

Hello! I am Ahmad Nassri Syrian-Canadian, Entrepreneur, Developer, Open Source Advocate & Dog lover! CTO at npm, Inc. Contributor to OpenJS Foundation, Founder at Tech Masters Community, Mentor at NodeSchool Toronto, Organizer at Functions Conf, Host of Hacker:Bio Podcast.

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

Outline 1. What does “modular” mean? 2. Why does this matter? 3. How modern patterns work?

Slide 5

Slide 5 text

What does “modular” mean?

Slide 6

Slide 6 text

1978: The Unix philosophy 1. Make each program do one thing well. To do a new job, build afresh rather than complicate old programs by adding new features. 2. Expect the output of every program to become the input to another, as yet unknown, program. Don’t clutter output with extraneous information. Avoid stringently columnar or binary input formats. Don’t insist on interactive input. 3. Design and build software, even operating systems, to be tried early, ideally within weeks. Don’t hesitate to throw away the clumsy parts and rebuild them. 4. Use tools in preference to unskilled help to lighten a programming task, even if you have to detour to build the tools and expect to throw some of them out after you’ve finished using them.

Slide 7

Slide 7 text

The Unix philosophy emphasizes building simple, short, clear, modular, and extensible code that can be easily maintained and repurposed by developers other than its creators.

Slide 8

Slide 8 text

What is “not modular” Modular != Packages But we’ll talk about the relationship in a bit. Modular Architecture != Microservices The methods in which you choose to deploy and manage your software do not have to be defined by how you write and manage your code. (Modular Monoliths are a thing!) Modular Architecture != Modular Software Don’t shift the burden of managing all the software components to your users (or your user’s clients) Be Modular like Unix != Become a Unix/Linux guru! Modular patterns can apply to all and any development environment, in-fact many of the patterns I’m identifying evolved through the web platform.

Slide 9

Slide 9 text

❤ Humans Love Modular Code

Slide 10

Slide 10 text

No content

Slide 11

Slide 11 text

Why does this matter?

Slide 12

Slide 12 text

“Organizations which design systems are constrained to produce designs which are copies of the communication structures of these organizations.” Your Org is a mess!

Slide 13

Slide 13 text

Building software is about the people who code and the relationships between them as defined through process and architecture paradigms!

Slide 14

Slide 14 text

How does this work in a modern setting?

Slide 15

Slide 15 text

2019: The Unix philosophy Principles 1. Each module should do one thing well. 2. The output of every module to become the input to another. 3. Throw away the clumsy parts and rebuild them. 4. Use tools to lighten a programming task. 5. Modules should be easily maintained and repurposed by developers other than its creators.

Slide 16

Slide 16 text

"Each module should do one thing well" "Throw away the clumsy parts and rebuild them" #1 apps as packages ● No more /app or /src directories ● Use package.json , composer.json , Gemfile , requirements.txt , etc … ● Describe your environment with with Dockerfile and docker-compose.yml ● README is (mainly) about Environment & Deployment ● Maybe an index.js

Slide 17

Slide 17 text

Things you can package: ● UI Components ● API Routes ● Data Models and Associated Mock Test Data ● And yes, you can keep all of those in a monorepo!

Slide 18

Slide 18 text

acme-app/ ├── index.js ├── package.json ├── public/ │ ├── images/ │ ├── javascripts/ │ └── stylesheets/ │ └── style.css ├── views/ │ ├── users/ │ │ ├── error.pug │ │ └── index.pug │ ├── billing/ │ │ ├── error.pug │ │ └── index.pug │ └── layout.pug … … ├── routes/ │ ├── users.js │ └── billing.js └── tests/ ├── users/ │ ├── get.js │ └── post.js └── billing/ ├── get.js └── post.js

Slide 19

Slide 19 text

@acme/[email protected] ├── index.js ├── tests/ │ ├── get.js │ └── post.js ├── models/ │ └── users.js └── views/ ├── error.pug ├── index.pug └── layout.pug @acme/[email protected] ├── index.js └── package.json @acme/[email protected] └── public/ ├── images/ ├── javascripts/ └── stylesheets/ └── style.css @acme/[email protected] ├── index.js ├── tests/ │ ├── get.js │ └── post.js ├── models/ │ ├── subscriptions.js │ └── transactions.js └── views/ ├── error.pug ├── index.pug └── layout.pug

Slide 20

Slide 20 text

@acme/[email protected] └── index.pug @acme/[email protected] ├── index.js ├── tests/ │ ├── get.js │ └── post.js ├── models/ │ └── users.js └── views/ └── index.pug @acme/[email protected] ├── index.js └── package.json @acme/[email protected] ├── index.js ├── tests/ │ ├── get.js │ └── post.js ├── models/ │ ├── subscriptions.js │ └── transactions.js └── views/ └── index.pug @acme/[email protected] └── public/ ├── images/ ├── javascripts/ └── stylesheets/ └── style.css

Slide 21

Slide 21 text

● But that’s okay! ● Orgs are a mess of dependencies across humans Package management systems are designed to solve complex dependency management! Your Org is a mess!

Slide 22

Slide 22 text

#2 Documentation! "Modules should be easily maintained and repurposed by developers other than its creators" ● Soon after it’s written (if not before) you lose track of what your code actually does! ● Things that are documentation: ○ Meeting minutes ○ Bug reports ○ User Stories ○ Pull Request comments ○ Package Versions! ● Things that are NOT Documentation: ○ Slack chats ○ Discussions / Decisions on video calls ○ Your code!

Slide 23

Slide 23 text

● Uncovered code = module without tests #3: 100% Test Coverage "Modules should be easily maintained and repurposed by developers other than its creators" ● Testable code == maintainable code ● Full coverage isn’t about writing code with more tests, it’s about writing code that is more testable! ● Always code as if the person who ends up maintaining your code will be a violent psychopath who knows where you live! ● Forces you to create a better experience for the next person

Slide 24

Slide 24 text

#4: Automate all the things! "Use tools to lighten a programming task" ● Bots are here to help make your job easier (not take it away) ● Bots can: ○ Check for bugs ○ Open Pull Requests ○ Update Dependencies ○ Refactor your code ○ Merge Pull Requests ○ Thank each other for doing all the hard work! ○ … and more!

Slide 25

Slide 25 text

Use the tools luke!

Slide 26

Slide 26 text

Questions / Ideas / Feedback? You can find me at: ● twitter.com/@AhmadNassri ● [email protected] ● Ahmadassri.com ● npm install ahmad Thank you!

Slide 27

Slide 27 text

Test slide ● Can you read this text? ● How about this one? ● Is this readable?