devxlogo

How Do I Christen This Class?

How Do I Christen This Class?

Good design goes hand in hand with the nomenclature it uses for exchanging that design between developers. A key feature to writing good code consists of good naming conventions and consistency to ensure that the code will be reusable.

The purpose of any class that you design should be apparent from its name. In addition, it will help the reader if your class indicates whether it is an interface, an abstract class, or a concrete implementation class. You can christen the type of your class based on its “abstractness.” Let’s look at a simple inheritance example. Consider a class whose purpose is to manage something. We would definitely want to have the String “Manager” in its name. The definition of the hierarchy for this class consists of defining an interface, an abstract class that partially implements it (i.e., provides the implementation for some of its methods), and a concrete class that completes the implementation of the interface. The nomenclature should be as follows:

 public interface ManagerIfcpublic abstract class ManagerBase implements Managerpublic class ManagerImpl extends Manager

If other programmers look at this code and know your conventions, they can easily determine where in the hierarchy the class falls. An “Ifc” suffix indicates an interface; “Base” means an abstract class; “Impl” means an implementation. Only the class with the “Impl” suffix can be instantiated.

What if there are multiple implementations? In that case, the name should indicate what is the main characteristic of the implementation and the class “ManagerImpl” should just be a default implementation. For example, if we have “Product Managers” and “Project Managers,” we should name them as:

 public class ProductManagerImpl extends Managerpublic class ProjectManagerImpl extends Manager
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist