$ ❯ CrowderSoup

A website about programming, technology, and life.

Programming

Day 10: Dependency Injection

by Aaron Crowder on in Programming

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.

Read more...

Debugging PowerShell in VSCode

by Aaron Crowder on in Programming Tools

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.

Read more...

Anatomy of a Commit Message

by Aaron Crowder on in Programming

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!

Read more...