When you're learning something new and eventually you figure it out, you got a fresh algorithm or rules in your mind, to understand how to use that. At that point you can explain it to somebody else and he/she will most likely understand the thing faster. However, when you become an expert your brain works automaticly and it is more difficult for you to explain it to somebody else. You forget that it is not straigforward to figure that out when you don't know it yet. Somebody else might be yourself within months, after a while without using that thing. This is a another good reason to write documentation and unit tests as the functionality is being implemented, that is, as the code is being written.
I had a bunch of ideas on how to explain the rationale behind applying generics when I was learning them. Now I just use strongly type structures and generic collections as much as I can but I would find it difficult to explain.
I'm know trying to leverage "new" features of C# and this time I'll post my thoughts about them. One useful manner of taking advantage of Anonymous Delegates is to use them as event handlers.
1: private void createDynamicPlaceholders()
3: StackPanel panel = new StackPanel();
4: panel.HorizontalAlignment = HorizontalAlignment.Left;
5: panel.Orientation = Orientation.Horizontal;
7: Label pickLabel = new Label();
8: pickLabel.Content = "Pick ";
9: Label ofLabel = new Label();
10: ofLabel.Content = " of ";
12: // LOOK THIS:
13: IntegerTextBox cumulativeBox = new IntegerTextBox();
14: IntegerTextBox maxPicksBox = new IntegerTextBox();
15: maxPicksBox.KeyUp +=
16: delegate(Object sender, KeyEventArgs args)
18: cumulativeBox.MaxValue = maxPicksBox.Integer;
19: if (cumulativeBox.Integer > maxPicksBox.Integer)
21: cumulativeBox.Integer = maxPicksBox.Integer;
If there wasn't an anonymous delegate I'd need a subscriber method but more importantly, I'd need to save the reference to the two textboxes, as the code in the subscriber needs them. It would imply having some kind of structure in memory to reference them, it means more lines of ugly code.