Learning
  • Software Engineering Golden Treasury
  • Trail Map
  • Caching
    • Alternatives to use before using cache
    • Caching Architecture
    • Cache Invalidation and Eviction
    • Cache Patterns
    • Cache
    • Consistency
    • Distributed Caching
    • Issues with caching
    • Types of caches
  • Career
    • algo types
    • Backend Knowledge
    • Burnout
    • consultancy
    • dev-level
    • Enterprise Developer
    • how-to-get-in-tech-from-other-job
    • how-to-get-into-junior-dev-position
    • induction
    • Interview
    • junior
    • mid
    • New Job
    • paths
    • Principle/staff Engineer
    • Requirements for job
    • Senior Dev capabilities
    • learning
      • automating-beginner
      • company1
        • analyst-progression
        • core-eng-progression
        • dev-progression
        • perf-eng-progression
        • soft-deliv-progression
    • mentoring
      • mentor-resources
    • recruitment
      • questions
      • Spotting posers
  • Computer Science
    • boolean-algebra
    • Compiler
    • Finite State Machine
    • Hashing
    • Algorithms
      • Breadth Firth Search
      • complexity
      • Depth First Search
      • efficiency
      • Sliding Window
      • sorting
    • data-structures
      • AVL Trees
      • data-structures
      • Linked List
    • machines
      • Intel Machine
      • Turing Machine
      • von neumann machine
      • Zeus Machine
  • devops
    • The 5 Ideals
    • microservice
    • Artifact repository
    • Bugs and Fixes
    • Build police
    • cloud-servers
    • Deployments
    • Environments
    • GitOps
    • handling-releases
    • infrastructure-as-code
    • System Migrations
    • SDP
    • On Premises Hosting
    • Properties/configuration
    • Release process
    • Release
    • Roll Outs
    • serverless
    • Serverless
    • Cloud Services
    • Versioning
    • AWS
      • deploy-docker-esc
      • cloud-practitiioner-essentials-notes
        • Module 1 - Intro to AWS
        • Module 2 Compute in the cloud
        • Module 3 Global Infrastructure and Reliability
        • Module 4 Networking
        • Module 5 Storage and Databases
        • Security
        • 7 Monitoring and Aanlytics
        • 8 Pricing and Support
        • 9 Migration and Innovation
      • developer-associate
        • AWS Elastic Beanstalk
    • build-tools
      • Managing dependecies
      • Apache ANT
      • Gradle
        • Custom Plugins
        • local-jars
      • Project Management - maven
        • Archtypes
        • Build Lifecycles
        • Customising build lifecycle
        • Dependencies
        • Directory layout
        • jar-files
        • one-to-one
        • Modules
        • Phases
        • Maven Plugins
        • POM
        • profiles
        • setup
        • Starting a maven project
        • wrapper
    • CI/CD
      • Continuous Delivery
      • zookeeper
      • Continuous Integration (CI)
      • github-actions
      • Pipeline
      • Teamcity
    • Cloud computing
      • Overview
      • Service Models
      • Cloud Services
    • containers
      • Best Practices
      • Docker
    • Infrastructure
      • IT Infrastructure Model
      • Non functional Attributes (Quality Attributes)
        • Infrastructure Availability
        • Performance
        • Secruity
    • monitoring
      • Alerting
      • Monitoring & Metrics
      • Metrics
      • Ready pages
      • Splunk
      • Status pages
      • notes-devops-talk
      • logging
        • logging
        • issues
        • Logging
        • Logging
    • Service mesh
      • Service Discovery
      • Istio
    • Terraform
    • container-management
      • Kubernetes
        • commands-glossary
        • OLTP
        • config-maps
        • Links
        • ingress
        • SDP
        • minikube
        • filter
        • indexes
        • sidecar
        • continuous-deployment
  • General Paradigms
    • CAP theorem
    • designing data-intensive applications summary
    • a-philosophy-of-software-design-notes
    • Aspect oriented Programming (AOP)
    • Best Practice
    • Cargo Cult
    • Clean Code
    • Coding reflections
    • Cognitive Complexity
    • Complexity
    • Conventions
    • Design discussions
    • Design
    • Error Handling Checklist
    • Exceptions
    • Feature Flags/toggle
    • Functional requirements
    • Last Responsible Moment
    • Lock In
    • Named Arguments
    • Naming
    • Performance Fallacy
    • Quality
    • Redesign of a system
    • Resuse vs Decoupling
    • Rules for software designs
    • Sad Paths
    • Scaling Webservices
    • Scientific Method
    • stream-processing
    • Upstream and Downstream
    • Patterns
      • Client-SDK-Pattern
      • ORM
      • Api gateway
      • Business Rules Engine
      • cache
      • Composition Root
      • Dependency Injection Containers
      • Dependency Injections
      • Double Dispatch
      • Exception Handling
      • Gateway pattern
      • Humble Object
      • Inheritance for reuse
      • Null Object Pattern
      • Object Mother
      • Patterns
      • Collection pipeline pattern
      • Service Locator
      • Setter constructor
      • Static factory method
      • Step Builder Pattern
      • telescopic constructors
      • Toggles
      • API
        • Aims of API designs
        • Avoid Checked Exceptions
        • Avoid returning nulls
        • Be defensive with your data
        • convience-methods
        • Fluent Interfaces
        • Loan Pattern
        • prefer-enums-to-boolean-returns
        • return-meaningful-types
        • Small intefaces
        • Support Lambdas
        • Weakest type
      • Gang of Four
        • Builder
        • Factory Pattern
        • Strategy Pattern
        • Template
        • abstract Factory
        • Adapter
        • Bridge Pattern
        • Chain of responsibility
        • Command Pattern
        • Composite Design Pattern
        • Decorator Pattern
        • Facade Pattern
        • Flyweight pattern
        • Guard Clause
        • Interpreter
        • html
        • Mediator Pattern
        • Memento Pattern
        • Observer
        • Prototype
        • Proxy
        • Singleton
        • State Pattern
        • Visitor Pattern
    • Architecture
      • Entity Component System
      • Integration Operation Segregation Principle
      • Adaptable Architecture
      • Architecture
      • C4 Modelling
      • cell-based
      • Clean/Hexagonal Architecture
      • Codifying architecture
      • Correct By configuration
      • Cost Base Architecture
      • Data Oriented Design
      • deliberate
      • Domain oriented DOMA
      • Event Driven Architecture
      • Evolutionary Architecture
      • examples
      • Feature Architecture
      • Framework and Libraries
      • functional-core-imperative-shell
      • Layered Architecture
      • Micro services
      • monoliths-to-services
      • Multi tiered Architecture
      • Multi tenant application
      • Resilient Architecture
      • stage event driven architecture (SEDA)
      • links spring rest app
      • Tomato Architecture
      • Tooling
      • Types of architecture
      • checklist
        • Checklist for new project
        • Back end Architecture Checklist
        • Front end Architecture Checklist
        • Mobile Architecture Checklist
      • Cloud Patterns
        • Command and Query Responsibility Segregation (CQRS)
        • Event Sourcing & CQRS
        • Asynchronous Request and Reply
        • Circuit Breaker
        • Retry
        • Sidecar
        • Strangler pattern
      • Domain driven design
        • value & entity
      • Microservices
        • Alternatives to choosing microservices first when scaling
        • Consistency in distributed systems
        • 12 Factor applications
      • Modularity
        • Module monolith vs Microservices
        • Spring Moduilth
      • Architecture Patterns
        • Hexagonal architecture
        • Inverting dependencies
        • Layering & Dependency Inversion Principle
        • Mappings
        • Vertical Slice architecture
        • Web Client Server
        • domain
          • Business and Data Layers Separation
          • DTO
          • Domain Model Pattern
          • Domain Object
          • Transaction Script/ Use Case pattern
        • Enterprise Patterns
          • Concurrency
          • Distribution strategies
          • Domain layer patterns
          • Layering/organisation of code
          • Mapping to datasource
          • Session State
        • Usecases
          • Use case return types
      • Serverless
        • Knative
    • Design architecture aims
      • back of envelope
      • Design ideas
      • Design mistakes
      • high-volume-design
      • ISO Quality Attributes
      • Non functional requirements
      • “Designing for Performance” by Martin Thompson
      • High Performance
      • Qaulity Attributes
        • Availability
        • System Availability
        • Fault Tolerance
        • interoperability
        • Latency
        • Maintability
        • Modifiability
        • Performance
        • Readability
        • Reliability
        • Scalability vs performance
        • Scalability
        • Scaling
        • statelessness
        • Testability
        • Throughput
      • System Design
      • web-scalability-distributed-arch
        • scalable-and-distributed-web-architecture
    • README
      • Conflict-free Replicated Data Type
      • Fallacies
      • Load balancing
      • Rate Limiting
      • Transactions
    • Patterns of Enterprise Application Architecture
      • Repository Pattern
      • Rules Engines
      • scatter-gather
      • Specification Design Pattern
      • Table Driven Development
      • Workflow Design Patterns
        • Triggers
    • Principles
      • Do It Or Get Bitten In The End
      • Dont Repeat Yourself
      • Habitability
      • Keep it simple
      • Responsibility Driven Design
      • Ya Ain’t Gonna Need It
      • Conceptual Overhead
      • CUPID
      • Reuse existing interfaces
      • Facts and Fallacies
      • locality of behaviour
      • Separation of Concerns
      • Simplicity
      • SLAP principle
      • Step down rule
      • Unix Philosophy
      • Wrong abstractions
      • SOLID
        • 1. Single Responsibility Principle
        • 2. Open Close Principle
        • 3. Liskov Substitution Principle
        • 4. Interface Segregation Principle
        • 5. Dependency Inversion Principle
        • GRASP (General Responsibility Assignment Software Principles)
        • Solid for packages
          • jobs
          • CCP
          • CRP
          • REP
          • egress
          • gossip-protocol
        • STUPID
    • programming-types
      • Coding to Contract/Interface
      • Links
      • Declarative vs Imperative Programming Languages
      • defensive-programming
      • Design by contract
      • Domain Specific Languages (DSL)
      • Event Driven
      • file-transfers
      • Logical Programming
      • Mutability
      • Self Healing
      • Simplicity
      • Type Driven Design
      • Value objects
      • Aspect Oriented Programming
      • Concurrent and Parallel Programming
        • Actor Model
        • Asynchronous and Synchronous Programming
        • Batch processing
        • Concurrency Models
        • SAP
        • Multithreading
        • Non Blocking IO
        • Optimistic vs Pessimistic Concurrency
        • Thread per connection or request model
        • Actor
        • aysnchronous-tasks
          • Computational Graphs
          • Divide and conquer
          • Future
          • Thread Pool
        • barriers
          • Barriers
          • Race conditions
        • design
          • agglomeration
          • Communication
          • Mapping
          • Partitioning
        • Liveness
          • Abandoned Lock
          • Deadlocks
          • Livelock
          • Starvation
        • locks
          • Read write lock
          • Reentrant lock
          • Try Lock
        • Mutual Exclusion
          • Data Races
          • Mutual Exclusion AKA Locks
        • performance
          • Amdahl's Law
          • Latency, throughput & speed
          • Measure Speed up
        • synchronization
          • Condition variable
          • producer consumer pattern
          • Semaphore
        • Threads and processes
          • Concurrent and parallel programming
          • Daemon Thread
          • Execution Scheduling
          • sequential-parallel
          • Thread Lifecycle
          • threads-and-processes
      • Functional Programming
        • Currying
        • design-patterns-to-func
        • imperative-programming
        • First class functions
        • Functional Looping
        • Higher Order Functions
        • Immutability
        • Issues with functional Programming
        • Lambda calculus
        • Lazy & Eager
        • map
        • Monad
        • Railway Programming
        • Recursion
        • Reduce
        • referential-transparacy
        • Referential transparency
        • Supplier
      • oop-design
        • Issues with object oriented code
        • Aggregation
        • Anti Patterns
        • Association
        • class-and-objects
        • Composition
        • general-laws-of-programming
        • general-notes
        • Getters and Setters
        • Inside out programming
        • Inversion of control
        • oop-design
        • Other principles
        • Outside in programming
        • Readability
        • Why OO is bad
        • README
          • abstraction
          • encapsulation
          • inheritance
          • Polymorphism
        • clean-code
          • Code Smells
          • Comments
          • Naming
          • CLEAN design
            • code is assertive
            • Cohesion
            • Connascence
            • Coupling
            • Encapsulation
            • Loose Coupling
            • Nonredundant code
      • Reactive Programming
        • reactive-programming
    • Projects and Software types
      • Applicatoin Development
      • Buying or creating software
      • Console Applications
      • Embedded Software development
      • Enterprise
      • Framework Development
      • Games
      • Library development
      • Rewriting
      • White Label Apps
    • State Machines
      • Spring State Machine
  • Other
    • 10x devs
    • Aim of software
    • Choosing Technologies
    • Coding faster
    • Component ownership
    • developer-pain-points
    • Developer Types
    • Effective Software design
    • Full Stack Developer
    • Good coder
    • Issues with Software Engineering and Engineers
    • Learning
    • Logic
    • Role
    • Software Actions
    • Software craftmanship
    • Software Designed
    • Software Engineering
    • Software
    • article-summaries
      • General notes
      • Summary of The Grug Brained Developer A layman's guide to thinking like the self-aware smol brained
      • improve-backend-engineer
      • Optimising Api
      • Simple and Easy
    • README
  • Hardware
    • Cpu memory
    • Storage
  • Integration
    • GRPC
    • API
    • Apis and communications between apps
    • asynchronous and synchronous communications
    • Batch Processing
    • Communications between apps
    • Delivery
    • Distributed Computing
    • Entry point
    • Event Source
    • SDP
    • egress
    • Graphql
    • Idempotency
    • Libraries
    • Long Polling
    • Multiplexing & Demultiplexing
    • Publish Subscribe
    • Push
    • Request & Response
    • REST
    • Remote Method Invocation
    • Remote Procedure Calls
    • Server Sent Events
    • Short Polling
    • Sidecars
    • SOAP
    • Stateless and Stateful
    • Streams
    • Third Party Integrations
    • wdsl
    • Web Services
    • Webhooks
    • repository
    • Kafka
      • Kafka Streams
    • message-queues
      • ActiveMQ
      • Dead Letter Queue
      • JMS
      • Messaging
  • Languages
    • C
    • Choosing A Language
    • cobol
    • Composite Data Types
    • creating
    • Date time
    • Numbers
    • Pass by value vs Pass by reference
    • Primitive Data Types
    • REST anti-patterns
    • Rust
    • Scripting
    • Static typing
    • string
    • Task Oriented Language
    • assembly
    • Getting started
      • Functional Concepts
    • cpp
    • Java
      • Code style
      • Garbage Collection
      • Intellij Debugging
      • Artifacts, Jars
      • Java internals
      • Java resources
      • Java versions
      • JShell
      • Libraries
      • opinionated-guide
      • Starting java
      • Java Tools
      • Why use java
      • Advanced Java
        • Annotations
        • API
        • Database and java
        • Debugging Performance
        • Files IO
        • Finalize
        • JDBC
        • jni
        • Libraries
        • Logging
        • SAP
        • Memory Management
        • Modules
        • OTher
        • Packaging Application
        • Pattern matching
        • performance
        • Properties
        • Reference
        • reflection
        • Scaling
        • Scheduling
        • secruity
        • Serilization
        • Time in Java
        • validation
        • Vector
        • Concurrency and Multithreaading
          • Akka
          • ExecutorCompletionService
          • Asynchronous Programming
          • Concurrency and Threads
          • CountDownLatch
          • Conccurrent Data Structures
          • Executor Service
          • Futures
          • reactive
          • Semaphore
          • structured concurrency
          • Threadlocal
          • Threads
          • Virtual Threads
          • Mutual Exclusion
            • Atomic
            • Synchronized
            • Thread safe class
            • Threads
        • debug
          • heap-dumps
          • thread-dumps
        • functional
          • Collectors
          • Exception Handling
          • Flatmap
          • Functional Programming
          • Generators
          • Immutability
          • issues
          • Optional
          • Parallel Streams
          • Reduce
        • networks
          • HTTP client
          • servlet-webcontainers
          • sockets
          • ssl-tls-https
      • Basics of java
        • compilation
        • computation
        • Conditonal/Flow control
        • Excuting code
        • Instructions
        • Looping/Iterating
        • memory-types-variables
        • methods
        • Printing to screen/debugging
        • Setup the system
        • Data structures
          • Arrays
          • Arayslist/list
          • Map
      • Effective Java notes
        • Creating and Destroying Objects
        • Methods Common to All Objects
        • best-practice-api
        • Classes and Interfaces
        • Enums and Annotations
        • Generics
      • framework
        • aop
        • bad
        • Dagger
        • Databases
        • Lombok
        • Mapstruct
        • netty
        • resliance4j
        • RxJava
        • Vert.x
        • Spring
          • Spring Data Repositories
          • actuator
          • cloud-native
          • H2 Db in Spring
          • Initializrs
          • JDBC Template
          • Java Persistence API (JPA)
          • kotlin
          • Pitfalls and advice
          • PRoxies
          • Reactive
          • spring security
          • spring-aop
          • Spring Boot
          • spring-jdbc
          • Spring MVC
          • Spring Testing
          • Testing
          • Transaction
          • patterns
            • Component Scan Patterns
            • Concurrency
            • Decorator Pattern in Spring
        • Micronaut
          • DI
        • Quarkus
          • database
          • Links
      • Intermediate level java
        • String Class
        • Assertions
        • Casting
        • Clonable
        • Command line arguments
        • Common Libraries/classes
        • Comparators
        • Where to store them?
        • Shallow and Deep Copy
        • Date and Time
        • Enums
        • Equals and Hashcode
        • Equals and hashcode
        • Exceptions
        • Final
        • Finally
        • Generics
        • incrementors
        • Null
        • packages and imports
        • Random numbers
        • Regex
        • Static
        • toString()
        • OOP
          • Accessors
          • Classes
          • Object Oriented Programming
          • Constructors
          • Fields/state
          • Inheritence
          • Interfaces
          • Methods/behaviour
          • Nested Classes
          • Objects
          • Static VS Instance
          • Whether to use a dependency or static method?
        • Other Collections
          • Other Collections
          • Arraylist vs Linkedlist
          • LinkedHashMap
          • Linked List
          • Priority queue
          • Sequenced Collections
          • Set
          • Shallow vs Deep Copy
          • Time Complexity of Collections
          • What Collection To use?
    • kotlin
      • Domain Specific Language
      • learning
      • Libraries
      • Personal Roadmap
      • Links
    • Nodejs
      • Performance
  • Management & Workflow
    • Agile
    • Take Breaks
    • # Communication
    • Engineering Daybook
    • Estimates
    • Feedback Loops
    • Little's law
    • Managing Others
    • poser.
    • Presentations
    • self-improvement
    • software-teams
    • Task List
    • trade-off
    • Types of devs
    • Type of work
    • Waterfall Methodology
    • coding-process
      • Bugs
      • Code Review
      • Code Reviews
      • Documentation
      • Done
      • Handover
      • Mob Programming
      • Navigate codebase
      • Pair Programming
      • Pull Requests
      • How to do a story
      • Story to code
      • Trunk based development
      • Xtreme Programming (XP)
      • debugging
        • 9 Rules of Thumb of Dubugging
        • Debugging
        • using-debugger
      • Legacy code
        • Legacy crisis
        • Working with legacy code
    • Managing work
      • Theory of constraints
      • Distributed Teams
      • estimations
      • Improving team's output
      • Kanban
      • Kick offs
      • Retrospectives
      • Scrum
      • Sign offs
      • Stand ups
      • Time bombs
      • Project management triangle
    • Notion
    • recruitment
      • In Person Test
      • Interviews
      • Unattended test
  • Networks
    • Content Delivery Network - CDN
    • DNS
    • cache control
    • Cookies and Sessions
    • Docker Networking
    • Duplex
    • Etags
    • HTTP Cache
    • HTTP - Hyper Text Transfer Protocol
    • HTTP/2
    • Http 3
    • Internet & Web
    • iptables
    • Keep alive
    • Leader Election
    • Load balancer
    • long-polling
    • Network Access Control
    • Network Address Translation (NAT)
    • Network Layers
    • Nginx
    • OSI network model
    • Persistent Connection
    • Polling
    • Proxy
    • Quic
    • reverse-proxy
    • servers
    • Server sent events (SSE)
    • SSH
    • Streaming
    • Timeouts
    • Url Encoding
    • Web sockets
    • WebRTC (Web Real-Time Communication)
    • Wireshark
    • tcp/ip
      • Congestion
      • IP - Internet Protocol
      • TCP - Transmission Control Protocol
  • Operating Systems
    • Cloud Computing
    • Distributed File Systems
    • Distributed Shared Memory
    • Input/Output Management
    • Inter-Process Communication
    • Threads and Concurrency
    • Virtualization
    • Searching using CLI
    • Bash and scripting
    • Booting of linux
    • makefile
    • Memory Management
    • Processes and Process Management
    • Scheduling
    • Scripting
    • Links
    • Ubuntu
    • Unix File System
    • User groups
    • Linux
  • Other Topics
    • Finite state machine
    • Floating point
    • Googling
    • Setup
    • Unicode
    • Machine Learning
      • Artificial Intelligence
      • Jupyter Notebook
    • Blockchain
    • Front End
      • Single Page App
      • cqrs
      • css
      • Debounce
      • Dom, Virtual Dom
      • ADP
      • htmx
      • Island Architecture
      • Why use?
      • Java and front end tech
      • mermaidjs
      • Next JS
      • javascript
        • Debounce
        • design
        • Event loop
        • testing
        • Typescript
        • react
          • Design
          • learning
          • performance
          • React JS
          • testing
      • performance
      • Static website
    • jobs
      • Tooling
      • bash text editor - vim
      • VS code
      • scaling
        • AI Assistant
        • Debugging
        • General features and tips and tricks
        • IDE - Intellij
        • Plugins
        • Spring usage
  • persistance
    • ACID - Atomicity, Consistency, Isolation, Durability
    • BASE - Basic Availability, Soft state, Eventual Consistency
    • Buffer
    • Connection pooling
    • service
    • Database Migrations - flywaydb
    • Databases
    • Eventual Consistency
    • GraphQL
    • IDs
    • indexing
    • MongoDB
    • Normalisation
    • ORacle sql
    • Partitioning
    • patterns
    • PL SQL
    • Replication and Sharding
    • Repository pattern
    • Sharding
    • Snapshot
    • Strong Consistency
    • links
    • Files
      • Areas to think of
    • hibernate
      • ORM-hibernate
    • Indexes
      • Elastisearch
    • relationships
      • many-to-many
      • SDP
      • serverless
      • x-to-x-relationships
    • sql
      • Group by
      • indexes
      • Joins
      • Common mistakes
      • operators
      • performance
    • types
      • maven-commands-on-intellij
      • in-memory-database-h2
      • Key value database/store
      • Mongo DB
      • NoSQL Databases
      • Relational Database
      • Relational Vs Document Databases
  • Security
    • OAuth
    • API Keys
    • Certificates and JKS
    • Cluster Secruity
    • Communication Between Two Applications via TLS
    • Cookies & Sessions
    • CORS - Cross-Origin Resource Sharing
    • csrf
    • Encryption and Decryption
    • Endpoint Protection
    • JWT
    • language-specific
    • OpenID
    • OWASP
    • Secrets
    • Secruity
    • Servlet authentication and Authorization
    • vault
  • Testing, Maintainablity & Debugging
    • Service-virtualization and api mocking
    • a-test-bk
    • Build Monitor
    • Builds
    • Code coverage
    • consumer-driven contract testing
    • Fixity
    • Living Documentation
    • Mocks, Stubs & Doubles
    • patterns
    • Quality Engineering
    • Reading and working with legacy code
    • Reading
    • remote-debug-intellij
    • simulator
    • Technical Debt
    • Technical Waste
    • Test cases
    • Test Data Builders
    • Test Pyramids
    • Test Types
    • Testing Good Practice
    • Testing
    • What to prime
    • What to test
    • Debugging
      • Debugging in kubernetes or Docker
    • fixing
      • How to Deal with I/O Expense
      • How to Manage Memory
      • How to Optimize Loops
      • How to Fix Performance Problems
    • Legacy Code
      • Learning
      • Legacy code
      • techniques
    • libraries
      • assertj
      • Data Faker
      • Junit
      • mockito
      • Test Containers
      • Wiremock
      • Yatspec
    • Refactoring
      • Code Smells
      • refactoring-types
      • Refactoring
      • Technical Debt
      • pyramid-of-refactoring
        • Pyramid of Refactoring
    • Test first strategies
      • Acceptance Testing Driven Developement (ATDD)
      • Behaviour Driven Development/Design - BDD
      • Inside out
      • Outside in
      • Test driven development (TDD)
    • testing
      • Acceptance tests
      • How Much Testing is Enough?
      • Approval Testing
      • Bad Testing
      • End to end tests
      • Honeycomb
      • Testing Microservices
      • Mutation testing
      • Property based testing
      • Smoke Testing
      • social-unit-tests
      • solitary-unit-tests
      • Static Analysis Test
      • Unit testing
  • Version Control - Git
    • Branch by Abstraction
    • feature-branching
    • Git patches
    • Trunk Based Development
