arrayName^ptrVar – headfirstC

How important? So low-level! I feel precise grasp gives us confidence. There are quite a lot of nuances due to this fundamental difference.
—————-

void f(){
 int arr[33] = …
 int* ptr = …;

[[headfirst C]] P79 clearly explains that compiler will allocate stack memory for a variable ptr but not for arr. Basically, the “arr” variable doesn’t exist in the final executable.

(Assuming a 32bit) If you look at the size of the stack frame, you find 4 bytes for “ptr” and 33*2 bytes for “arr”. No allocation for the “arr” variable! Compiler allocates 4 bytes for the ptr VARIABLE “ptr” partly because we can later reseat this pointer. In contrast, the “arr” name is a not reseatable and a permanent alias for the address of array object. Every occurence of “arr” is replaced (by compiler) with the actual address of the array object.

arr = anotherArray;// won’t compile.
————-
On P59, the book points out another key difference between array Name vs ptr Variable

Taking the address of “ptr” gives you the address of the 4-byte ptr VARIABLE. So suppose ptr points to address 0x0197. &ptr may be 0xb762.  In contrast,

&arr == arr // Both expressions evaluate to an address (like 0xb755) of the array OBJECT. There’s no separate allocation or separate address for the “arr” variable (non-existent). The “arr” is just a name in source code.

Advertisements

sell-side on the FX Vol market

Backgrounder — The traditional meaning of a “sell-side” is basically a player who makes a living
– by commission or
– by earning bid-ask spread (market makers),
– but no insurance premium.
Such a player provides liquidity to the market and seldom consumers liquidity. In so doing they provide a valuable service to the market and are rewarded. In a sense, they sell liquidity.

I now think of fx options as even more like insurance than equity options. There's economic need for fx options. Demand comes from mostly (MNC) corporations. They buy this insurance because they need protection.

Since fx options are insurance, it's natural to classify the participants as sellers and buyers. I guess some big players in this market stay primarily on one side only. (Some banks may need to pay insurance premium just for hedging.) If that's true then the “sell-side” concept can be adjusted to mean players who make a living selling insurance who seldom buys the same insurance except for hedging.

The mainstream sellers are banks. If the interbank bid-ask vol spread is narrow, then these sellers will have little restraint from frequent buying/selling.

Compared to corporations, is there an even bigger category of buyers in the fxo market? I don't think so. I have no statistics, but I believe corporations are the most stable client base for the banks.

I think the commodity options (or options on futures) market isn't that active, but these option sellers are, likewise, insurers to provide for an economic need.

c++ uninitialized "static" objects ^ stackVar

By “static” I mean global variables or local static variables. These are Objects with addresses, not mere symbols in source code. Note Some static objects are _implicitly_ static — P221 effC++.

Rule 1: uninitialized local and class fields of primitive types (char, float…) aren’t automatically initialized. See [[programming]] by Stroustrup.

Rule 2: uninitialized local or file-scope statics are automatically initialized to 0 bits at a very early stage of program loading. See https://stackoverflow.com/questions/1597405/what-happens-to-a-declared-uninitialized-variable-in-c-does-it-have-a-value

Rule 3: all class instances are “initialized”, either explicitly, or implicitly via default ctor. Beware… Reconsider Rule 1 — is a field of primitive type of the class initialized? I don’t think so. Therefore, “initialized” means a ctor is called on the new-born instance, but not all fields therein are necessarily initialized. I’d say the ctor can simply ignore a primitive-typed field.

Uninitialized static Objects (stored in BSS segment) don’t take up space in object file. Also, by grouping all the symbols that are not explicitly initialized together, they can be easily zeroed out at once. See
http://stackoverflow.com/questions/9535250/why-is-the-bss-segment-required

Any static Object explicitly initialized by programmer is considered an “initialized” static object and doesn’t go into BSS.

P136 [[understanding and using c pointers]] uses a real example to confirm that a pointer field in a C struct is uninitialized. C has no ctor!

P261 [[programming]] by Stroustrup has a half-pager summary
* globals are default-initialized
* locals and fields are truly uninitialized …
** … unless the data type is a custom class having a default ctor. In that case, you can safely declare the variable without initialization, and content will be a pre-set value.

standard practice around q[delete]

See also post about MSDN overview on mem mgmt…

  • “delete” risk: too early -> stray pointer
  • “delete” risk: too “late” -> leak. You will see steadily growing memory usage
  • “delete” risk: too many times -> double free
  • … these risks are resolved in java and dotnet.

For all simple scenarios, I feel the default and standard idiom to program the delete is RAII. This means the delete is inside a dtor, which in turn means there’s a wrapper class, perhaps some smart ptr class.

It also means we create stack instances of
– the wrapper class
– a container holding the wrapper objects
– an umbrella holding the wrapper object

Should every departure/deviation be documented?

I feel it’s not a best idea to pass a pointer into some cleanup function, and inside the function, delete the passed-in pointer. What if the pointee is a pointee already deleted, or a pointee still /in active service/, or a non-heap pointee, or a pointee embedded in a container or umbrella… See P52 [[safe c++]]

1 or 2 nameless classes generated for each yield block

If a (possibly static) method or getter has “yield”, then I call it (loosely) a “yield method” — officially an “iterator-method”. A yield method must return aa) IEnumerator or bb) IEnumerable.

