I guess LINQ sometimes modifies a sequence in-place, and sometimes creates a new sequence like STL _copy algorithms
See posts on meta programming.
Linq sequence processing is FP.
However, Linq permits mutable sequence, contrary to FP principles.
http://www.java2s.com/Code/CSharp/Language-Basics/Demonstrategettingandprintingtheinvocationlistforadelegate.htm Demonstrates printing the invocation list of a delegate
Update: java 8 lambda. [[mastering lambds]] P 5 mentions AA BB DD as use cases for Command pattern
AA — is the main topic of the book
BB — https://docs.oracle.com/javase/tutorial/java/javaOO/lambdaexpressions.html
DD — http://www.oracle.com/technetwork/articles/java/lambda-1984522.html and http://www.drdobbs.com/jvm/jdk-getting-a-head-start-with-lambdas/240008174
Today I finally feel ready to summarize the 2 usage categories of c# delegates. If you are new like me, it’s better to treat them as 2 unrelated constructs. Between them, the underlying technical similarities are relevant only during initial deep dive, and become less important as you see them in various patterns (or “designs”).
In java, these features are probably achieved using interface + other constructs. Dotnet supports interfaces too, but in some contexts offers more “specialized” constructs in the form of delegates. As shown below, in such a context interfaces are usable but less than delegates.
Most tutorials would start with unicast delegate, without the inv list.
Coming from a java or c++ background, you will want to find a counterpart or close equivalent to delegates. Almost hopeless for BB. For AA there are quite a few, which adds to the confusion.
AA) lambda as function AAArgument
* I believe compiler converts such a lambda into a STATIC method (there’s really no host object) then bind it to a delegate Instance
* often returns something
* Usually _stateless_, usually without captured variables.
* predominantly unicast
* Action, Func and Predicate are often used in this context, but you can also use these 3 constructs as closures, which is a 3rd category beyond AA and BB
* Domain? Linq; functor argument as per Rajesh of OC
* Before java 8, often implemented as an interface or an anonymous inner class
BB) event field Backed by a multicast delegate instance (See other posts on “newsletter”)
* Usually NON-STATIC methods, esp. in GUI context
* Usually returns void
* A callback method is usually _stateful_, because the callback method often does its job with “self-owned” i.e. this.someField objects, beyond the argument objects passed in
* event is a pseudo _f i e l d_ in a class. Static field or non-static field are both common.
* Domain? GUI + asynchronous WCF
* we must register the callback method with the event source.
** can lead to memory leak
* in java, implemented by several callback Objects supporting a common interface (cf swing)
Some of the other categories —
CC) CCClosure — stateful, seldom passed in as a func arg
DD) thread start
EE) Passing in a delegate instance as a function input is the lambda usage (AA). How about returning from a function? P83 [[c#precisely]] shows examples to return an anon delegate instance. This is an advanced and non-trivial unicast use case. The underlying anon method is usually static and stateless
In a source code with AA, we see lots of custom delegate Types created on the fly.
In a source code with BB, delegate Instances take center stage, since each instance is assigned to a … pseudo field. The delegate type is less complicated.
– – I still feel less familiar with some everyday tasks than my c# veteran colleagues.
– – i did rather few complete projects like Guardian and many enhancement projects. In contrast, veteran c# guys did more big projects. The number of years isn’t as important as complexity and variety of challenges. VARIETY — for eg a web dev expert (or a DB-centric c# coder) isn’t really a complete c# expert.
– – assembly, appdomain, GAC
= = people agree that I can get my job done and meet most technical challenges, even if non-trivial. (“tactical”)
= = explaining, justifying my design choices – not always convincing. Not only c#, but java too.
+ + When presented a new c# challenge, when pushed to the frontier of my c# know-how, I am competent to construct a basic “infrastructure” and then search on-line for the missing pieces to complete the loop meeting the challenge
+ + competent with most everyday troubleshooting. Some troubleshooting is beyond my current skill but I feel many are hard for my veteran colleagues too. If my colleagues can solve 50% of the tech problems, then my level is close to that. This competence comes from mileage i.e. real world projects. The more projects one takes on, the more competent.
+ + much more confident with MSVS than before. Perhaps comparable to my Eclipse confidence.
+ + on some of the hot but purely theoretical IV topics (fake mileage), I have read up quite a bit and appreciate their nuances. I can follow most discussions on these topics –
*GC, dtor, finalizer
1) home-grown web server to download any file in the local file system – essentially my invention, as no one in the team know how to do it
GUI – full ownership
stability improvement in the microagent and Guardian server
Bloomberg piece – no one dared to touch it given the complexity
Created many windows services
Though this post is about dotnet, it is likely to be also applicable to non-dotnet apps.
You can create/delete custom event logs. The 3 built-in event logs (app, security and sys) can’t be deleted. All of the above are viewable on eventvwr.exe
Except security log, all other event logs are writable – including app, sys and custom event logs. I feel this is a simple way to implement basic application logging in dotnet. The EntryWritten event firing feature looks neat.
Further, it looks like multiple (Local) processes can subscribe to the same EntryWritten event, so you could perhaps coordinate 2 processes using EntryWritten — IPC
You can even access remote event logs.
Perf counter is Another simple IPC mechanism. You can create custom perf counters, visible to other processes + perfmon.exe.
Since one process can update the counter and another process can see it in real time, it’s IPC.
I have yet to implement IPC this way.
background — I used wcf many times but a clear understanding doesn’t come automatically.
See other blog posts about the “Service” jargon.
A TYPICAL wcf service is characterized by these items
– always remote;
– always requires serialization across network
– always uses a public url (part of the so-called service endpoint)
– protocol — typically http or tcp
– serializer/formatter/encoding — typically xml or binary
– there must exist a local proxy INSTANCE for some remote “object”, though the “service” concept isn’t strongly object-oriented.
– hosting process — any process that stays up, such as —
** console host
** winforms, wpf
** windows service (similar to linux daemons, visible on services applet)
** web server
A wcf service must be hosted — basically a server process. In contrast, the client process can be short-lived. The host is the realization of a lot of the above
wcf and soap? wcf is frequently implemented using soap + other technologies
wcf and the remoting technologies? see separate post
myArray.Aggregate(“”, (a, b) => a + b + “, “)
C:Usersa5xxxxxxAppDataLocalMicrosoftSilverlightOutOfBrowser – win7
C:Documents and SettingsA5XXXXXXLocal SettingsApplication DataMicrosoftSilverlightOutOfBrowser – winxp