Powered by GitBook
On this page

Was this helpful?

What

  • A technique that enables loose coupling

  • collaborating classes should rely on infrastructure to provide necessary services

  • A dependency references other classes to complete some work

    • delegate work to another class

    • send a message to another object from the calling class

      • Just calling an instance method of an object with or without arguments

  • All classes can have dependencies, it is how they managed

  • Dependencies are provided to a class instead of the class creating them

    • This happens at creation time called object composition in a composition root

  • the app has control and proactively injects the required objects.

  • Dependencies are not defined by the number of modules but the number of times each module depends on another module

  • Manage dependency lifecycle

  • Allow for dependencies to be intercepted

links

  • https://www.techyourchance.com/dependency-injection-myths-debunked/

  • http://www.bryancook.net/2011/08/on-dependency-injection-and-violating.html

  • https://dzone.com/articles/about-dependency-injection

  • https://completedeveloperpodcast.com/episode-185/

  • goolge talk https://www.youtube.com/watch?v=o-ins1nvbDg&feature=youtu.be

  • https://developer.android.com/training/dependency-injection#kotlin

  • https://benjiweber.co.uk/blog/2014/09/13/frameworkless-dependency-injection/

Issues

  • can be over reliant on frameworks or libraries to do this for you

    • pollute code with framework (reduced separation of concerns)

  • Needs to start an app with DI at the beginning, otherwise it becomes harder later on

  • can add more complexity

