-
-
Notifications
You must be signed in to change notification settings - Fork 346
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simplify IUser #2163
Simplify IUser #2163
Conversation
It looks like |
My suspicion would be that as events ahave been removed from IUser's main sections, the editors have left them in the NullUser part by accident, not necessarily realising they were there. This PR seems to be removing a bunch of code, but I can't see any impact. Is it possible some of it is used in obscure commandline cases? I mean, the IDE/build process should flag that, I suppose. |
"Obscure command line cases" is the story behind I did text searches before removing the events, and then compiled the code after. I believe that would catch anything that's trying to use them. |
NullUser is about allowing tests to run without interrupting the build process, I gather. |
Great work, by the way, and very much appreciated! It's very easy for codebases like this to get filled up with unused cruft that no one dares touch. |
Yes, |
That seems odd. Well, if you want to tackle those issues as future projects, it would be most welcome. I find myself flailing in the wind trying to make sense of this code a lot of the time. See #1971 for a good example of that. |
Currently
IUser
has 6 public events, which makes it awkward to implement this interface. These events are only used insideNullUser
, so at first blush, they belong insideNullUser
as an implementation detail. However, allNullUser
does with them is wire up the interface's functions toNullUser
's own equivalentvirtual
functions. This is an unnecessary and cumbersome step of indirection with no advantages over simply calling those functions directly. (Technically this structure could allow third-party classes to inject listeners to various events in other places, but no code currently does this, so the need/advantage is debatable.)This PR replaces this structure with a much simpler one and does some additional minor clean-up:
NullUser
NullUser
simply call the virtual functions from inside the interface functionsWindowWidth
(not used even before this)IUser
into a general-purpose group and a progress/updates groupAfter these changes,
Core\User.cs
is much easier to understand, theIUser
interface is much simpler to implement in new code, and existing code still works.