Monthly Read Posts in Sep 2018
How to add a type wrapper for built-in types.
Besides using phantom template parameter to avoid alias, one can also use private inheritance:
This post is the sequal of the above post.
The main problem the post tryies to solve is: how to make copy of
NamedType values cheap.
However, I am conservative on using reference-wrapper as the solution, because doing this has to expose the lifetime of the wrapped object to public; after all, reference-wrapper is only a point per se.
I think the real solution is to make wrapped object type clear about being value semantics or reference semantics.
Using double is usually faster than using float.
Because compilers usually promote float to double for evalution, and convert back as final result.
This talk really presents some amazing magics, like generating multiplcation table on compile time…
- Restrict exception types that may throw to control catch handlers.
- Use RAII instead of try/catch for cleanup in the presence of exceptions.
- Try not to change exception types.
- Be consistent in use of exceptions.
- Exceptions are part of a library’s interface but can be leaked more easily. Encapsulate them properly.
- Only catch exception if you have enough information to take actions on them.
Know C++ compilation and linking model and internal linkage can be your friend.
There are other engineering advice but they have been talked too much and I decide to follow the DRY principle.
This post should be divided into several parts to reduce information density.
Besides, this post lacks a systematic roadmap for thinking clearly.
Maybe reading Windows Internals is a better option.
What does too many CLOSE_WAIT connections mean and how to solve it.
TIME_WAIT and why
这样看起来 dummy 也太 dummy 了
The basic architecture concepts I wish I knew when I was getting started as a web developer.
One principle to rule others all: respecting levels of abstractions.
Respecting levels of abstraction means that all the code in a given piece of code (a given function, an interface, an object, an implementation) must be at the same abstraction level.
Constantly ask yourself: in terms of what am I coding here.
Generalizations has a cost. Don’t generalize a function because you have a hunch that “some day in the future” the generalization might be useful.