Why

  • Improves maintainability

  • that reduces coupling and promotes the open-closed principle.

  • provides references to objects that the class depends on, instead of allowing the class to gather the dependencies itself.

  • it is about knowing as little as possible.

    • SRP

  • allows classes to “not know” how their dependencies are assembled, where they come from, or what actual implementations are fulfilling their contracts.

  • not using the “new” keyword in your classes and demanding instances of your dependencies to be provided to your class by its clients.

  • reduces local complexity of the class and makes it dumber, which is a good thing.

  • Without knowing who the provider of the contract is or how to get an instance of it, our class can focus on its single responsibility

  • reduce coupling

  • requires less understanding of the rest of the system to modify and unit test the class

  • By removing the assembly code from your classes, you make them more independent, reusable, and testable.

  • Dependency inversion relies on this idea

Relevant for late binding

  • late binding = ability to replace parts of an app with recompiling code

    • ie third party addons, or support different runtime env

  • Can change the implementation of different database/algorithm, depending on env/settings/configuration/inputs

  • This allows the decision to decide on what service to use as late as possible, to defer the choice

    • then can use one service, but not tied to it, so can easily swap it out for another service with minimal changes

Relevant for unit testing

  • Allows you to swap out injected dependencies with ones that can be controlled to setup situations for different test cases

