Posts with the tag design:

Function Types in Go

A while ago, I saw a question in a Go developer Slack channel that went something like this (translated): When would you want to define a function type like type MyFunc func(msg string) error? Do you have any examples? I replied with a http.HandlerFunc example (more on that below), but there were many developers smarter than me in that Slack channel, and I ended up learning a lot from the other answers to this question.

Feature-oriented package structures and the default access modifier

In Java we have 4 access modifiers that can be applied to methods and fields of a class. In descending order of visibility, they are: public String publicModifier = "Anyone can access me"; protected String protectedModifier = "Only accessible to classes in the same package as me, and my subclasses"; String defaultModifier = "Only accessible to classes in the same package as me"; private String privateModifier = "Only accessible within this class"; This article is a love letter to the third in this list of modifiers, the one-who-shall-not-be-named.

Spring Dependency Injection Patterns -- The good, the bad, and the ugly

Spring developers will be familiar with its powerful Dependency Injection API. It allows you to declare @Beans that Spring then instantiates and manages. Any dependencies between these beans is then resolved by Spring and injected automagically. Three Annotation-based Injection Patterns There are three ways Spring lets you declare the dependencies of your class using annotations: Field injection (The bad) import org.springframework.beans.factory.annotation.Autowired; public class MyBean { @Autowired private AnotherBean anotherBean; //Business logic.