What is the convention when I have dependencies which are optional, like for example logging ? I want to have them injected by properties. And what after when nobody set it? Check for null every time ? Or get a fake logger which does nothing ? 1.The problem is not related only for logging. 2. I am asking for convention when injecting via properties.
What is the convention for optional dependency injection via properties?
1.3k views Asked by MistyK At
1
There are 1 answers
Related Questions in C#
- How to call a C language function from x86 assembly code?
- What does: "char *argv[]" mean?
- User input sanitization program, which takes a specific amount of arguments and passes the execution to a bash script
- How to crop a BMP image in half using C
- How can I get the difference in minutes between two dates and hours?
- Why will this code compile although it defines two variables with the same name?
- Compiling eBPF program in Docker fails due to missing '__u64' type
- Why can't I use the file pointer after the first read attempt fails?
- #include Header files in C with definition too
- OpenCV2 on CLion
- What is causing the store latency in this program?
- How to refer to the filepath of test data in test sourcecode?
- 9 Digit Addresses in Hexadecimal System in MacOS
- My server TCP doesn't receive messages from the client in C
- Printing the characters obtained from the array s using printf?
Related Questions in DESIGN-PATTERNS
- Will it slow down the performance when Unit of work pattern is used with EF Core
- Design patterns - How Design patterns work with bulk data
- Using Repository pattern to fetch data from different places and build list of objects
- Suggest best design patterns to update or insert bulk data
- Mapping one collection of objects into another collection of objects
- How can I break down a large presenter in the Viper design pattern into smaller pieces?
- How to create under the label in Textformfield, not a border, in Flutter
- Own Pattern / framework for interfacing with components in C
- Common Method Implementation for Elasticsearch and OpenSearch Java SDK
- How can I decouple them?
- Understanding Potential Deadlock in Resource Pool Implementation Described in "Go in Action"
- Dependency Injection Patterns stand alone implementaion
- How to use GoF design pattern for software robustness?
- Pipeline data processing and code architecture
- Mocking inherited class where new object is created or how to unsmell my class
Related Questions in DEPENDENCIES
- I have hundreds of dependencies on my package.json file which I didn't install (npm and using Warp)
- Nest.js can't resolve dependencies of the external library's Reflector dependency
- c++ python ctypes dependency issues
- Why rebuild module does not recompile dependency module, but build module does in IntelliJ Idea?
- I need help to upgrade deprecated dependencies in an ASP.NET Core 8 Web API project
- libstdc++ dependency mismatch for applications
- Use Google Font Without Network Connection
- IServiceCollectionConfigurator' does not contain a definition for 'UsingRabbitMq'
- Understanding Modules, Dependencies, Libraries & Packages
- `go mod graph` doesn't seem to provide the full graph
- java.lang.NoSuchMethodError: org.glassfish.jersey.message.internal.HeaderUtils.createInbound()Ljakarta/ws/rs/core/AbstractMultivaluedMap;
- "Unable to generate SAFESEH image." but disabling SAFESEH breaks dependency links
- When or what makes gcc add dependencies?
- How can I change a dependencies for an installed Gem
- Java Maven Cannot Find Symbol on compile, but runs ok on debug
Related Questions in CODE-INJECTION
- How can I disable JVM bytecode verification at runtime?
- Component inheritance and sharing of elements in Angular with dynamic template
- VSCode Extension - Grammar Injection Into Multiple Languages
- Toastr implementation in Angular17 at standalone components
- Inject own Logic into existing Quakus Extension
- Cannot wait until the entire DOM is loaded with Scripty Chrome extension
- .NET MAUI 8: System.Reflection.TargetInvocationException on initializing the main view with dependency injection
- SegmentationFault of sprintf in CSAPP Attack Lab
- Checkmarx vulnerability - if embeds untrusted data
- chrome extension to inject javascripts (one or more) on a webpage
- Determining the end of output and readiness for input of the сonsole process in C#
- Possible Injection Risk on Azure Synapse Spark when using certain key words in strings in where or join clauses
- Issue with CreateRemoteThread causing target process crash
- Injecting JS to script tag inside HTML
- JavaEE - Strategy Pattern - Error while injecting Lambda
Related Questions in CONVENTION
- Where to put import statements in a jupyter notebook
- A getter method that doesn't necessarily get a member's value?
- The use of brackets in VIM help pages
- How can I define a file naming convention of incoming files in Spark
- Closing braces with Python
- What is the canonical name for a function that ensures that an asynchronous task takes at least x time to resolve?
- Automapper - Map fails after profile is added
- ViewModel method name convention
- Correct Way To Load An Alternate Version Of jQuery For IE8 And Below
- A lot of named arguments vs. **kwargs
- Project structure for class inheritance in Python
- Where to put single util methods that only serve a single purpose? (Java)
- Kotlin Data Class packaging
- How to name variable correctly to avoid warning like "Shadows name from outer scope" in Python
- Bad practise to catch IllegalStateException? Alternatives?
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Property injection is typically used when you can generally rely on a default implementation but want the option of injecting an alternative.
In your example, you might create a DefaultLogger that the class uses unless someone passes in an alternative via a property.
I think there should always be an instance of something, a 'null object' maybe. Checking for null doesn't feel right.
Also, have you considered decoration? Logging is a great example of how decoration can add extra, optional, features.