Naming standard for abstract/base classes

Created on 8 May 2012, about 12 years ago
Updated 21 June 2024, 7 days ago

Spin-off from #1567812-7: Remove "Verified" from configuration class names โ†’

Problem

  • It's not clear whether a class is an abstract base class or not.

Goal

  • Introduce coding standard for abstract base class names.

Details

  • Coding standards define naming for classes (e.g., Thing) and interfaces (e.g., ThingInterface).
  • Current code in core is inconsistent regarding abstract base class names:
    • ThingBase (abstract or not)
    • AbstractThing
    • Thing (even if abstract)
  • Symfony has no clear and consistent standard either.
  • Abstract base classes are as structuring as interfaces when looking at a class hierarchy.
  • Denoting the abstract nature in the class name is very handy.
  • There are 4-5 abstract classes in the OO Field API redesign and the "X as plugin" conversions will likely introduce many more in various subsystems.
  • A base class might be abstract or not. The "baseness" is a very important hint: When you want to implement your own thing, look up the at ThingInterface and notice there is a ThingBase to it. You learn it's probably a good idea to consider subclassing the base instead of starting fresh. Regardless of whether the base class is abstract or not.

Options

  • Thing: No indication for abstract base classes.
  • ThingAbstract: "Abstract" suffix. Unnatural language. Appears next to ThingInterface in file listings.
  • AbstractThing: "Abstract" prefix. Natural language. Far off from ThingInterface in file listings.
  • ThingBase: "Base" suffix. ditto.
  • BaseThing: "Base" prefix. ditto.

Proposed solution

  1. ThingBase
๐Ÿ“Œ Task
Status

Active

Component

Coding Standards

Created by

๐Ÿ‡ซ๐Ÿ‡ทFrance yched

Live updates comments and jobs are added and updated live.
  • Coding standards

    It involves compliance with, or the content of coding standards. Requires broad community agreement.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024