Type of Abstract factories

  • Methods that create objects of certain kind

  • DI is not a service locator, or a service to call to get dependencies

  • DI is a way to structure code so that you never have to imperatively ask for Dep

Does not require a DI Container

  • A DI container aim is to make it easier compose classes and wire up an application

    • it might add unnecessary overhead for it to be worth using

    • it is an optional tool to implemetn DI

  • Using DI without a container library is called PURE DI

  • Pure DI allows you implement DI without compromises

    • might take a more work

    • easier to follow

Intercept dependencies

  • With DI, can intercept each dependency instance and act on it before it is passed to the consumer

  • Decorating

  • Allows for cross cutting concerns to be applied outside of the consumer

Seams

  • Is a place where an application is assembled from it's constituent parts

  • Where you can disassemble the application and work with the modules in isolation

  • Use of interface, so that class relies on the interface rather than implementation

  • allows you to handle volatile dependencies

Managing volatile dependencies

  • dep that change or can change should be injected

  • Stable dependencies dont need to be injected

    • Might be useful testability or other reasons

Stable Dependencies

  • Criteria

    • The class/module already exists

    • expectation that new versions won't contain breaking changes

    • The types in question contain deterministic algorithms

    • never expect to have to do the following with another class

      • replace

      • wrap

      • decorate

      • intercept the class/module

    • specialised libraries that encapsulate algorithms relevant to your app

  • stable if they are not volatile

