Architecture Does NOT lie!

Attended an architecture overview meeting. When I looked at the architecture diagram, I recognized something familiar, and immediately understood their design intent even before we began to talk.

The something familiar was one flavor of design pattern Remote Proxy, which was used to [1]:

  1. Provide a surrogate or placeholder for another object to control access to it.
  2. Use an extra level of indirection to support distributed, controlled, or intelligent access.
  3. Add a wrapper and delegation to protect the real component from undue complexity.

So the architecture doesn’t lie. Design patterns and best practices, if used in proper context, convey the true design intent that fellow developers and architects can understand.




Is TDD a Silver Bullet?


I recently designed and implemented a project prototype. I used Test-Driven Development (TDD) as well. After implemented the project prototype for a few days, I felt TDD didn’t help me too much in this project due to lack of good requirements specification.

TTD is very helpful when we have a good requirements specification. In another words, if we know what we need to test, TDD is great. However, if we don’t have any concrete requirements specification and still is in prototyping or piloting phase, TDD is not so great.

If we design the project wrong in the upstream of software development cycle, it doesn’t matter whether we use TDD or not. The use case of TDD is in the implementation phase.

Sorry, TDD is not a silver bullet, and we still have to analyze and design first.




No. REST is an architecture style, and HTTP 1.1 is one of the implementations very closely following REST style. But REST is not limited to HTTP, it can be applied to other areas as well.

A little bit history here. One of my friends, Jun, worked at CERN around 90’s. He witnessed the birth of HTTP there. He said that the scientists need to share tons of information about particles, and HTTP was invented for that purpose. The scientists never imagined at that time HTTP changed the world forever, and we now call it World Wide Web.

The HTTP evolves over the years. Fielding developed the REST architectural style while worked on HTTP 1.1 of 1996–1999.



Unit Tests – Write Smaller Classes



The benefits of unit tests are well-known by us, as explained in numerous books and online articles such as this answer in StackOverflow,

However, most authors conveniently forgot to mention a few things about unit tests. Management usually worry about spending too much time on unit tests instead of real software deliverables.

  1. The size of unit tests is usually larger than the size of related classes being tested. If the size of the class is 100 lines of code, the size of related unit test will be around 200 to 500 lines of code because we have to test different methods and the combination also.
  2. The size of unit tests will grow exponentially.
    1. If the size of one class is 500 lines of code, , the size of related unit test will be around 3,000 to 6,000 lines of code.
    2. If the size of one solution is 1M lines of code such as Microsoft Word, , the size of related unit test will be around 20 to 50M lines of code.
  3. Programming is an art. Unit tests programming is an art also, which requires almost the same-level software skillsets but in different areas. The same software principles such as SOLID and DRY, etc., apply to unit tests as well.
  4. Maintenance of unit tests is just like the maintenance of the software, and should be treated as integrated portion of software.

Today I only mention one way to manage problems 1. and 2 is to write smaller classes. The classes will be easier to understand, the unit tests will be easier to write, and the size of unit tests will be smaller as well.


Design Principle #1 – Separation of Content and Presentation


How do we deliver the content to the end users? Depends on the audience, we might need to deliver the same content in different formats such as html, PDF, printer, voice prompts, braille, etc.

The answer is that we should use the design principle – separation of content and presentation.

If you really think about this, this design principle is applied everywhere we see. Web developers use CSS to create different presentations of the content for years. In addition, the same content of fancy-looking web pages (presentation 1) could be browsed in different devices (mobile-first responsive design, presentation 2), delivered in different languages to users in different regions (presentation 3), be printed to papers (presentation 4), fed into text-to-speech engine to generate high-quality voices for visually-impaired users (presentation 5), etc..

The key is that this design principle is NOT tied to any particular technology, can be applied to almost anywhere, and must be applied wisely.


  2. The separation of structure, presentation and behavior is dead


A Review of Murach’s Python Programming

