Closed FiSHonAUT closed 3 years ago
The Code Explorer doesn't currently create parent nodes for member types, but it does offer various ways to regroup them via sort options, and different accessibility members use different icons (private members have a little padlock icon).
We would not necessarily need a new annotation to implement this kind of grouping though: it could be a toggle button in the toolbar, but then that would affect all modules... perhaps something like a module-level @GroupMemberTypes
annotation could give RD a hint for grouping the members of that module, while leaving other non-annotated modules alone (i.e. render them without parent member type nodes).
That said, consider moving related members to other class modules, and leverage composition to reduce the responsibilities of a large class and move concerns to more specialized modules.
Composition is just a fancypants OOP term to mean simply declare a private instance field of an object type inside a class module:
Option Explicit
Private OtherFunctionality As AnotherClass
The instance can be New
'd up in the _Initialize
handler if coupling is acceptable, or provided as an abstraction/interface by the calling code via a factory method and property injection if the two objects need to be decoupled.
The result is functionally identical to the original code, but now instead of invoking private methods in the same class (e.g. Private Sub DoStuff()
), you're invoking public methods in that other class:
Before:
DoStuff
After:
OtherFunctionality.DoStuff
Thank you very much for your detailed answer! :-)
After spending time learning from Mathieu, when I first read the OP’s request my first thought was, “that class is probably doing WAAAY too much and needs to be broken up into more focused classes” which would really increase testability and reusability.
DGM
From: Mathieu Guindon notifications@github.com Sent: Saturday, December 12, 2020 11:39 AM To: rubberduck-vba/Rubberduck Rubberduck@noreply.github.com Cc: Subscribed subscribed@noreply.github.com Subject: Re: [rubberduck-vba/Rubberduck] Subfolders within a module (#5655)
The Code Explorer doesn't currently create parent nodes for member types, but it does offer various ways to regroup them via sort options, and different accessibility members use different icons (private members have a little padlock icon).
We would not necessarily need a new annotation to implement this kind of grouping though: it could be a toggle button in the toolbar, but then that would affect all modules... perhaps something like a module-level @GroupMemberTypes annotation could give RD a hint for grouping the members of that module, while leaving other non-annotated modules alone (i.e. render them without parent member type nodes).
That said, consider moving related members to other class modules, and leverage composition to reduce the responsibilities of a large class and move concerns to more specialized modules.
Composition is just a fancypants OOP term to mean simply declare a private instance field of an object type inside a class module:
Option Explicit Private OtherFunctionality As AnotherClass
The instance can be New'd up in the _Initialize handler if coupling is acceptable, or provided as an abstraction/interface by the calling code via a factory method and property injection if the two objects need to be decoupled.
The result is functionally identical to the original code, but now instead of invoking private methods in the same class (e.g. Private Sub DoStuff()), you're invoking public methods in that other class:
Before:
DoStuff
After:
OtherFunctionality.DoStuff
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/rubberduck-vba/Rubberduck/issues/5655#issuecomment-743789543 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AKCD6F62URNXINZ6EI2AZL3SUOTENANCNFSM4UYKF2HA . https://github.com/notifications/beacon/AKCD6FYDBHVWM6EU2Z3CQJTSUOTENA5CNFSM4UYKF2HKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOFRKVHZY.gif
Hi, I just started using Rubberduck and I am still in getting into it. I discovered the magic comments, especially the folders (@Folder). Unfortunately with the Folder annotation it is only possible to organize whole modules. But I have one or another big class module and it would help a lot to use something similar to @Folder for within a module. I would like to group the declaration part, the public functions and the private functions of a class module, for example. Of course I group it in the Code section of VBE, but it would be nice to have a visual structure in Rubberduck's Code Explorer. Is Rubberduck able to do that?
Thanks for your help! Andreas