0%

What is a transaction and why distributed?

A transaction is a sequence of operations that are performed as a single unit of work. The main goal of a transaction is to ensure that the data remains consistent and reliable, even in the face of failures or errors.

Achieving scalability and availability requires distributed systems. Also, to guarantee atomicity in global transactions across components.

There are two kinds of structures in distributed transactions:

Read more »

Asynchronous messaging is that sender does not expect an immediate response and does not “blocks” waiting for the response. He will carry out his remaining tasks.

This article will introduce common patterns and compare 3 popular technologies for asynchronous messaging.

Asynchronous messaging patterns

There are two basic patterns in asynchronous messaging (and more variants):

  1. Message queue Using queue as a message broker. One message can only be consume by a consumer. Unconsumed messages will be stored in queue until timeout.
Read more »

The common language runtime (CLR) provides an automatic memory manager, which is the garbage collector (GC).
Unlike languages like C and C++, developers need to manually handle memory allocation, the GC manages the allocation and deallocation of memory for objects in a .NET application to simplify development, reduce memory leaks, and improve overall code safety.

Read more »

Key Expiration

Redis allows to set an expiration time for keys using the EXPIRE command or by providing a TTL (Time-to-Live) value when setting the key.
This feature is beneficial for managing data expiration and automatic cleanup, saving storage space, and improving performance.
Also, there is some data only valid for a period of time, i.e. verify code, login token, etc.

Redis has another dictionary(hashtable) for saving expiration time of keys, which stores unix timestamps in milliseconds (long long data type).

Read more »

There are various HTTP methods. Every of them has its own semantics.
Which means each method has been defined what it should do.

Designing APIs that following semantics is important since semantics of methods has been defined in HTTP/1.1 specification.
Almost all browsers, APIs, apps, tools, and other developments are based on this consensus.
So not following it may cause issues in most scenarios.

Read more »

Reverse Polish Notation

Reverse Polish Notation (RPN) also called postfix notation.
Which which operators follow their operands and does not need any parentheses.
For example, 3 * (10 + 5) in RPN is 3 10 5 + * as above.

How do we write an evaluate function?

Read more »

Traversal means to go through all node on tree.

The most intuitive way in my mind is level-order way:
Print all node on root level from left to right, and then its child level, and so on.
Level order of example graph is 0 1 2 3 4 5 6 7 8.

But how about depth-first way?
There are 3 actions when we move on a tree node:

Read more »

Representational State Transfer (REST) architectural style has been first presented in 2000 in dissertation Architectural Styles and the Design of Network-based Software Architectures by Roy Fielding.
Which introduced and elaborated the REST architectural style for distributed hypermedia systems.
He is also one of the principal authors of HTTP/1.1 specification.

Read more »

As a programmer, we can see a lot of try-catch patterns in the legacy code.

But sometimes exception messages cannot precisely point out where the error occured.

And this is how C# Exception behaves.

Read more »