Volatile Dependencies

  • Dependencies that don't provide a sufficient foundation for apps

  • You introduce seams in your code to inject volatile dependencies

  • Criteria

    • The dep introduces a requirement to set up and configure a runtime env for an app

      • ie databases, out of process resources like message queues, webservices, filesystems

      • leads to lack of late binding, extensibility, testing

    • The dep does not yet exist or is still in development

    • The dep isn't installed on all machines in the dev organisation

      • ie paid for 3rd party libraries, dep that cannot be installed on all OS

      • leads to disabled testability

    • The dep contains non deterministic behaviour

      • ie randomness, time/date

      • leads to hard to control behaiour for testing

DI Scope

  • As the class has no control of managing it's dep in DI, it has no control of the lifetime (when it goes out of scope, when it is created/reused) of the object injected

    • Does not know when it is created or goes out of scope

    • This simplifies the consumer

  • Thus the composition root can control the lifecycle of a dependency/objects/instances

  • Depending on your language you dont have to worry about the object scope, as this is handled by garbage collector

    • When no class references the dependency it is eligible for garbage collection

  • In application, multiple consumers might use the same dependency

    • You can either inject a separate instance into each consumer

    • or you can choose to share a single instance across multiple consumers

Intercepting Dependencies

  • DI allows the power to modify dependencies before passing them on to the consumer

  • Form of decorator pattern

  • This is related to AOP (aspect oriented programming)

  • can apply logging, auditing, access control, validation etc, to maintain separation of control