–aa) If a “yield-method” has return type IEnumerator, then exactly 1 unnamed class generated. The yield-method return value is an instance of this unnamed class.

* This class implements IEnumerator

–bb) If a “yield-method” has return type IEnumerable, then 2 unnamed classes. The first (outside) class implements IEnumerable, so the yield-method return value is this type. This outside class implements the mandatory GetEnumerator() method returning an IEnumerator. GetEnumerator() return value is an instance of the other (inside) class.

* the 1st class implements IEnumerable

* the 2nd class implements IEnumerator

Here's a potential confusion. Say you write an IEnumerable subclass. In it you write a GetEnumerator() returning an IEnumerator. Is this the aa case or the bb case? Actually aa.

Q1: when is such a class instantiated?

A: every invocation of the yield method would instantiate an instance of 1 or 2 classes. The IEnumerator object is stateful, so you hold on to that object throughout the iteration. You don't call the yield method 55 times to hit the 55 items — you call Current/MoveNext 55 times.

Q2: but when exactly is the yield method invoked?

A: Invoked at the initialization of the foreach. The only way to use a yield-method is a foreach loop.

See P101 [[c# precisely]]

c# variable naming convention

Without a context, these identifiers all look indistinguishable.

Argument passed in? arg_
Local temp variables? tmp_
Fields? Just qualify it with this.field1 or MyClass.field1
Events? Just qualify ith with this.event1 or MyClass.event1
Properties? CapitalizeFirstLetter. Actually, these are primarily used outside host class. In such cases they are fairly identifiable.

gym scheduler #greedy#Junli

I find this algorithm extremely simple but not easy to recognize. The extreme simplicity indicates some important/valuable tip but not sure what.

Write a scheduler for a single gym equipment(like a room). Every morning at 8am before start of day, we receive a batch file containing all booking requests for that day. We run the scheduler once, and all accepted bookings are confirmed and finalized. Each request is identified by a pair of start/end times on the current day. No 2 requests share the same start/end times (perhaps because the duplicates are already filtered out). Exercise duration is in blocks of 1 minute. We earn $1 rental for each session regardless of duration.  Optimization goal is to allocate as many sessions as possible. We don’t care idle time; it doesn’t cost us. Let’s say the candidate for the “optimal” allocation plan is PlanK.
—–solution——
Pick the booking that ends earliest. Alternatively, pick the booking that starts later than all others.
(I feel this is not a dynamic programming algorithm, but a greedy algorithm.)

If there’s a last-minute user (4.59pm – 5pm, let’s call it AA), then it’s always good to accept. This last minute user AA doesn’t block others. AA is a minimum-hindrance session.

If PlanK ends with any other session (call it BB), BB surely starts before 4.59pm. BB is a bigger hindrance than AA is. If we replace BB with the last-minute user AA, we would produce a “safer” plan – PlanL. PlanL is at least as optimal as PlanK, and can potentially /accommodate/ additional sessions. Therefore PlanK without AA isn’t the optimal. The optimal plan ought to include the last-minute allocation.

That’s the key to the optimization. The last-to-begin session has minimum hindrance and should always be selected. After that selection, eliminate all requests that are now hindered. Then among the remaining  requests, look for the last-to-begin.

———-
Exploiting symmetry, you can reverse the algorithm by picking the first-to-end session.

wpf commanding – web of references

Too many cross-referencing in the commanding architecture. I'd say ignore the conceptual and focus on a typical implementation. Even

at the implementation levle, Commanding involves a web of references — non-trivial.

command source (typically a visual) often not always defines a command property and a command target property.

command target (typically a visual) often not always defineds a command binding and command handlers/reactors.

UI thread restriction in wpf/winforms, briefly

This is a popular question, and also an interesting question, for the curious. [[More effective c#]] says there are 2 reasons why we need Dispatcher or ControlInvoke —

1) STA — windows controls including those in .Net use COM Single-Threaded-Apartment model
2) message pump – the author said “many” (I would think all) of the controls use the message pump

http://stackoverflow.com/questions/2222365/what-is-a-message-pump has interesting comments on both 1) and 2)

Weiner process, better understood in discrete time

[[Hull]] presents a generalized Wiener process

dx = a dt + b dz

I now feel this equation/expression/definition is easier understood in discrete time. Specifically, x is a random variable, so its

Future value is unknown so we want to predict it with a pdf (super-granular histogram). Since x changes over time, we must clarify

our goal — what's the probability distribution of x a a time t a short while later? I feel this question is best answered in

discrete time. So we throw out dt and dz. (As a Lazy guy U don't even need delta_t and delta_z).

Let's make some safe simplifying assumptions : a = 0; b = 1 and last observation is x = 0. These assumptions reduce x to a Weiner

variable (i.e. x follows a Weiner process). At at a (near) future t units[1] away, we predict x future value with a normal

distribution whose stdev=sqrt(t).

[1] time is measured in years by custom

Now, What if I want to estimate the rate of change (“slope” of the chart) i.e. dx/dt? I don't think we can, because this is stoch

calculus, not ordinary calculus. I am not sure if we can differentiate or integrate both sides.

linq – a scratch seeking an itch

The more I read about linq2collection, the more convinced I feel that it’s not strictly necessary. Old fashioned for-loops are
cleaner and easier to read. Exception handling is cleaner. Branching is cleaner. Mid-stream abort is cleaner.

A linq proponent may say OO was not strictly necessary (compared to procedural), and relational DB was not strictly necessary
(compared to non-relational DB) but offer real values and so is linq. Here’s my argument, focusing on linq2collections.

– I feel this is a local implementation choice, not a sweeping, strictly enforced architectural choice. As such, a particular method
can choose not to use linq.
– Another comparison is ORM. Once ORM is chosen in a project, you can hardly choose not to use it in one particular method. Linq is
more flexible, less enforced and more “sociable”.

A java guy has no such tool but is perfectly productive, until java 8 streams…

I feel linq gained mindshare on the back of c# success. If F#, python or delphi invents such a cool feature, it would remain a niche feature. I don’t see another language embracing linq, until java 8

Neverthless, we must master linq for the sake of job interviews. This is somewhat comparable to c++ multiple inheritance – not used
widely but frequently quizzed by interviewers.

100-lightbulb problem, with my solution

Q: There are 100 switched-off light bulbs along a staircase. Visitor #1 walks upstairs, pushing the on/off switch at each bulb. Visitor #2 walks upstairs hitting bulb #2,4,6…100. Visitor #3 to #100 each walks upstairs. In the end how many light bulbs are on? Can you tell me which bulbs are on? Can you tell me how many times each bulb has turned on?

For each integer between 1 and 100, factor it into “prime” factors. For eg, 72 = 2x2x2x3x3. Each integer is then expressed in the “Beautiful” form like A^n x B^m x C^p… where ABC are increasing prime numbers and nmp are exponents. For eg, 72 = 2^3 x 3^2.

Now (n+1)(m+1)(p+1)… is the number of “toggles” received by the light bulb. For eg, Bulb#72 gets 12 toggles. Bulb 10 gets 4 toggles (due to 2^1 x 5^1). Bulb 13 gets 2 toggles (due to 13^1).

Now let me defined Group-E and Group-O —
If (n+1)(m+1)(p+1)… is even, then the light bulb is in Group-E.
If (n+1)(m+1)(p+1)… is odd, then the light bulb is in Group-O.

Now, (n+1)(m+1)(p+1)… is usually an even integer. It’s odd only if n,m,p… are all even — for eg Bulb#4, #64, #36, …– Group-O. It’s easy to list all of them.

2^2,  2^4,  2^6,  3^2 , 3^4,  5^2,  7^2
2^2×3^2,  2^2×5^2

For all the “prime” bulbs like #2, #3 … #37…, the beautiful form looks like A^1, so these prime bulbs each gets 2 toggles exactly. Therefore Group-E.

Special cases — Bulb #1 gets togged only once — Group-O.

It turned out Group-O is the group of square numbers.

wpf data binding – target Object holds the binding

One ticker (like the SPX last move direction — up or down) can drive 22 visuals controls. Each visual control is a target objects

and can have only one driver. In this case, there would be 22 binding Objects for the 22 linkages.

The binding object is injected into the target object, not into the source object. The single source drives 22 targets, so it can't

accept and hold 22 binding objects.

Remember both source and target must be properties. Therefore, one source Property drives 22 target properties. 2 of the 22 target

properties might belong to the same visual control (since one visual can have many properties like font, background…), but it's

not likely. Usually, the 22 target properties belong to 22 visual controls.

Incidentally, the source may not be a visual and may not exist on xaml. It could be a plain old property of a plain old object, but

this object needs to be visible to xaml, so xaml can bind to it. Alternatively, it can be visible to the code behind, so we can set

the binding in code behind.

LINQ – narrow moving window

Which part of linq operates this way??

—–
Imagine you can only use 1 unit of memory…. You get the narrowest possible moving window (size 1) over the “stream” of items. You can’t query how many items in total — You have to remember the past items. You can’t query the sequence for a past or future item.

I feel this is similar to SAX parser…

I feel this is similar to database drivers. When you iterate the rows from a large query, the server gives you one row at a time.

It also reminds me of the c++/java/c# stream concept, but streams consist of bytes not “composite, structured objects”

func^var in header files

Many authors describe a single set of rules for func declaraion vs variable declaration in header files. However, for some beginners, it might make more sense to assume the rules are largely independent and unrelated between func vs var.

Note I will use “include file” and “header file” interchangeably.

The word “static” is heavily overloaded and confusing. I will try to avoid it as far as possible.

(Perhaps because function in header files are implicit global) We are more familiar with the rules on functions
– Rule: each some.cpp file that uses a shared func1() must have func1 “declared”. Best done via include file.
– Rule: across all the .cpp files, there must be exactly 1 definition of func1, otherwise linker complains. Consequently, this must go into a non-include file and seen once only by the linker.

——global variables——-
Let’s start with a big Backgrounder (because it’s rather confusing) — Let’s ignore fields of classes/structs and just focus on classic C variables. The most common and most simple variables are local to a function — function-scope static/non-static variables. The other variables are essentially static-duration variables[1]. A simple type of non-local variable is a file-scope but unshared variable. It can be used across functions within that single file, but here we are interested in global shared variables. I think there are various categories but as hinted in the rather authoritative [[essential c++]] P53, most common is a file-scope static var. The way to globalize such a variable var2 is

Rule: use extern in an include file, so every .cpp file will “see” this extern declaration of var2
Rule: in exactly one .cpp file, define var2 without “extern” or “static”

[1] Someone said online “A local variable is a variable that is declared inside a function. A global variable is a variable that is declared outside all functions“. Scott Meyers discussed “non-local static variable”.

—— static field eg sf2 ——-
See also post on static Field init, and P115 [[essentil c++]]
Usually must be defined exactly once outside class Declaration (which is part of include files). Somewhat similar to shared global variables.

Rule — each some.cpp file that uses this field must have it “declared”. Best done via include file.
Rule — across all the .cpp files, there must be exactly 1 definition of this field. Consequently, this must go into a non-include file and seen once only by the compiler. The field name should be prefixed with the class name, but with the “static” keyword.
Rule — NO “extern” please.
Rule — (special) — const static Integral field can be initialized (not “defined”) in the declaration. See
http://stackoverflow.com/questions/370283/why-cant-i-have-a-non-integral-static-const-member-in-a-class. But watch out for http://stackoverflow.com/questions/3025997/c-defining-static-const-integer-members-in-class-definition

5 business models in investment banking

Hi Yi Hai,

Upon your suggestion, I watched many Tim's videos including this one (http://www.youtube.com/watch?v=xlYDonZLoHg&feature=endscreen) about the 5 business models in investment banking. Very good framework. I have a few inputs to add on his 5 items —

1) prop trading
2) market making
3) M&A
4) Underwriting
5) structured products

