473,799 Members | 3,080 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

what is anonymas methods

Hi,

I want to know what is anonymas methods and how they can be used.

Thanks and regards.
Bhuwan
Oct 7 '07 #1
6 1453
"Bhuwan Bhaskar" <kx**@gmail.com schrieb
Hi,

I want to know what is anonymas methods and how they can be used.
I haven't heard of it yet. Pretty sure that it is not a term of a current or
past VB release.
Armin

Oct 7 '07 #2
Hi,

"Bhuwan Bhaskar" wrote in message
news:up******** ******@TK2MSFTN GP03.phx.gbl...
I want to know what is anonymas methods and how they can be used.
http://msdn2.microsoft.com/en-us/lib...5k(VS.80).aspx

but C# only.
Oct 7 '07 #3
Bhuwan,

For me it is something like the overloading operator method in version 2005.

Something I never need however in my idea some want it because they cannot
make a program in a maintainable way but needs things that make their
programs "looks" more sophisticated. For others it has to be in VB.Net
because it is in C#.

Of course those things can be handy, but for me it makes only that I need
more time when I review a program of somebody else.

However just my thought,

Cor

Oct 7 '07 #4
On Oct 7, 10:55 am, "Cor Ligthert[MVP]" <notmyfirstn... @planet.nl>
wrote:
Bhuwan,

For me it is something like the overloading operator method in version 2005.

Something I never need however in my idea some want it because they cannot
make a program in a maintainable way but needs things that make their
programs "looks" more sophisticated. For others it has to be in VB.Net
because it is in C#.

Of course those things can be handy, but for me it makes only that I need
more time when I review a program of somebody else.

However just my thought,

Cor
For me, anonymous delegates have three purposes (and only one is a
good purpose).

1) Help create hard to debug and maintain code. It's sort of like
using a public field instead of a full fledged property. In the
initial release it makes things "short and sweet", but 4 months later
when you need to make a change, or reuse the function, or apply an
attribute, you must spend even more time finding and rewriting the
code to into a "proper" method.

2) Give the C# loving, VB hating people something to brag about. As
you surely know the common response to "VB can do anything C# can"
post is "Oh yeah, what about creating Anonymous Methods?" Sure we can
declare the method, but that seems to never be enough to the anti-VB
groups.

3) Limited debugging help. Often times we create a method to use
solely for debugging. Generally, these are used to check for the
existence of a problem and then deleted. In this case it's nice to
wrap everything in one method declaration instead of having multiple
methods we need to delete afterwards. After all, stranding a method
can lead to confusion during maintenance, since you probably won't
remember what the method was ever used for.

(Just some casual observations on the topic)

Thanks,

Seth Rowe

Oct 8 '07 #5
On Oct 8, 7:45 am, rowe_newsgroups <rowe_em...@yah oo.comwrote:
For me, anonymous delegates have three purposes (and only one is a
good purpose).

1) Help create hard to debug and maintain code. It's sort of like
using a public field instead of a full fledged property. In the
initial release it makes things "short and sweet", but 4 months later
when you need to make a change, or reuse the function, or apply an
attribute, you must spend even more time finding and rewriting the
code to into a "proper" method.
I hold the opposite view. When used appropriately it makes the code
*much* easier to read and maintain. Consider this example that
searches a List for all Point objects with the same X coordinate.

int criteria = GetCurrentCrite ria();
List<Pointlist = GetSomeListOfPo ints();
List<Pointresul t = list.FindAll(de legate(Point p) { return p.X =
criteria; });

Aside from using lambda expressions it just doesn't get any clearer
than that. The predicate logic is embedded in the same spot where it
is used. Now, consider what this would look like in VB. There are
two alternatives. The first requires creating a new instance variable
in the class whose only purpose is to temporarily store the criteria
so that it can be referenced in the Predicate delegate. The second
requires creating a brand new class that has the instance variable and
Predicate delegate. It's the better of the two options (and what the
C# compiler does for you), but still not very elegant if you ask me.

>
2) Give the C# loving, VB hating people something to brag about. As
you surely know the common response to "VB can do anything C# can"
post is "Oh yeah, what about creating Anonymous Methods?" Sure we can
declare the method, but that seems to never be enough to the anti-VB
groups.
VB.NET's lack of anonymous methods is (was) unfortunate. Lamda
expressions arrive next year though.
>
3) Limited debugging help. Often times we create a method to use
solely for debugging. Generally, these are used to check for the
existence of a problem and then deleted. In this case it's nice to
wrap everything in one method declaration instead of having multiple
methods we need to delete afterwards. After all, stranding a method
can lead to confusion during maintenance, since you probably won't
remember what the method was ever used for.

