Anonymous Methods and Types
-
Rajesh R Subramanian wrote:
Best arm size from the past - 18 inches, relaxed.
Holy Cow! :omg:
The narrow specialist in the broad sense of the word is a complete idiot in the narrow sense of the word. Advertise here – minimum three posts per day are guaranteed.
-
Anonymous types are handy when you want to databind properties that are not directly available in the form you want them to be in. Without anonymous types, you'd end up creating an inner private struct or class merely for databinding which is kinda overkill.
Regards, Nish
Nish’s thoughts on MFC, C++/CLI and .NET (my blog)
My latest book : C++/CLI in Action / Amazon.com linkIn other words, a closure.
-
Anonymous type…isn’t this SO gay VB?
The narrow specialist in the broad sense of the word is a complete idiot in the narrow sense of the word. Advertise here – minimum three posts per day are guaranteed.
Nah... Ya know, I originally learned to program in BASIC, and learned windows-based programming in VB3 (MFC was intimidating at that age)... Having long since outgrown that, I know all about the horrible things VB3 lets you do... Anonymous types in C# are NOTHING like the old "Variant" type in VB, even though they share a few letters. Variants are late-bound and utterly evil, but the C# "var" is just a syntax shortcut (The compiler knows the type). Now, the "dynamic" keyword they're adding in the next version... That's going to cause untold misery...
Proud to have finally moved to the A-Ark. Which one are you in?
Author of Guardians of Xen (Sci-Fi/Fantasy novel) -
Apart from LINQ- WHY???? It makes for messy code and harder to maintain code. At least that's all I've seen so far. any thoughts on the opposite?
Weight loss Target Weight at start [1/Feb/2009] 127kg Weight now [17/Feb/2010] 97.5kg Target weight : 80kg Only 17.5 to go hope to be there by July Wish me luck!
I agree completely. Clarity and simplicity always win the day over slightly more verbose code in my mind. In my first job many years ago I wrote a line of C++ code which took up about 4 lines. I used all the clever things you could do, assignments as expressions, ternary operators and such and marveled at how much I'd managed to fit between semicolons. My boss didn't like it though and taught me the most important lesson I've adhered to ever since - to make everything as clear and simple as possible. If only everyone else would choose simplicity over elegance or cleverness life would be much, much easier.
Regards, Rob Philpott.
-
I agree completely. Clarity and simplicity always win the day over slightly more verbose code in my mind. In my first job many years ago I wrote a line of C++ code which took up about 4 lines. I used all the clever things you could do, assignments as expressions, ternary operators and such and marveled at how much I'd managed to fit between semicolons. My boss didn't like it though and taught me the most important lesson I've adhered to ever since - to make everything as clear and simple as possible. If only everyone else would choose simplicity over elegance or cleverness life would be much, much easier.
Regards, Rob Philpott.
In other words... "Just because you can, doesn't mean you should."
.45 ACP - because shooting twice is just silly
-----
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
-----
"The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001 -
Because other languages have them and the C# team wants C# to be everything? :~
bingo. someone needs to tell the C# features team to take a few years off.
-
This is not entirely correct, the main C #prototypes - Java and Object Pascal has neither anonymous methods nor delegates.
The narrow specialist in the broad sense of the word is a complete idiot in the narrow sense of the word. Advertise here – minimum three posts per day are guaranteed.
And you can bet the C# team is having a good snicker over that...
.45 ACP - because shooting twice is just silly
-----
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
-----
"The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001 -
Apart from LINQ- WHY???? It makes for messy code and harder to maintain code. At least that's all I've seen so far. any thoughts on the opposite?
Weight loss Target Weight at start [1/Feb/2009] 127kg Weight now [17/Feb/2010] 97.5kg Target weight : 80kg Only 17.5 to go hope to be there by July Wish me luck!
i think they're great for things like simple sorting predicates. other than that... i dunno.
-
Nah... Ya know, I originally learned to program in BASIC, and learned windows-based programming in VB3 (MFC was intimidating at that age)... Having long since outgrown that, I know all about the horrible things VB3 lets you do... Anonymous types in C# are NOTHING like the old "Variant" type in VB, even though they share a few letters. Variants are late-bound and utterly evil, but the C# "var" is just a syntax shortcut (The compiler knows the type). Now, the "dynamic" keyword they're adding in the next version... That's going to cause untold misery...
Proud to have finally moved to the A-Ark. Which one are you in?
Author of Guardians of Xen (Sci-Fi/Fantasy novel)Ian Shlasko wrote:
Nah... Ya know, I originally learned to program in BASIC, and learned windows-based programming in VB3 (MFC was intimidating at that age)...
Yeah, I know - the first versions of MFC drove me to the hands of Delphi in the beginning of my career.
The narrow specialist in the broad sense of the word is a complete idiot in the narrow sense of the word. Advertise here – minimum three posts per day are guaranteed.
-
This reminds me my new hobby - RC helicopters /Align T-Rex 450/. :)
The narrow specialist in the broad sense of the word is a complete idiot in the narrow sense of the word. Advertise here – minimum three posts per day are guaranteed.
-
Rajesh R Subramanian wrote:
Best arm size from the past - 18 inches, relaxed.
Holy Cow! :omg:
The narrow specialist in the broad sense of the word is a complete idiot in the narrow sense of the word. Advertise here – minimum three posts per day are guaranteed.
Yeah, I used to love it when people complimented my physic. But that's in the past. :( A lumbar spinal disc prolapse ruined the whole thing for me more than 3+ years ago. Now that I've recovered, I'm back at the gym (about 2 months now) and am trying to gain muscles. And am having to take special care not to put load on the spine or on the lower back. No noticeable improvements so far, and I'm not able to take even one fourth of the weights I used to train with. I know that's natural, but it's all depressing as this is a fascination for me. I won't give up, but it's going to take a while. :|
“Follow your bliss.” – Joseph Campbell
-
And you can bet the C# team is having a good snicker over that...
.45 ACP - because shooting twice is just silly
-----
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
-----
"The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001Especially considering the fact that the Sun banned the delegates from Java just to be contrary to Microsoft. As a direct result the event handling in Java Swing is a little clumsy/compared to .Net, Delphi or even MFC/.
The narrow specialist in the broad sense of the word is a complete idiot in the narrow sense of the word. Advertise here – minimum three posts per day are guaranteed.
-
Yeah, I used to love it when people complimented my physic. But that's in the past. :( A lumbar spinal disc prolapse ruined the whole thing for me more than 3+ years ago. Now that I've recovered, I'm back at the gym (about 2 months now) and am trying to gain muscles. And am having to take special care not to put load on the spine or on the lower back. No noticeable improvements so far, and I'm not able to take even one fourth of the weights I used to train with. I know that's natural, but it's all depressing as this is a fascination for me. I won't give up, but it's going to take a while. :|
“Follow your bliss.” – Joseph Campbell
Hope you will get back in shape shortly.
The narrow specialist in the broad sense of the word is a complete idiot in the narrow sense of the word. Advertise here – minimum three posts per day are guaranteed.
-
hopingToCode wrote:
Weight at start [1/Feb/2009] 127kg Weight now [17/Feb/2010] 97.5kg Target weight : 80kg
Pretty impressive! How long did that take? brain fart. Just noticed you've mentioned the time taken too. :-O I might put myself on a muscle gain program. Best arm size from the past = 18 inches, relaxed. Current size after 3 years of rest for the back injury to heal = 14.2 inches. Target = old size. Going to take ages. :( BTW, I think that an arc trainer could possibly be the best calorie burning machine. I burned 200 calories in 10 minutes this evening. :)
“Follow your bliss.” – Joseph Campbell
Rajesh R Subramanian wrote:
BTW, I think that an arc trainer could possibly be the best calorie burning machine. I burned 200 calories in 10 minutes this evening
Try 100 burpees for time. :laugh:
I can imagine the sinking feeling one would have after ordering my book, only to find a laughably ridiculous theory with demented logic once the book arrives - Mark McCutcheon
-
Apart from LINQ- WHY???? It makes for messy code and harder to maintain code. At least that's all I've seen so far. any thoughts on the opposite?
Weight loss Target Weight at start [1/Feb/2009] 127kg Weight now [17/Feb/2010] 97.5kg Target weight : 80kg Only 17.5 to go hope to be there by July Wish me luck!
I disagree, just because it's possible that anonymous methods are messy, it doesn't follow that they are:
delegate void Foo(string s);
static void WriteToConsole(string j)
{
System.Console.WriteLine(j);
}public static void RunSnippet()
{
Foo bar = WriteToConsole;
bar("The delegate using the named method is called.");
}is far less terse than:
delegate void Foo(string s);
public static void RunSnippet()
{
Foo bar = j => System.Console.WriteLine(j);
bar("The delegate using the named method is called.");
}Once you get used to reading the syntax, sometimes it is just much cleaner to do it this way. If you need to doe something more complicated, then the anonymous method will look messier but, often, the anonymous method should be an actual method on the object type that is being acted on. Ironically, this means the "closure" stuff is cleaner if you get the object encapsulation right.
Dalek Dave: There are many words that some find offensive, Homosexuality, Alcoholism, Religion, Visual Basic, Manchester United, Butter. Pete o'Hanlon: If it wasn't insulting tools, I'd say you were dumber than a bag of spanners.
-
In other words, a closure.
Brady Kelly wrote:
In other words, a closure.
How can an anonymous type be a closure? :~
Regards, Nish
Nish’s thoughts on MFC, C++/CLI and .NET (my blog)
My latest book : C++/CLI in Action / Amazon.com link -
I agree completely. Clarity and simplicity always win the day over slightly more verbose code in my mind. In my first job many years ago I wrote a line of C++ code which took up about 4 lines. I used all the clever things you could do, assignments as expressions, ternary operators and such and marveled at how much I'd managed to fit between semicolons. My boss didn't like it though and taught me the most important lesson I've adhered to ever since - to make everything as clear and simple as possible. If only everyone else would choose simplicity over elegance or cleverness life would be much, much easier.
Regards, Rob Philpott.
With few exceptions, clear, simple code optimizes much better than convoluted "fancy" code. C# is no different.
-
Apart from LINQ- WHY???? It makes for messy code and harder to maintain code. At least that's all I've seen so far. any thoughts on the opposite?
Weight loss Target Weight at start [1/Feb/2009] 127kg Weight now [17/Feb/2010] 97.5kg Target weight : 80kg Only 17.5 to go hope to be there by July Wish me luck!
On the other hand, if it's such a problem to you, maybe you're in the wrong business?
-- Kein Mitleid Für Die Mehrheit
-
Apart from LINQ- WHY???? It makes for messy code and harder to maintain code. At least that's all I've seen so far. any thoughts on the opposite?
Weight loss Target Weight at start [1/Feb/2009] 127kg Weight now [17/Feb/2010] 97.5kg Target weight : 80kg Only 17.5 to go hope to be there by July Wish me luck!
-
hopingToCode wrote:
Weight at start [1/Feb/2009] 127kg Weight now [17/Feb/2010] 97.5kg Target weight : 80kg
Pretty impressive! How long did that take? brain fart. Just noticed you've mentioned the time taken too. :-O I might put myself on a muscle gain program. Best arm size from the past = 18 inches, relaxed. Current size after 3 years of rest for the back injury to heal = 14.2 inches. Target = old size. Going to take ages. :( BTW, I think that an arc trainer could possibly be the best calorie burning machine. I burned 200 calories in 10 minutes this evening. :)
“Follow your bliss.” – Joseph Campbell
How about doing some proper exercise :-)[^] Seriously though, do a summer's worth (i.e. a few training expeditions and then the main thing) and you'll see how quickly you become fit lugging a 50lbs rucksack around the mountains. You're expected to (as a 16 yro kid) eat a minimum of 3,500-4,500 calories per day just to keep going (you'll probably lose a bit of wait even with eating that much, I did).