Composition Root

  • Describes where and how you should compose an application's object graphs

    • where the object graphs performs the actual work of the app

  • it is a single logical location

  • Object graphs are composed as close as possible to the application's entry point

    • especially for loosely coupled classes

  • This can be

    • Main method

    • it can span multiple classes and then called in main method or via DI container

  • Using constructor injection, pushes the responsibility for the creation of their dependencies up to the consumer, which also pushes the consumer's dep to their consumers.

  • Should be the only place where you use a DI container

    • Otherwise leads to service locator pattern (anit pattern)

  • composition root should be in one module

  • It is not part of the UI layer

How it works

  • Acts as a third party that connects consumers with their services

  • Deferring the decision on how to connect the classes the more options you have

  • They are not reused

  • All classes should use constructor injection (possibly others for good reasons)

    • this allows CR to decide how to compose the objects

  • Should be only place that knows the structure of the object graphs

    • centralises the knowledge

    • avoids application code passing on dependencies to other threads the run parallel to the current operation

      • as the consumer has no way of knowing if it is safe to do so

    • It is up to CR to create the object graph for each concurrent operation

  • The CR relies on config/setting/property files

    • increases flexibility

    • Should separate the loading of the config files to values, from the methods that does the object composition

Avoid

  • Dont create the object graphs in many different locations

  • This limits you from intercepting the object graphs to modify their behaviour (ie for testing replace a db with map)

  • It is not part of the UI layer, although it is easiest to create composition root here

    • can take out the layer as module, but might be tricky

