Bitcoin is far from Enterprise Blockchain

While trying to apply Blockchain to enterprise applications, a common mistake is to draw analogy to Bitcoin. While Bitcoin is a Blockchain application, it is far away from enterprise Blockchain application.

Below are the major differences between Bitcoin and Enterprise...

Read More

Monolithic applications are not so bad actually

Monolithic applications have a lot of advantages over microservices ones. For example:

  • Strong reference check accross the whole system.
  • Tooling and compiler support for system wide refactoring
  • Easy debugging
  • Easy to trace through call chains to understand system behavior
  • ...
Read More

RabbitMQ Cheat Sheet


  • Queue: what you receive messages from
  • Exchange: what you send messages to
  • Binding: binds queues to exchanges
  • Routing Key:
    - binding routing key: routing key is associated with a Binding
    - message routing key:...
Read More

Understanding sql query execution

Understanding SQL Execution

  • SQL parsing: –> AST
  • Query optimization: cost based on statistics
  • Query execution: Tasks(requests) vs Workers(thread pool threads)
  • Execution Plan Caching and Reuse. EF Linq queries are by default cached. Impact on server memory foot...
Read More

Task, async, and await

Benefits of Asynchrony

  1. Unblocking the UI thread This only maters to WPF and WinForm applications but does not mean much for Asp.NET applications. Asp.NET applications are automatically multi-threaded. For details, please see Read More

Combining MVC, MVP and MVVM

There are often confusions about MVC, MVP and MVVM. These 3 patterns are all trying to address different concerns and do not have to be mutually exclusive. In a complex real world application, it is often beneficial to apply a...

Read More

IQueryable or IEnumerable

When implementing a data access layer against a database storage, one always has to choose from returning either an IEnumerable or an IQueryable collection. I’d say neither is a good choice. Instead, the following pattern should be applied. Neither IQueryable...

Read More

TPL, async, await guidelines

  1. When using await, always explicity specify ConfigAwait because:
  • It prevents potential deadlocks.
  • It reduces future maintance effort. It is always easier to decide wether the continuation code can be put to the thread pool thread when you...
Read More

关于WPF中px, pt, inch, DPI的笔记

网上有无数关于px, pt的搜索结果,这说明了关于这个题目的文档有多么难懂和误导。


##1. PX,PT,都是长度单位 把PX定义为“设备无关像素”真的是很误导,很容易让人想起设备,像素。其实与它与设备无关,也和像素无关。它就是一个长度单位。PX和PT都是长度单位。 1 PX = 1/96英寸, 1pt = 1/72英寸。

##2. DPI(每英寸点数)是一个系统设置 我们需要的DPI来把长度(以PX,PT表示)转换到物理像素。DPI表示1英寸应该转换为多少物理像素。它不是显示器的物理特性而是一个系统设置。对DPI设为96的系统,一1英寸的线(或96PX,72pt,2.54厘米线)会转换为96个物理像素。

##3. DPI同时也是显示器的物理特性 这一点非常迷惑人。 实际工作中DPI往往还被不加区别地用来描述显示器的物理属性。 DPI作为显示器物理属性表示像素密度。 在一个96DPI的显示器上,96个物理像素占据1个物理英寸。

##举例: 如果一个线段在WPF中被指定义为1 inch(或96PX,72pt,2.54cm),这表示逻辑上1英寸长。WPF画线的时候首先需要计算需要画多少个物理像素在显示器上。要做到这一点,WPF使用系统DPI设置。如果DPI设置为96,那么WPF会画96个像素到显示器上。这条线在显示器上实际显示有多长取决于显示器的DPI属性。在一个96 dpi的显示器上,96个像素的这条线就刚刚好有有1英寸长。

##结论: 定义一英寸长的线可以用:1 in, 2.54cm, 96px, 72pt. 用什么单位完全看个人爱好和方便程度。硬要说它们之间有含义不同只会误导。即使曾经有过不同那也是历史上的。WPF的功劳是把它们都归一成了长度。再强调不同有害无益。



Read More

Notes on px, pt, inch, and DPI in WPF

The fact that there are so many seach results on this topic tells how confusing the documents are.

Here are the points that I find misleading when reading the documents.

###1. px, pt, in and cm are all length units....

Read More