From be49fc0a3bc99847ea877fb09a2a1411244c5a21 Mon Sep 17 00:00:00 2001 From: Sylv Date: Thu, 16 Jul 2026 06:26:49 -0400 Subject: [PATCH] docs(CONTRIBUTING.md): make constructors private in utility classes (#5490) * docs(CONTRIBUTING.md): privatize constructors in utility classes * fix(CONTRIBUTING.md): multiple private constructors * fix(CONTRIBUTING.md): formatting and grammar errors * fix(CONTRIBUTING.md): privatize -> make private --- CONTRIBUTING.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d998caf82f..59c276a1b0 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -102,6 +102,8 @@ Fabric API makes strong backwards compatibility guarantees, by which contributor - Avoid exposing java `record`s as public API. - Records expose more than is necessary for most APIs, which makes them difficult to evolve. - Prefer to expose an interface that is implemented by an impl record. +- Always make constructors `private` in utility classes. + - Utility classes are never instantiated, so ensure that they are final and their constructors are made `private`. - Avoid creating constant interfaces or creating an interface that is never implemented and intended only to hold `static final` fields. - Constant interfaces confuse users by suggesting they are intended to be implemented. - This is a common Java anti-pattern. @@ -128,7 +130,7 @@ Fabric API makes strong backwards compatibility guarantees, by which contributor } // Holder class is not meant for instantiation. - private ExampleEvents() { + private FooEvents() { } } ``` @@ -227,7 +229,7 @@ public final class FooEvents { } // Holder class is not meant for instantiation. - private ExampleEvents() { + private FooEvents() { } } ```