Code reuse

Why write code that we already wrote for previous programs? Well here is a small tip that might save you some time: Make a generic file with reusable functions.

Many languages make this easy to do. Object oriented languages like Java or C++ for example allow you to make a class with utility functions, and then import them in your main program. This way you can use the generic class in all your programs. Even in C you can do this by including the generic C file when compiling with a command like:

gcc -o myprogram myprogram.c generic.c

Your generic utility functions would be in generic.c and gcc would simply add the file to myprogram.