1) is the only BuySide business model among Tim's 5 items. In many investment banks, there's actually another buy-side business unit in the form of asset management. They often run big mutual funds and hedge funds.

2) is not the only way a investment bank makes money on the Security markets. Most of them also provide trade facilitation and market access to their big clients. A 3rd major business in this domain is block trading. A big client hoping to sell 500,000 shares of IBM would send the RFQ to 3 investment banks. Once UBS provides a quote and gets selected, it must execute at the agreed price (even if at a loss, if market moves quickly against it.)

5) SP is not a separate business unit in many investment banks I worked with. I guess each trading desk often has a structured product team. Tim made me realize this is probably a 4th business model under the umbrella of Securities business. In Singapore, a lot of commercial banks sell structured products to consumers and businesses, but there could be an investment bank behind the scenes doing the structuring.

3) Besides M&A, there are privatization deals, spin-off deals, Management-Buy-Out deals etc. Very often the advisory bank must lend money to the client.

4) Tim actually used the term “new issue”, including bond IPO and stock IPO.

In addition, Prime Brokerage is another big business for many investment banks. The PB department often brings business to the Securities department (since the hedge fund clients often sends in orders) but PB revenue is more than that, based on what I heard.

variance is additive, explained briefly ] %% own words

In 2012, I told an option pricing interviewer that variance is additive along the time horizon. Important statement worth a closer look. Here are some necessary conditions

