Month: July 2019

By Reference vs By Pointer Dependency Injection C++

By Reference DI is safer because reference cannot be Null, but it has some issues: initialization, copying, and assignment problem. Something that I’m currently experience now.

By Pointer DI has no issues above, but by using pointer reference you will need to watch some issues like object ownership (where Smart Pointer is better), and null-value (always remember to assert dependencies != nullptr)

My Git Command Tricks

Temporarily switch to a certain commit

Make sure git status is clean. Jump to a specific git commit:
git checkout commit_hash

Example:
git checkout 286202caa31b61c2182209f37f8069a0b60fb942

Back to the original commit:
git checkout branch_name

Example:
git checkout master