Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Modern Patterns in Modular Software Architectures

Ahmad Nassri
October 25, 2019

Modern Patterns in Modular Software Architectures

Ahmad Nassri

October 25, 2019
Tweet

More Decks by Ahmad Nassri

Other Decks in Programming

Transcript

  1. 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.
  2. Outline 1. What does “modular” mean? 2. Why does this

    matter? 3. How modern patterns work?
  3. 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.
  4. 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.
  5. 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.
  6. “Organizations which design systems are constrained to produce designs which

    are copies of the communication structures of these organizations.” Your Org is a mess!
  7. Building software is about the people who code and the

    relationships between them as defined through process and architecture paradigms!
  8. 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.
  9. "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
  10. 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!
  11. 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
  12. @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
  13. @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
  14. • 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!
  15. #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!
  16. • 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
  17. #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!
  18. Questions / Ideas / Feedback? You can find me at:

    • twitter.com/@AhmadNassri • [email protected] • Ahmadassri.com • npm install ahmad Thank you!
  19. Test slide • Can you read this text? • How

    about this one? • Is this readable?