* 2 consecutive periods
* independent
* normal distribution

See P281 [[hull]]. In my own language, Suppose we denote the 1year-from-now value of a variable (say, temperature in New Oleans) as A1. (think of log return…) We aren’t so interested in A1 as A1-A0, denoted X_01. We can assume X_01 has a normal distribution so X_01‘s histogram (simulated) is bell-shaped. Mean 0 variance assumed 13.

Consider X_02, defined as A2-A0. This is viewed as 2 consecutive PROCESSes, each over a year. Identical and independent. X_02 is therefore the sum of X_01 + X_12, two variables of normal distributions. This sum is therefore another normal distribution with mean = 0, variance = 2 * 13.

variance of 2 iid variables is twice the individual variance.

Stdev is therefore 13*√ 2 .

geometric distribution – basics illustrated

This is prerequisite of Geometric Brownian Motion.., but this is a Distribution whereas GBM is a Process.

Based on http://en.wikipedia.org/wiki/Geometric_distribution

Keep rolling a dice until you get a 6. Record the number of rolls required (X) in a log book, and repeat the game to get another X, and another X…. X follows a geometric distribution. Discrete, so histogram shows —
Height of Bar#1 is 1/6
Height of Bar#2 is 1/6 x 5/6 i.e. the likelihood of X = 2
Height of Bar#3 is 1/6 x 5/6 x 5/6

