I’m so grateful I had the privelege to work so many smart and nice people in Google, this is the place where I grew into a leader and learned how to manage projects and people.
The reason I’m leaving has nothing to do with YouTube TV, nor the company, I’m very proud of the product and features that we developed and shipped, I would strongly recommend Google to my friends because it’s the best place to work, especially for engineers.
I tried to use a Raspberry Pi to shoot a timelapse, to record the growth of my baby tangerine.
However, after checking the first pilot, the tangerine plant is pretty blurry, the camera was focusing on somewhere far away but not the plant, like the floor in the background is clear.
If a function returns a static variable, there won’t be any return value optimization (RVO), as static variable is allocated for the lifetime of the program, it can’t be moved.
There are many discussions between reference and pointers, it’s not always true to say “use references when you can, and pointers when you have to“. We should pay attention to the lifetime of the input parameters, choose the one that is safer and more efficient according to the use case.
How to pass a parameter?
Before we talk about const reference vs. pointer in C++ class constructor, let’s take a quick look at different ways of passing a parameter to a function.
1 2 3 4 5 6 7 8 9 10 11
// 1. Passing by value. voidDoSomething(int a){}
// 2. Passing by const reference. voidDoSomething(constint& a){}
// 3. Passing by pointer. voidDoSomething(int* a){}
// 4. Passing by const pointer. voidDoSomething(constint* a){}
#
parameter
object copied?
original object mutable?
1
passing by value
✔️
X
2
passing by const reference
X
X
3
passing by pointer
X
✔️
4
passing by const pointer
X
X
As it can easily tell from the table above, passing by value introduces an extra object copy, while passing by pointer makes the original object mutable.
If you just want to pass some data, do some work with its value without updating it, you can choose #2 or #4, (don’t pick #1 as it’s could be expensive especially for large object, don’t use #3 as you could mistankenly update its value). Between #2 and #4, I’m leaning to #2 because reference is always non-nullable.
If you want to pass a parameter and update its value, pick #3 obviously.
to rename or move a file instead of renaming or moving a file directly (e.g. from IDE, or via mv). This is helpful for preserving history and potentially helpful for preventing merge mistakes.