Image for post
Image for post

When it comes to how we view the world, most of us fall into one of the two types: Optimistic or Pessimistic. Whether you are one or the other, scientists said it has to do with our upbringing and culture. There are both pros and cons in viewing the world one or another.

An optimistic view of things makes one willing to try new things. Usually, optimistic thinking equals positive thinking. If you are confident and hopeful that the project you initiate will have a brighter future, you will be more likely to start that project. …


Image for post
Image for post
Originally published at https://edward-huang.com

As the new year starts, I need to finish some stuff on last year’s task. One of the studies is to finish reading Steven Pressfield, The War Of Art, a must-read book for anyone trying to fight with their inner resistance.

One of the key concepts in the book is working hierarchically vs. territorially. It is such great insights for changing our way of thinking towards the work we do that I would like to share in this article.

“In the animal kingdom, individuals define themselves in one of two ways — by their rank with hierarchy (a hen in a pecking order, a wolf pack) or by their connection to a territory (a home base, a hunting ground, a turf). This is how individuals — humans, as well as animals — achieve psychological security. They know where they stand. …


Image for post
Image for post
Originally published at https://edward-huang.com.

Data structure helps us store values within our data and help us efficiently do the operation with those data if we need them. For instance, if we want to store 1-dimensional data points, natural numbers that you will plot in a single line or a string, we can use a 1D array to store these data. To create a fast retrieval (search), we will use a natural order indexing (1 < 2 < 3) or using a data structure like Trie or Binary Tree.

What if we want to work with the 2D space and store our data to do a fast retrieval? What if we’re going to find proximity ordering, such as find all the nearby points that are close to this point? …


Image for post
Image for post

Have you ever wonder how you can implement getUUID? We often set random IDs for making an entry in a table. The most common way is to create a UUID.randomUUID. However, many programming languages and cloud infrastructure have provided us with UUID that sometimes we took the function for granted.

What is a globally unique identifier?

A globally unique identifier is a function that will generate a different output each time you call that function. It will not create the same function on the same machine, another machine, or even your lifetime. It needs to be unique.

In this article, I would like to walk through the thought process of creating an incrementing globally unique identifier. …


A look at strategies when thinking about distributed systems and microservices

Example of microservice architecture
Example of microservice architecture
Photo by the author.

Microservice architecture can help teams develop applications asynchronously. Teams can deploy their code base, creating a faster iteration and development process overall. However, with flexibility, there also comes complexity in developing distributed systems. Many of our assumptions in a single system don’t work in a distributed system, and we need to reevaluate how we approach our design in distributed systems.

One example of this is time ordering. I recently wondered how you can ensure the services you created are in the right order.

Imagine you created an event-driven architecture with two microservices: a Product service and Order service.

The Product service will be responsible for managing products, and Order services are reliable for managing orders. The Product service can emit a CreateEvent and UpdateEvent, and based on the event, the Order service consumes the messages through a queue and updates its local data store. …


Image for post
Image for post
Originally published at https://edward-huang.com.

When developing an application, it is often useful to have some state in the application to detect the current point at which the program is executed. Often, we want to operate in sequential data streams, such as the parser, firewalls, communication protocol, or a stream of data. In some of these operations, the previously computed data is stored in some variable (State) and will often influence the program’s current execution decisions.

We can call these operations a stateful operation, where the program’s previous execution is carried over to the current implementation. …


Image for post
Image for post

Applications are often design with a throttling mechanism involved. Sometimes, we want to limit the number of requests to improve our application’s security and performance. Sometimes your application cannot respond to more than a certain number of connections. For instance, if you polled the message as fast as your can from a queue and did not limit the number of connection, your application will soon exhaust its connection fool and face Denial of Service error. …


Image for post
Image for post

Last week, I tried to investigate raw data from Dead Letter Queue (DLQ) at work. One of the functionalities that I want to do is poll sources from the SQS DLQ and write those data in a file for further investigation. I thought using FS2 will be a great use-case for this.

FS2 is a light-weight streaming library that can help you do a lot of data processing functionality. Often, we want to get some data from upstream and write them to a file for any investigation.

I want to share how we can create a simple type class for writing data to a file system with FS2. …


Change your schedule

An assortment of clocks.
An assortment of clocks.
Photo by Lucian Alexe on Unsplash.

In a 2004 interview, famous novelist Haruki Murakami discussed his daily habit: He would wake up at 4 a.m. and work for five to six hours. Then, Murakami would go for a swim, listen to music for the rest of his day, and go to bed at around 9 p.m. He said that he would hold on to such repetition to keep up his artistic sensitivity. Another great writer, Ernest Hemingway, had a daily routine whereby he would write every morning from 6 a.m. to 12 p.m. because that was when no one disturbed him. …


Image for post
Image for post

In part one of this post, we talked about how Free Monad can build a monad from Functor. To do so, you can create a DSL like programs and generate another program. The program that you make becomes plain data structures that represent a domain logic. Once you composed the program, you can connect those programs with an interpreter. You can switch a different interpreter on dev and QA. You can also abstract out the implementation of your program or optimize them without changing your domain logic.

We started by creating a Todo application with these algebras:

First, we created an algebra FlatMap and Pure and introduce what it's like to make a monad like programs by wrapping our Todo algebras into the "Free" data…

About

Edward Huang

Sharing my notes and document my journey in learning FP and Careers | https://www.edward-huang.com/

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