Azure Communication Services (ACS) sponsored nwHack 2022 at The University of British Columbia. It was great to see the engagement from students to leverage open source API’s to solve daily problems. …
At the beginning of year 2021, my professional goal was to write bogs as well as to work on designing a software system. …
I do not know how the perfect software architectures are build. It is possible that perfect software designs are myth. …
This post demonstrates the Android chat application leveraging Azure Communication Services and ChatKit.
2021-06-20 No tag
Last week, I read an article “Harnessing the Power of Less” published in Special Times Edition “Secrets of Success”. The beautiful line “Stretching encourages adaptation and working with what you already have, rather than focusing on needing more” …
Kotlin supports Higher order functions. In this blog, I will create a higher order function that will use map & fold right for execution.
Before diving into higher order functions, let’s go through map & fold right.
map is collective transform operation.
var numbers = mutableListOf(1, 2, 3)
numbers = numbers.map { it*2 }.toMutableList()
// elements in numbers: 2,4,6
foldRight accept initial state, apply initial state to all elements and return final state.
var numbers = mutableListOf(1, 2, 3)
var result = numbers.foldRight(100, {a,b -> test(a,b)})
private fun test(a: Int, b: Any): Int {
return a + b as Int
}
/*
First execution: initial 100
a = 3
b = 100
Second Execution
a = 2
b = 103
Third Execution
a = 1
b = 105
final: result = 106
*/
Let’s create a higher order function Middleware that takes an instance StringApp, has inner function next: Type and return Type.
It is very connivent to use any DI framework when all the objects required are available in application. For example, I have two classes Logger, Service and class Middleware is dependent on these classes.
class Logger()
class Service()
//this class requires Logger & Service object
class Middleware(private val logger:Logger. private val service:Service)
// middleware object
val middleware = Middleware(Logger(),Service())
Dagger can build objects of Logger and Service classes by indicating @Inject annotation to all three classes
internal class Logger @Inject constructor()
internal class Service @Inject constructor()
//this class requires Logger & Service object
internal class Middleware @Inject constructor(private val logger:Logger.
Below are widely used Dependency Injection frameworks mostly by android & Java application projects.
For Android application development, the suggested Framework by Google are Dagger and Hilt. These frameworks help to avoid writing boilerplate code.
Guice Guice (pronounced ‘juice’) is a lightweight dependency injection framework for Java 6 and above, brought to you by Google. (github.com)
With 10K stars this framework is mostly used by Java developers where Java is used for backend & Application development.
For Android, this framework is not suggested as this framework use reflections to scan annotations from code. This requires significant CPU cycles and RAM thus slowdowns application launch.
Redis is in-memory data structure store. Redis has a really good documentation to learn and implement framework capabilities.
My mentor at Job guided me to learn Redis. My primary focus is to understand how Redis helps for Distributed Caching.
Distributed Caching Distributed Caching is cache shared by multiple servers. The miclsroservices or services can keep it’s own cache for data but distributed cache has many advantages as we can scale and manage cache at one place.
The caches are used to save time to reduce cost to read database from database. The in memory(RAM cache) data is much more efficient to perform read operations as compared to SQL databases.
Recently, I developed an Android application. The application was developed focusing on simplicity. The application was small thus skipped writing unit tests. I know skipping the unit tests is not a good practice.
In past, I was working on backend projects where tons of unit tests exists for API’s. I am new to application development and spent some time to learn about MVC and MVVM design patterns.
For next project, the preference is MVVM. At end of this post I will share the reason to choose MVVM.
The example code for this post is written for Android application.
MVC (Model-View-Controller) Model: Model is data layer.