What is it? Dependency Injection is a design pattern whereby an object/module’s dependencies are provided to it. It is one of several techniques for implementing Inversion of Control.
So rather than:
func NewClient() *Client { return &Client{ Service: service.NewService(), } } You would have:
func NewClient(service *service.Service) *Client { return &Client{ Service: service, } } Why tho?? If you wanted to write a test for the Client first example above, you wouldn’t be able to mock it’s Service.
Yesterday I learned a neat trick with Visual Studio Code when working on some PowerShell scripts to help orchestrate build and deployment of our projects (more on that in a different post). I knew that VSCode had a debugger, but I didn’t realize that a debugger for PowerShell had been added via an extension.
I had installed this extension some time ago to help with writing PowerShell scripts in VSCode, but I was running my PowerShell prompt in another window to actually test them.
A couple months ago I decided I needed to be better about telling my wonderful wife how much I loved her on a daily basis. Being the nerd that I am I decided to tackle this using IFTTT and a custom web app. For this project I went with Django to build my app out. I’d never used it before so I wanted a chance to play with it.
The idea The idea is pretty simple.
1. Subject Line The Subject Line is the first line of your commit message. Often the subject alone is enough, but if it’s not and you need a body be sure to separate the subject and body with a blank line.
First line of a commit message Often the only part you’ll need Separated from the body by a blank line Soft limit of 50 characters, hard limit of 69 Github’s interface truncates the subject line at 69 characters Capitalize!