Thank you. The DSpace Build Cookbook was very helpful.
basically, if you can, use the overlays mechanism, which will ease
forward-porting your changes to newer DSpace version.
If you can't, you're making an Addon. This can be a standalone
module/webapp (maven project) or modifications to existing codebase
which you distribute in form of a patch.
Here are some resources you can look at:
Compulsory reading: DSpace Mailing List Etiquette