DI containers

  • software library that can automate many tasks for composing objects and managing lifetimes

  • should only be used to compose object graphs

  • Only be in the composition root

    • CR should have reference to DI container

    • DICon should not be referenced by any other module

  • removal of any coupling between the DI container and app code base

  • For request based applicatoins (websites/services)

    • you configure the container once, but resolve an object graph for each incoming request

Constructor Injection

  • allows a class to statically declare its required dependencies

  • To guarantee a necessary volatile dependency is always available to the class, by requiring all callers to supply this dependency as a parameter to the class's constructor

  • pass the dependencies of a class to its constructor as parameters, thus store the reference for future use

  • The composition root will supply these dependencies, by instantiating them and injecting them

  • Should be default choice for DI

How it works

  • The class that needs the dep, needs to expose a constructor

    • This can also be done via static factory method

  • The dependency passed in to constructor should be assigned to a field

    • This allows the field (dep) to be used anywhere in the class

    • Generally, the field will be of an abstract type (depends on the patterns used)

  • The field holding the dependency should be read only (no setters)

    • Thus after object instantiation, the dependency cannot be modified

  • There should be no other logic in the constructor (see below exception for validation)

  • Dep injected into a class are few, but the depth of the object graphs might be long/deeper, due to the multiple layers of decorators

    • Have large parameter lists for constructors, can have an adverse effect on performance

Benefits

  • Clearly documents what the class requires via it's constructor parameters

  • Makes sure the class cannot create an object if it has not been passed a dependency that it needs to function

    • injection guaranteed

Bad

  • Some frameworks need to break this implementation to work

  • Some frameworks may need you to have a parameterless constructor (hibernate, ant)

    • leading to more work and configuration to setup properly