Height of Bar#99 is 5^98 / 6^99 a very small number.
….
Each bar is shorter than the previous bar, i.e. 83.3%
Total lengths must add up to 1.0

This histogram completely describes the distribution of the discrete random variable X. From this histogram we can derive the Expected, variance, stdev etc.

Not intuitive (better internalize), but E(X) = 1/p and is 6 in our case.
——————
Many everyday probability problems involve GD. Many quant interview questions involve some GD but sometimes much harder than GD. It pays to have a firm grounding on the basics of GD.

Why call it “geometric”? Because each bar is 83.3% the height before. If you space out the bars equally, it’s a gentle down-slope.

2 important predecessors to c++11 thread API

One of the committee members behind the c++11 thread api said in [[c++ concurrency in action]] that Boost::thread has been used as the primary reference for the standard api, although the latter includes non-Boost features, notably atomic operations.

The 2nd strongest influence among the early cross-platform thread libraries is ACE.

3rd influence? Perhaps MFC, but I'm not sure.

## most popular base threading libraries

win32 – on windows
Pthreads – on *nix

Traditionally, these are the 2 most important among the base thread libraries. Unsurprisingly, all the base thread libraries are in C. As explained elsewhere on my blog, there’s no reason to package these libraries in any other language. C is the clear, overwhelming favorite.

 

http://stackoverflow.com/questions/30816307/does-java-jvm-use-pthread confirmed that jvm uses pthreads on linux and macOS

transformer blackboxes in linq

A lambda used in Linq is often a transformer function, or a converter or lookup or mapper or translator function.  All of these words describe the same generic blackbox having exactly 1 input object and 1 output object.

