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 best solutions below
Related Questions in C#
- Passing arguments to main in C using Eclipse
- kernel module does not print packet info
- error C2016 (C requires that a struct or union has at least one member) and structs typedefs
- Drawing with ncurses, sockets and fork
- How to catch delay-import dll errors (missing dll or symbol) in MinGW(-w64)?
- Configured TTL for A record(s) backing CNAME records
- Allocating memory for pointers inside structures in functions
- Finding articulation point of undirected graph by DFS
- C first fgets() is being skipped while the second runs
- C std library don't appear to be linked in object file
- gcc static library compilation
- How to do a case-insensitive string comparison?
- C programming: Create and write 2D array of files as function
- How to read a file then store to array and then print?
- Function timeouts in C and thread
Related Questions in DESIGN-PATTERNS
- Pass Data between two view controllers using 'Delegation' : Objective-C
- Revealing module pattern instantiation and naming convention
- Is using the same Redis instance for different applications against Separation of Concerns principle?
- Swift - Issue trying to access to Singleton object
- How to set data context of ViewModela View's xaml?
- How to use nested builder pattern in json?
- Is object casting a good practice?
- reference data class member visitor pattern
- variable global const "macros" in C++ and optimal design patterns
- How to design abstract listener and its implementation?
- DTOs with different granularity
- Object creation depending on caller
- What is the proper way to use inheritance when combined with factory method?
- Is this Java Enumeration Used/Designed Correctly?
- Design pattern for incremental code
Related Questions in DEPENDENCIES
- r package development imports not loaded
- building api only artifact with maven
- How to mock specific RequireJs dependencies while unit testing
- Am I using puppet contain correctly?
- GNU make - depend only on file existence and not modification time
- How to specify dependencies in aar library?
- Gradle project dependency does not reference SNAPSHOT jar
- PL SQL Find Dependencies on Table Field
- GNU make - making one task do another task as well
- How to know the dependencies of an application in kibana 4?
- E: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages
- Gradle - inherit repositories from a module
- Can't install devtools in RStudio -- Dependencies not found (xml2/rversions)
- Gradle: How do I include ivy artifacts by pattern?
- Bitbake runtime vs build dependency
Related Questions in CODE-INJECTION
- Allow extension of class by injection of user-made subclass, while preserving accessibility
- C++ Injection Code
- Java EE using Datasource without lookup method
- Java polymorphism through injection at runtime
- Is FILTER_VALIDATE_EMAIL sufficient to stop shell injection?
- Protecting against user injection, running imagemagik from through command line
- How to inject a logging statement before every catch block in java
- Worried about html/script injection in angular app
- IHTMLDOMNode::appendChid() won't always work as expected
- Angular - function in dependency or dependency in function params?
- Android runtime code injection / method hooking with Java Reflection
- How can I inject or dynamically load an c function into another c program
- Access document object in my contentScriptInjection in js
- Command Injection DVWA Hard Difficulty
- auto js injected in js files [ default/base.js ] using Moblink 3G
Related Questions in CONVENTION
- Passive Objects in C++
- Rails indentation convention
- What is the naming convention for CMake scripts?
- Is it proper convention to just name a GitHub remote `github`?
- Java naming convention for a class with version in its name?
- Google JS Coding Conventions - "The var keyword must not be used"
- Microsoft's Consistency in PowerShell CmdLet Parameter Naming
- What is the difference between [ ] and ( ) brackets in Racket (lisp programming language)?
- Is there any convention for methods 'converting' an object into another? (toX, fromY)
- Best way of creating dynamic conditions in sql functions
- Alternative for checkstyle
- How to avoid creating objects to check or get content from Maps in Java
- Including file known to already be included
- Calling an overridable method in constructor is bad. Are there exceptions?
- What is the convention for optional dependency injection via properties?
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)
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?
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.