Multiple constructors

  • There are patterns which allow a class to have multiple constructors (Via telescoping) that allows defaults

    • This can allow a class to have constructors with more or less parameters than previous constructor

    • These can be helpful, especially in refactoring a class for testing

    • This can lead to ambiguity in terms of which constructor should be called or DI Con should use

  • Alternatively, can have one constructor, and have multiple explicitly named static factories which call the constructor

  • For application constructors having one constructor is preference, while in libraries having multiple is preferred

Optional dependencies

  • This can be a consequence of having multiple constructors

  • They can complicate checks for null arguments

  • Give greater flexibility in constructing a specific object

  • Best to use the builder or factory patterns

  • Can maintain a single constructor, but the composition root can inject a null object which has no behaviour

    • but code that uses this dependency must be careful of it's usage if it relies on a return type (output)

Validating constructor arguments

  • This is doing guard clauses to make sure that args are correct before constructing the object

    • So that when the dep is used elsewhere in the class no issues with null pointer

  • Two camps, one saying constructors should just be purely for assigning the reference for the dependecy to the class, and others saying should assign validation

  • I believe they should be pure with no validation, and create static factories that will do the validation before instantiating the object

    • Not all classes should need validation, only those at the edge of the system, or can be constructed at runtime (without the coders knowledge - but for to reduce failure might better to have default dependency instead of throwing an exception)

    • This might lead to issues with DI Con frameworks from not easily using it, with extra work to create (ie @bean and @configuration in Sprin)

Setter/Method Injection

  • Enables you to provide a dependency to a consumer when either the dependency or the consumer might change for each operation

    • Dependency can vary with each method call

    • Consumer of such dependency can vary on each call

  • dependencies are instantiated after the class is created.

  • Dep supplied with method parameter

  • Done outside of composition root

Good

  • Allows caller to provide operation specific context or service

  • Allows inject dep into data centric objects that are not created inside composition root

Bad

  • limited applicability

  • causes the dep to become part of the public api of a class or it's abstraction

When

  • Creating entities (DDD)

    • due to entities possibly containing lots of methods, these will require only certain dependencies

    • yes, can inject all dep via constructor, but not all will be used within each method

      • which complicates testing

Avoid

  • Dont store the dependnecy when passed in via method args

    • leads to temporal coupling, captive dependencies, hidden side effects

    • just use it or pass it on

Field/Property Injection

  • By exposing a writable property/field, that lets the caller supply a dep, if they want to override the default (one created in constructor)

  • having a public non final field, where you can inject the dependencies

  • dependencies are instantiated after the class is created

Good

  • Allow for class to be extensible

Issues

  • NPE

    • object created may have null fields, as they dont need to be assigned when object is instantiated

    • CURE: Have a default at constructor time

  • Causes temporal coupling

    • lead to inconsistent behaviour

  • Hard to impl in robust manner

  • https://www.vojtechruzicka.com/field-dependency-injection-considered-harmful/

when

  • when you have a good local default but want to extend by allowing users to provide diff impl

  • only applicable to resuable libraries

    • allows components to define sensible defaults

  • Dont use for applications

Issues with injecting too many dependencies

  • Some times having too many dependencies injected, can make the code more complex (esp for testing)

  • Things like crosscutting concerns (logging, date etc) can pollute the class.

    • Instead try using a factory, which can pass a supplier to a static factory method, and when the method of dependency is called, can call the supplier and instantiate it. Then the supplier is passed in at composition root, or a stub/fake is passed in for tests

  • https://enterprisecraftsmanship.com/posts/singleton-vs-dependency-injection/

DI anti patterns

Service locator

Control freak

Ambient Context

Constrained Constructor

Code smells

constructor over injection

abstract factories abuse

cyclic dependencies

Object lifetime

Singleton

Transient

Scoped

interception

Decorator

cross cutting

Last updated 1 year ago

Was this helpful?

  1. General Paradigms
  2. Patterns

Dependency Injections

PreviousDependency Injection ContainersNextDouble Dispatch
  • What
  • links
  • Issues
  • Why
  • Relevant for late binding
  • Relevant for unit testing
  • Type of Abstract factories
  • Does not require a DI Container
  • Intercept dependencies
  • Seams
  • Managing volatile dependencies
  • DI Scope
  • Intercepting Dependencies
  • Composition Root
  • How it works
  • Avoid
  • DI containers
  • Constructor Injection
  • How it works
  • Benefits
  • Bad
  • Multiple constructors
  • Validating constructor arguments
  • Setter/Method Injection
  • Good
  • Bad
  • When
  • Avoid
  • Field/Property Injection
  • Good
  • Issues
  • when
  • Issues with injecting too many dependencies
  • DI anti patterns
  • Service locator
  • Control freak
  • Ambient Context
  • Constrained Constructor
  • Code smells
  • constructor over injection
  • abstract factories abuse
  • cyclic dependencies
  • Object lifetime
  • Singleton
  • Transient
  • Scoped
  • interception
  • Decorator
  • cross cutting