Monthly Read Posts in Sep 2018
Programming Language
Strong types for strong interfaces
How to add a type wrapper for built-in types.
Besides using phantom template parameter to avoid alias, one can also use private inheritance:
1 | class NamedType |
Passing strong types by reference – First attempt
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.
CppCon 2015: Peter Sommerlad “Variable Templates and Compile-Time Computation with C++14”
This talk really presents some amazing magics, like generating multiplcation table on compile time…
Don’t Try Too Hard! – Exception Handling
- 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.
Helper Classes Deserve Some Care, Too
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.
Operating System
Exploring Windows virtual memory management
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.
Network
What does too many CLOSE_WAIT connections mean and how to solve it.
Coping with the TCP TIME-WAIT state on busy Linux servers
what is TIME_WAIT
and why net.ipv4.tcp_tw_recycle
evil
扫盲,就是内容太少了。
这样看起来 dummy 也太 dummy 了
Architecting
因为没有具体经验,所以上面三篇文章干货足不足不好评判
The basic architecture concepts I wish I knew when I was getting started as a web developer.
MISC
It all comes down to respecting levels of abstraction
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.