The 1 input object is carried by the range variable in Linq. Output can be a field of the input. Output can be another object (perhaps of anonymous class). Output can be a true/false flag…

Many Linq sequence operations “Apply a Transformer On” the input sequence.
eg: Where() applies a filtering transformer on the input sequence
eg: OrderBy() applies a sorter transformer on the input sequence
eg: Select() applies a one-to-one mapping transformer from input sequence to an output sequence

— OrderBy() —
Comparitor.java takes *2* arguments and returns a comparison result. Ditto for comparitor in STL sort(). Linq OrderBy() is a bold departure.

OrderBy() looks more like SQL order-by, specifying a sorting “key-field”.

This is the Hollywood principal like spring RowMapper. Inernally, the sorter (“the Hollywood”) will pick 2 elements from the sequence and compare that key-field to decide who wins….(imprecise language, admittedly). The only info needed by Hollywood is “which (pseudo) field to use for Ranking items”. A crude example — You can rank companies by reputation, by popularity, by profit … OrderBy() answers that question.

Therefore OrderBy accepts a transformer blackbox with 1 input i.e. the range var , and 1 output i.e. a “key” pseudo-field. Actually the field can be any value computed from fields of the input object.

SERVICE means … in WCF, SOA etc

The concept of Service is central to wcf, but the “service” word is overloaded and vague. Here are a few distinct meanings

* windows service – daemon process. I think a unix network daemon is similar. However many windows services and unix daemons aren’t exposed to the network

* web service

* a remote callable [1] thingy, like a RPC. Any remote callable would qualify as a service!
** I feel web service qualifies as a type of of rpc service.
** a network daemon qualifies too.
** I feel in wcf, “service” means something like this.

Remote means you don’t call it like calling ToString() or localtime() within the same process.

Callable means on-demand, online, like a 24-hour call center, ready to serve callers.

How is it implemented? A base form is a Function or Procedure, but frequently there are “service OBJECTs” involved. In fact, the service objects are in the official Model of a service;) but I actually feel these objects are unnecessary to the basic concept of service. Nevertheless, “Service”, WebService, and SOA are big buzzwords, and these people just love the OO jargon. I feel these jargon terms add confusion without adding value. Too much abstraction can lead to health problems;)

In WCF, there are many jargon phrases containing “service”, which is a central concept in WCF.
* service host — the Process hosting the service.
* service reference — just a fancy name for the proxy class.
* ServiceEndpoint

c#Reuters database IV

Database Question

Table E
=========
int id
string empType
string email
string firstName
string lastName

indices:
======
CLUSTERED (id, empType)
UNIQUE(id)
UNIQUE (empType, id, firstName)
DUPLICATE (empType, firstName)

Table E has: 10,000,000,000 rows

Table E has: one row with firstName “bettlejuice”

Table E has: 1,000,000,000 rows with empType = ‘fulltime’

SELECT * FROM E WHERE email = ‘foo@example.com‘;

SELECT * FROM E WHERE id = 100 AND firstName = ‘beetlejuice’;

SELECT * FROM E WHERE empType = ‘fulltime’ AND firstName = ‘beetlejuice’;

SELECT * FROM E WHERE empType = ‘fulltime’ AND firstName = ‘beetlejuice’;

How many pages for leaf nodes does the above query read?

INSERT: Writes how many pages?

SAM interface^lambda, across 3 languages

(In this discussion I suppose it’s probably OK to ignore the multicast feature of delegates.)

update — see java lambda and Single-Abstract-Method interface on http://www.oracle.com/technetwork/articles/java/lambda-1984522.html

I used to feel a (unicast) delegate TYPE is quite similar to a SAM interface. Now I doubt it.

C++ has abstract classes. When all the methods are pure virtual, that’s an interface (as in java). In this tradition, an interface is typically implemented by a Stateful class. Most textbooks and most schools introduce interface of this kind. What if the implementation class is stateless?

(To keep things simple let’s suppose there’s just 1 method.)  Then the objects needed by the method must be passed in. This feels like a static utility method without the static keyword. Such an interface is quite a different animal from the traditional interface. A non-capturing Lambda is the best example. But also
– static nested classes in java
– anonymous delegates

Where c# API uses a lambda, java often uses a SAM interface, since Java didn’t support lambda until Java 8.

