Take care of the MainWindow
-
In the mornings, Bernie normally browses thru the code checked in by his coworkers. Well, it's just fun to start a long tedious working day among morons with some new ideas fit for the Annals of WTF.
David changed the constructor for a View which is used for showing some messages in their app. Originally, it was:
public InteractionView(string _title, int _width, int _height, object _content, bool _noSysMenu = true) { m_Window = new Window { Title = _title, Content = _content, WindowStartupLocation = WindowStartupLocation.CenterScreen, WindowStyle = WindowStyle.ThreeDBorderWindow, ShowInTaskbar = false, Owner = Application.Current.MainWindow, Width = _width, Height = _height }; if (_noSysMenu) { m_Window.Activated += WindowActivated; } }
Now it is:
public InteractionView(string _title, int _width, int _height, object _content, bool _noSysMenu = true) { m_Window = new Window { Title = _title, Content = _content, WindowStartupLocation = WindowStartupLocation.CenterScreen, WindowStyle = WindowStyle.ThreeDBorderWindow, ShowInTaskbar = false, //Owner = Application.Current.MainWindow, Width = _width, Height = _height }; if (m_Window != Application.Current.MainWindow) { m_Window.Owner = Application.Current.MainWindow; } if (_noSysMenu) { m_Window.Activated += WindowActivated; } }
Yes, David takes care that the Window to be constructed later on must not be mixed up with the MainWindow of the Application. How would the new Window behave if it was already the MainWindow and its owner is set to the MainWindow, i.e. itself? My poor brain just refuses to think of such a weird thing.
At the line of comparison with the MainWindow, ReSharper shows a "Possible unintended reference comparison" warning - which David ignores, of course. Well, at least he did not use the "Disable once with comment" option from the ReSharper menu, which he used several times in his new code.
-
I can't even tell what he was trying to do.
-
m_Window = new Window { ... }; if (m_Window != Application.Current.MainWindow) { ... }
That
if
is always entered, so I also want to know what it was supposed to do...
-
@JBert Well, ehm, in effect, the code change makes no change... Except for that strange exceptional case where David accomplishes to create the application's MainWindow with this constructor. I am curious to find out how that could happen. Obviously, also you fail to see a way to get there.
We're poor guys, we lack the inspirational genius of my coworker.
-
@BernieTheBernie maybe you should try asking him?
Edit: or maybe the commit message would give some insight?
-
@BernieTheBernie said in Take care of the MainWindow:
Well, ehm, in effect, the code change makes no change
Maybe that's the whole idea.
You know, to game @cartman82's hiring process, for example.
-
@Applied-Mediocrity said in Take care of the MainWindow:
@BernieTheBernie said in Take care of the MainWindow:
Well, ehm, in effect, the code change makes no change
Maybe that's the whole idea.
You know, to game @cartman82's hiring process , for example.if (m_Watermelon != Application.Current.MainFruit) { ... }
-
Is... this supposed to be C#? What is with these naming conventions? Why would you make a constructor like this for anything?
This is so thoroughly awful...
-
@Magus said in Take care of the MainWindow:
Is... this supposed to be C#? What is with these naming conventions? Why would you make a constructor like this for anything?
This is so thoroughly awful...
long time ago - HUNGARY notation borrowed from microsoft fried chicken (MFC).
-
@Nagesh No. Hungarian notation had meaningful prefixes. Mostly in C# it's evaporated to the point where private members in some codebases start with
_
s, but on parameters?
-
@BernieTheBernie said in Take care of the MainWindow:
accomplishes to create
I'm loving this phrase!
-
@Nagesh said in Take care of the MainWindow:
microsoft fried chicken (MFC).
-
@Nagesh should have said in Take care of the MainWindow:
HUNGRY notation borrowed from microsoft fried chicken (MFC).
+ for Microsoft Fried Chicken though. You got a laugh out of me.
-
@Zecc said in Take care of the MainWindow:
@Nagesh should have said in Take care of the MainWindow:
HUNGRY notation borrowed from microsoft fried chicken (MFC).
+ for Microsoft Fried Chicken though. You got a laugh out of me.
Yes, that was unexpectedly funny.
-
@Gąska You wouldn't get anything for the real expansion ("Microsoft Foundation Classes") because that's on MSDN.
(Seriously though, it's retired content, not just MSDN-shuffled. You have to download it like some sort of animal.)