Python is gaining in popularity. According to TIOBE Index for January 2017, Python is the fifth most popular programming language. I am recently interested in Raspberry Pi, and Python is the default language for it. So I picked up this book for a quick study because I like the self-paced style of Murach’s books.

This book is an introductory text to Python, and covers most of the programming concepts. I was able to follow the text and finished those exercises in Python 3 very quickly.  I also learned to use the IDLE, an IDE for Python, along the way.

From what I read in chapters of this book, Python is as powerful as most popular traditional languages such as Java and C#. However, Python is simpler and more intuitive. I believe teenagers should learn Python as their first language. In addition, Python is an interesting programming language which combines the best features of popular programming languages such as Java (platform-independent) and JavaScript (loose type system).

I strongly recommend this book to those who just want to learn Python. It really doesn’t matter whether you’re a beginner or an experienced programmer.

This review is first posted at Amazon.


Clean Architecture – Event Sourcing Pattern


Many years ago around 2008, I worked onsite in one of client sites. When I looked at the database model, I found something interested.

There were no delete operations allowed in the database model, and records were saved / presented in the layers. Delete and update commands were translated to insert new records operations. In addition, the change requests themselves and associated data were saved to other tables as the actions.

I immediately realized this was a great idea for recording-keeping, and the auditors like it. I called it snapshot design at that time. My ex-boss told me he continued to refine / design this model himself over the course of 16 years, finally reached this model, and he didn’t know how to describe it. However, he was very happy and liked the term snapshot design. Both of us didn’t realize it was one variation of Event Sourcing pattern.

Later I went on and designed / implemented two enterprise business applications using this pattern. Of course, I added my own flavors to improve the design.

I watched Uncle Bob’s Clean Architecture on YouTube one month ago. He mentioned this Event Sourcing pattern. I dived in and found what Event Sourcing was.


  1. Event Sourcing pattern on MSDN
  2. Martin Fowler’s article on Event Sourcing


Cloud Saturday Atlanta Jan. 21st

Went to Cloud Saturday Atlanta this past Saturday Jan. 21st at Alpharetta Microsoft Campus. I strongly recommend this event to any IT professional. In addition, I met a few alumni / friends there, and had a great time.

There were many sessions with various topics. The sessions I like were Microsoft Cognitive Service (Emotion API), DocumentDB (Microsoft’s NoSQL), Microservices with Docker, AWS, and Cloud Workflow.

I am going to write blogs to express my thoughts on these topics. So stay tuned…



SQL Index Strategies on OLTP vs OLAP

A SQL developer came to me. There was a report timeout issue. The same report ran fine during the passed two years.

I looked at the stored procedure that generated the data, and noted there were only two parameters passed in, BeginDate and EndDate. These two parameters basically filtered the data to make sure that the returned data set would not be too large. However, the report finally got the timeout issue because the size of table grew, there were no indexes on these two columns, and a table scan was used by SQL engine.

The lesson is that the SQL index strategies are different between OLTP and OLAP. We should add proper additional indexes on OLAP if necessary, and cannot simply rely on the existing indexes on OLTP.


  2. Search sql oltp vs olap using search engine

JavaScript function as first-class citizen


Interviewed candidates for senior full-stack developer position. Here was one of my questions in the JavaScript area.

Write a function ‘compose’ that takes two unary functions and returns a unary function that calls them both.

function double(x) { return 2 * x; }

function square(x) { return x * x; }

function triple(x) { return x * x * x; }

The ‘double’, ‘square’, and ‘triple’ are unary functions. Please finish the ‘compose’ function below.

function compose(f1, f2) {

    // implement code here….



Sample outputs of invocation of function ‘compose’:

compose(double, square)(3);              // result: 36

compose(square, triple)(3);              // result: 729


This question tests the knowledge of function as first-class citizen, which can be passed around just like data. The question is good for interview purpose because the answer is short and simple.

The answer is at the bottom of this page.








function compose(f1, f2) {
     return function(x) { return f2(f1(x)); };