Conceptualized by Alistair Cockburn. Also known as "Ports and Adapters".
In a nutshell:
Application Driver -> Primary Adapter -> Primary Port -> Use Case -> Secondary Port -> Secondary Adapter -> External System/Side Effect
| // PseudoCode for Manual DI | |
| public class ModuleAbcConfiguration { | |
| private static ModuleAbcApi moduleAbcApi; | |
| // Test Use (allows to inject mocks) | |
| ModuleAbcApi newTestInstance(externalModule) { | |
| return newInstance(externalModule); | |
| } | |
| // Production Use |
| const sinon = require("sinon"); | |
| const auth = { session: () => "real" }; | |
| sinon.stub(auth, "session").callsFake(() => { | |
| return "fake"; | |
| }); | |
| console.log(auth.session());// fake as expected | |
| const holdSession = auth.session;//hapens in app.js app.use(auth.session); | |
| sinon.restore(); | |
| console.log(auth.session()); // real as expected | |
| console.log(holdSession()); // fake ... UNEXPECTED! |
| function transposeChord(inputChord, halfStepsToTranspose) { | |
| const splittedChord = inputChord.split("/"); | |
| if (splittedChord.length > 2) throw new Error("Format error, too many slashes."); | |
| const [transposedChordBase, modifier] = transposeChordBase(splittedChord, halfStepsToTranspose); | |
| const maybeTransposedBass = transposeBass(splittedChord, halfStepsToTranspose); | |
| const transposedChordHasAccident = | |
| transposedChordBase.length > 1 && | |
| ["#", "b"].includes(transposedChordBase.charAt(1)); |
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="utf-8" /> | |
| <title>Parent Window</title> | |
| <!-- Use the angular js we use at this moment --> | |
| <script | |
| src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.8.0/angular.js" | |
| integrity="sha512-CiKQCmN86Y1I8Ewkt2gGnSNmsiVrS9Ez5MoudCBhTiBJScg+GjA9OlKdaeI0IuxdCl43Fs5x5zpeew2hfOatOA==" | |
| crossorigin="anonymous" |
| Math.sin(t) |
| X:1 | |
| T:CoronaMidi (t=d) | |
| M:5/8 | |
| K:G | |
| addaaaggdd | dadaccddcc | caggdaacaa | accaaccaac | dddcgadcdc | ddgdagadcd | | |
| gddcdcdaaa | cgaacdddaa | aadcdgdgdg | gcdgdcacdc | ggcdgcadgc | ddagdgcacd | | |
| cacgcagdad | aaddaadaac | daaddacdgd | cgddgacagg | acacgagdaa | cdcgdcdadc | | |
| ddcdgcaggc | dgcddacggd | ddcgdccgdg | ddgcagccga | dcadcagcac | adcdaggddd | | |
| cgdccgggdg | dgaccgaaag | gdaagadgga | gagccddgdc | ccdggdddca | acgagaaaac | | |
| acacgdccaa | cdcagdddgc | cdgddddaca | ggddcgcgac | gdgcdcgdac | gdggcdddgg | |
| version: '3.1' | |
| services: | |
| # phpmyadmin: | |
| # image: phpmyadmin/phpmyadmin | |
| # ports: | |
| # - 8080:80 | |
| # environment: | |
| # - "PMA_HOST=mysql" | |
| mysql: | |
| image: mysql:5.6 |
| # Open terminal where you want to create the jitsi sources folders and run: | |
| # Download sources | |
| git clone https://github.com/jitsi/jitsi-meet.git | |
| # enter project folder | |
| cd jitsi-meet | |
| # make sure you have node version 12 or higher. Check it with | |
| node -v | |
| # If it is not 12.x.x or higher you should stop, and install the right version of node. | |
| # Now install the npm packages |