Git Large File Storage

Summary In the post, I will introduce a common usage of large file storage in Git together with a tool bfg. Background Say one day you found an engineer in your team accidentally commit a binary file (for example a shared library) to the remote repository. He argued the file must be accessible in the…

DependencyManagement and Dependencies in Maven

Summary In this post, I will introduce the key difference between Maven’s <dependencyManagement> and <dependencies>. Conclusion In pom inheritance, artifacts specified <dependencies> will ALWAYS be included as a dependency of the child module(s). However, artifacts specified in <dependencyManagement> will only be included if child modules explicitly specify them in <dependencies>. <dependencyManagement> is good for centralized…

Generics in Java Compared to C++ Templates

Summary In this post, I will introduce Generic in Java. The post may be useful when you are working with Java with prior knowledge of C++. Context The context is that I want to define an AbstractBaseClass which is a top-level abstract class but different subclasses require different types of arguments for some member functions….

Virtual Functions, Constructors, and Destructors

Summary In this post, I will introduce rules related to constructors and destructors of classes which has virtual functions. Conclusions Golden Rule 1: Define a virtual destructor immediately Golden Rule 2: Do not invoke virtual functions from constructors or destructors Details In C++, Virtual functions allow for the choice of member function calls to be…

Override vs Overload

Summary In this post, I will introduce function override and function overload in C++, which are introduced by polymorphism in object oriented programming. Conclusion Overload Function overloadding achieves at compile time. It provides multiple definitions of the function by changing signature. Changing signatures includes changing number of parameters, change datatype of parameters. Note that return…

Class Template Definition and Declaration

Summary In this post. I will introduce class templates in C++. Especially, how do we declare a template which generates classes and how do we write definitions in separate source files. I will also dive deeper to present how class templates are compiled. Conclusion As usual, I present the conclusions first. Say the customer will…

A Generic Project Structure in C++

Summary In this post, I will introduce a generic structure for C++ projects. Details A clean structure is the basis of a clean project. I simplify the full version and present a simpler but useful structure here. 1. bin: The output executables. 2. build: This folder contains all object files. 3. docs: Any notes, like…

Allocate Memory in Constructors and Destructors

Summary In this post, I will introduce the way to define a class which contains memory allocation. I will focus on constructors and destructors in this post. Conclusion I present the conclusion first as usual: whenever the implementation of a class involves dynamically allocated memory, the class should explicitly define: a destructor which frees the…