A look at field injection and constructor injection

Serum
Serum
Photo by Kelly Sikkema on Unsplash.

Spring is a very popular framework in the world of Java, and one of the reasons behind its popularity and high usage rate is its dependency injection mechanism.

Kotlin, on the other hand, is a JVM language created by the team at JetBrains that is considered to be the modern version of Java alongside Scala, for example.

How good would it be to use a modern language with the solid, robust, and time-tested Spring framework?

Fortunately, in January 2017, it was announced that Spring version 5.0 will provide support for Kotlin. So, starting from Spring Boot version 2.x, Kotlin will have their first-class support. …


Using embeddedKafka and JUnit5

a stack of newspapers filed upright
a stack of newspapers filed upright
Photo by AbsolutVision on Unsplash

Introduction

Recently, I wrote a comprehensive tutorial on how to build an event-driven application with Kafka and DynamoDB. The tutorial covers the end-to-end of building a working application which exposes 2 x endpoints:

  • 1 x POST endpoint to receive a request to create a new user
  • 1 x GET endpoint to return a user information

The POST endpoint publishes a message containing a user creation request from the client to a Kafka topic. There’s a Kafka listener pipeline that subscribes to this topic, consumes the messages, and, finally, persists the new user information in a DynamoDB table. …


Renaming branches, overwriting Git history, and creating feature branches

USB stick connected to a laptop
USB stick connected to a laptop
Photo by Brina Blum on Unsplash.

As developers, most of us spend a fair amount of time on Git to manage our version control. We also use Git to collaborate with other developers to track bug fixes, build new features, refactor codes, and many more things.

In this tutorial, I am going to share with you three common scenarios that you will face or have encountered previously and how to deal with them.

Rename Existing Branch

I don’t know about you, but where I work, I do my development based on Jira tickets. What this means is all my pull requests will have their corresponding branches named as per the respective ticket number. This is also true for the first commit of the pull request (i.e. it starts with the ticket number followed by the commit message). …


DynamoDB enhanced with Kotlin

landscape consisting of forest with water in the front and a cloudy sky behind
landscape consisting of forest with water in the front and a cloudy sky behind
Photo by Lucas Campoi on Unsplash

Introduction

If you have been using the AWS Java SDK for DynamoDB since its version 1, you will have implemented or come across the DynamoDBMapper class. This class allows us to define the relationship or mapping between the actual items in the DynamoDB table and the Java POJO classes in our application.

In other words, the AWS Java SDK takes care of or abstracts out the low-level operations, i.e., constructing the relevant DynamoDB expression for the corresponding CRUD operations. This is very convenient for us when we write our application code.

To cut the story short, here comes the AWS Java SDK version 2. It is a major rewrite of version 1. The initial releases did not have the DynamoDB abstraction as provided by the DynamoDBMapper class from version 1. What this means is that we need to handle the low-level operations, i.e., constructing attribute values and the Java POJO class objects. …


Image for post
Image for post
Photo by Slidebean on Unsplash

Empty meeting room at the office? Well, that is most likely how meeting rooms all over the world look like during this unprecedented time of COVID-19. Almost all organisations, if not all, are working remotely and meetings are conducted via online conferencing software, such as Zoom, Google Hangouts and Microsoft Teams.

Challenge

This is also the case for my company and my Church’s bible study organisation. In the case of my bible study activities, we usually would take attendance. When it was done in person, it was easy as we were broken up to a few classes. …


Exception handling in Python is done by using the try except clause

Image for post
Image for post
Photo by Hitesh Choudhary on Unsplash

Introduction

In this tutorial, we will learn how to handle exceptions in Python by using the try except clause.

But first, what is an exception? 🤔

An exception is an error that is thrown by our code when the execution of the code results in an unexpected outcome. Normally, an exception will have an error type and an error message. Some examples are as follows.

ZeroDivisionError: division by zero
TypeError: must be str, not int

ZeroDivisionError and TypeError are the error type and the text that comes after the colon is the error message. …


Image for post
Image for post
Photo by Jason Leung on Unsplash

Overview

String is one of the basic type in any programming languages, including Kotlin. I have never seen any application or program that does not deal with String. Have you ever? 🤔

That’s why I thought we should spend some time looking at the fundamentals of String. In this tutorial, we will learn the basics of String in the Kotlin programming language.

Initialise a String Object

Let’s start by learning how to initialise a String object. To initialise a String object, simply wraps your expression with double quotes ".

val myString = "This is my first String object"
myString::class
println(myString)// val myString: String
// class kotlin.String …


Image for post
Image for post
Photo by Emma Matthews Digital Content Production on Unsplash

The Properties of Python List

In Python, one of the most used data structures is list. A list in Python is basically an ordered collection that can hold a number of items or objects. Just think about a to-do list, which basically just contains the list of things for us to do.

List initialisation

There are 2 ways to initialise a list object.

demo_one = list([1, 2, 3, 4, 5])
print(demo_one) # [1, 2, 3, 4, 5]
demo_two = [1, 2, 3, 4, 5]
print(demo_two) # [1, 2, 3, 4, 5]

Alternatively, if you don’t already know what are the items the list will store, you can also initialise an empty list like so. …


When your if-else statements get too long, it’s time to consider pattern matching.

Image for post
Image for post
Photo by Andrew Ridley on Unsplash

Overview

Pattern matching is one of the most powerful tools that the Scala language has to offer. It is similar to when statement in Kotlin and switch statement in Java.

Essentially, it compares an input with all the possible cases we want to match it with. In my opinion, it’s an elegant alternative to using multiple lines of if-else statements and it’s more readable when there are many cases to compare against.

In this tutorial, we are going to learn how to use pattern matching in Scala by looking at a few different scenarios.

For those who are interested in Kotlin’s when statement, you can go to this tutorial. …


Image for post
Image for post
Photo by Andy Kelly on Unsplash

Overview

In the past two tutorials on Google Drive API with Python, we have covered how to obtain credentials here and search for a specific file in Google Drive by its name here.

In this tutorial, we are going to learn how to download a specific Sheet by name from a Google Spreadsheet into a csv file. A use case for this: you need to generate a report, which data are stored in a Google Spreadsheet that has many Sheets, but you only need one or two of them. …

About

billydharmawan

A passionate Software Engineer trying to leave a good legacy on earth

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store