Skip to content

Wrap fields in private type #875

@retailcoder

Description

@retailcoder

A module usually has its fields this way:

Private mFoo As Integer
Private mBar As Integer

Public Property Get Foo() As Integer
    Foo = mFoo
End Property

Public Property Get Bar() As Integer
    Bar = mBar
End Property

That works, but I prefer this:

Private Type TClassName
    Foo As Integer
    Bar As Integer
End Type

Private this As TClassName

Public Property Get Foo() As Integer
    Foo = this.Foo
End Property

Public Property Get Bar() As Integer
    Bar = this.Bar
End Property

Wrapping the private fields in a private type like this, eliminates the need for prefixes and makes the code cleaner, leaving only a single field in the class, which I like to name this.

Could be just me though. Thoughts?

Metadata

Metadata

Assignees

Labels

difficulty-03-duckInvolves more challenging problems and/or developing within and revising the internals APIenhancementFeature requests, or enhancements to existing features. Ideas. Anything within the project's scope.feature-refactoringsup-for-grabsUse this label in conjunction with a difficulty level label, e.g. difficulty-02-ducky

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions