Posts

Showing posts from February, 2017

Spring DI with different styles

Spring as a dependency injection (DI) framework allows us to define our application components' dependency tree in three different ways: XML Annotation Java Config I've written a simple app, bookstore, with the three styles and they're available in the following repository. You can take a look and see how each style would look like. It also has a version that uses no Spring beans for comparison. https://github.com/ryu1kn/spring--working-with-beans Different styles have different pros/cons. Spring lets you mix the styles; so you can change it as you go. Here is my observations on each style. XML-based configuration Pros Weak/loose coupling with Spring framework in your app code. Good for keeping the option of removing Spring later Class dependency information is centralised. Fine-grained control on the dependency definition. Changing only the dependency information doesn't require the recompilation of your app code. Cons Unless you have a good IDE ...

Terraform

Organise your infrastructure with terraform How to create reusable infrastructure with Terraform modules How to manage Terraform state But HIL is somehow limited Support for nested maps in variables #2114 Type system to support list and map element types Intermediate variables (OR: add interpolation support to input variables) Use null_data_source Can't create an output map

Golang way

I want to convert a list of type T1 to a list of type T2. Do I convert its element one-by-one? Yes, simply iterate over the whole list. cf. Type converting slices of interfaces in go Does a Go project needs to be under GOPATH ? I wrote a tool in Go and want to check it into an exising repository, but don't want to put the repo under GOPATH as it's mostly written in non-Go languages Add an appropriate place to GOPATH every time you run go commands. GOPATH for a project written in several languages (for example Go and Python)? AWS SDK for Go exposes struct s but not many interface s hence hard to mock in unit tests. Define interfaces as you need and use AWS SDK through them. cf. Discussion: How should you unit test code which uses the aws-sdk-go Where is list manipulation functions like filter , map , reduce , ...? Use for loop. cf. Map, reduce and filter in Go? , Writing type parametric functions in Go Dereferencing a nil pointer doesn't cause an error...