(Just some casual observations on the topic)

Thanks,

Seth Rowe

Oct 8 '07 #6
Sorry, I got quite busy yesterday and didn't get a chance to respond.
I hold the opposite view. When used appropriately it makes the code
*much* easier to read and maintain.
The key phrase here is "when used appropriately." In my experience
anonymous methods are easy to misuse, in that they are used to just to
be "lazy" putting everything in-line instead of adding an additional
method. And for the record, I never said that anonymous methods
couldn't increase readability, I just said they can make maintenance
more difficult (as it can get messy adding additional lines to a
delegate, such as code to fire off events, or attributes, or reusing
the code, et cetera).
int criteria = GetCurrentCrite ria();
List<Pointlist = GetSomeListOfPo ints();
List<Pointresul t = list.FindAll(de legate(Point p) { return p.X =
criteria; });
Very good example! I hadn't thought about the sharing of method-level
variables when I posted.
The first requires creating a new instance variable in the
class whose only purpose is to temporarily store the criteria
Well, depending on where and what GetCurrentCrite ria() is, we could
just use it in our predicate method (Return p.X =
GetCurrentCrite ria()). But like I said, depending on the
implementation of GetCurrentCrite ria() this could lead to poor
performance (as in the case of remote service calls) or to inconstant
data (if for example the method read out real-time data).

I guess the question now becomes when is the proper time to use an
anonymous method, and when is the proper time to wrap the
functionality into a full fledged method? Any more ideas besides the
local variable sharing?

Thanks,

Seth Rowe

Oct 9 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

54
6582
by: Brandon J. Van Every | last post by:
I'm realizing I didn't frame my question well. What's ***TOTALLY COMPELLING*** about Ruby over Python? What makes you jump up in your chair and scream "Wow! Ruby has *that*? That is SO FRICKIN' COOL!!! ***MAN*** that would save me a buttload of work and make my life sooooo much easier!" As opposed to minor differences of this feature here, that feature there. Variations on style are of no interest to me. I'm coming at this from a...
28
3310
by: David MacQuigg | last post by:
I'm concerned that with all the focus on obj$func binding, &closures, and other not-so-pretty details of Prothon, that we are missing what is really good - the simplification of classes. There are a number of aspects to this simplification, but for me the unification of methods and functions is the biggest benefit. All methods look like functions (which students already understand). Prototypes (classes) look like modules. This will...
7
3564
by: Michele Simionato | last post by:
So far, I have not installed Prothon, nor I have experience with Io, Self or other prototype-based languages. Still, from the discussion on the mailing list, I have got the strong impression that you do not actually need to fork Python in order to implement prototypes. It seems to me that Python metaclasses + descriptors are more than powerful enough to implementing prototypes in pure Python. I wrote a module that implements part of what...
24
2418
by: Xah Lee | last post by:
in computer languages, often a function definition looks like this: subroutine f (x1, x2, ...) { variables ... do this or that } in advanced languages such as LISP family, it is not uncommon to define functions inside a function. For example:
4
1511
by: Alex Sedow | last post by:
Method invocation will consist of the following steps: 1. Member lookup (14.3) - evaluate method group set (Base.f() and Derived.f()) .Standart say: "The compile-time processing of a method invocation of the form M(A), where M is a method group and A is an optional argument-list, consists of the following steps:  The set of candidate methods for the method invocation is constructed. Starting with the set of methods associated with M,...
6
6080
by: John Salerno | last post by:
I understand how they work (basically), but I think maybe the examples I'm reading are too elementary to really show their value. Here's one from Programming C#: #region Using directives using System; using System.Collections.Generic; using System.Text;
18
1984
by: cj | last post by:
members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe. I'm under the impression before you can use a class you have to make an instance of it. So how can a class be threadsafe by itself but an instance of it not be? I guess I don't get what exactly being threadsafe means. Multiple theads can use the same instance of a class?
18
1841
by: Xah Lee | last post by:
What are OOP's Jargons and Complexities Xah Lee, 20050128 Classes, Methods, Objects In computer languages, often a function definition looks like this: subroutine f (x1, x2, ...) { variables ...
9
1967
by: Jonathan Wood | last post by:
I found the following class on the Web: public class LoginRewriter : IHttpModule { void IHttpModule.Dispose() { } void IHttpModule.Init(HttpApplication app) { app.AuthorizeRequest += new EventHandler(authorizeRequest); }
0
9687
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9541
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10027
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9072
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7565
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6805
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5463
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4141
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3759
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.