I feel in both c# and c++, lambda is often used as a function argument (not “parameter”). Imagine you have a method parameter whose type is an SAM interface,
– and this interface has just 1 (or few) implementation(s)
– and the instance of this implementation class is basically stateless,

then this SAM parameter is probably a lambda trapped in an SAM. C# 3.0 and c++11 would set it free.

untold horror stories in Microsoft dev environment

Other horror stories:

* http://weblogs.asp.net/psteele/archive/2007/01/31/windows-service-stops-updating-event-log.aspx
* http://blogs.msdn.com/b/saurabh_singh/archive/2009/01/30/getting-fatal-error-lnk1181-cannot-open-input-file-kernel32-lib.aspx
* In my projects, logs folder can become inaccessible even though no one but my own services were touching it.
———
http://mariusbancila.ro/blog/tag/regasm/ looks like a typical horror story about Microsoft development platform.

– too many binary files involved. In unix environments ascii is the format for most files developers need to deal with. I feel from the beginning unix favors ascii. That tradition has endured the test of time and is going strong. I feel ascii is Clean and efficient. If a platform must use so many binary files, it’s a sign of weakness and non-ideal design. Simplicity is not easy to achieve or maintain. Look at copy-paste.

– outcome depends too much on the idiosyncrasies of the IDE. In unix-like environments, all the standard dev tools are command line tools, usually more transparent than a GUI tool.

– environment dependency and esp. the Mysterious Monstrous Murky registry — the worst problem IMO. It’s a local environmental config that’s pretty invisible. That means the same source code compiled on another machine may not behave the same. Even if you copy everything to another machine it may behave inconsistently.

– The platform is not robust enough. You may say it’s all developer’s fault, being inexperienced with the platform and tools. Well, I have substantially fewer such problems on other dev platforms. I’d venture to say a unix veteran hits fewer such problems than a windows veteran. If you follow the standard procedure and hit this kind of roadblock, it’s disappointing and stressful. This platform tends to throw up too many such roadblocks. Other platforms are more consistent and robust.

Look, every dev platform has complexity under the hood. As a higher-layer app developer we shouldn’t need to know a lot under the hood. The platform should be robust and just work. When we are forced to look under the hood, usually it’s a premature, unprofessional dev platform. As a 3-year old eclipse user, I  feel eclipse is such a premature tool, but other tools in java land are simpler and very robust.

This story also reminds me of my very first programming project in Microsoft dev environment. It’s a VBA project. Some basic FTP functionality was rather hard to implement. The MS-supplied infrastructure was not fully documented. Took several false starts. I soon left the MS platform for greener pastures — LAMP, javascript, unix, java, … and never looked back. Notably, Mysql had the best documentation and no surprise.

A recent project experience is again similar. We just couldn’t get auto update to work on a SL-OOB application. Auto-update once worked but now stopped working. What changed? We checked all the known issues… mystery, opaque, hidden under the hood, undocumented.

WCF ^ remoting, briefly

WCF and the remoting technologies are related. I feel both are umbrella technologies. Both nebulous. Both having a lot of abstract concepts and jargon.

I feel remoting as a concept is like RMI (or ejb?), but remoting as an umbrella technology also can use soap.

WCF is designed as a superset of remoting. In addition to TCP and HTTP channels, wcf added MSMQ channel and a considerably faster named pipes channel.

WCF and Remoting can coexist side-by-side.

See http://msdn.microsoft.com/en-us/library/aa730857(v=VS.80).aspx

where does the q[&] belong: ref declare^address-of

1) & appears in declarations reference variable.
2) & appears outside a declaration address-of

When dealing with references, the “&” should go with the data type, not the variable name. I’d suggest move the space to the right side of &, as in

T& var

You can see this clearly in typedef statements.

You see the & only in the declaration. Afterwards, you never see it.

Read it backwards …
—–
When used as address-of, obviously the & goes with the variable or function. I’d suggest move the white space to the left side of &.

Note the address-of is an operator. You can even overload it

No comments about other uses of &

ICommand instance CAN define actual action

When The MSDN article talks about ICommand, it only talks about one subtype i.e. the RoutedCommand. For RoutedCommand, the command instance doesn’t contain actual action, as echoed by other authors, but I am not sure if that is true across all ICommand implementations.

I think It’s possible to implement ICommand with a real Execute() method. See [[wpf succinctly]]