Table of Contents

RDC00405 — Implementations should be private

Severity: Information  ·  Family: RDC (Rubberduck Core analyzers)  ·  Raised by: ImplementationsShouldBePrivateAnalyzer

A Public procedure implements a member of an interface, or handles an event.

The Public members of a class module are the members of its default interface. A procedure named InterfaceName_MemberName implements a member of an interface the class Implements (MS-VBAL §5.3.1.9 Implemented Name Declarations); made Public, it exposes the member of another type on this one's, where it does not belong. A procedure named VariableName_EventName handles an event of a WithEvents variable (§5.3.1.8 Event Handler Declarations); the language calls it when the event is raised, and nothing else should: made Public, it can be. The diagnostic is an opinion of the analyzer and not a condition of the language: both are legal.

That a member is an implementation or a handler is a fact of the declaration that the environment host vouches for (DeclarationFact.Role): it knows which names the interfaces of the module and the events of its WithEvents variables make. A Public procedure that only has an underscore in its name, or that begins like one, is not reported. It is a suggestion because Private does not change what the procedure is.

How it is raised

Situation Example Resolution
A Public procedure, or one that states no access, implements a member of an interface of the class. Public Sub IShape_Draw() Declare it Private.
A Public procedure, or one that states no access, handles an event of a WithEvents variable. Public Sub Source_Click() Declare it Private.

See also


ACCUEIL • HOME | ℹ️ BIENVENUE • WELCOME | 🧩 BÂTISSONS • BUILD | RD-VBAL | SDK | 🌐 rubberduckvba.ca