event handlers s/d be defined in VM !! code-behind

Update – this is the pre-Commanding perspective. In the Commanding paradigm, everything changes.

Event handling logic should ideally be in VM, but VM source code should not mention view objects. See post on model depending on view.

Many xaml developers put event handlers in the code behind the xaml. This is the “lazy” alternative. The code behind is an integral part of the view layer IMO. Its source code mentions numerous view objects.

Code behind also makes liberal use of vm objects (V is over VM). Therefore this class is the perfect melting pot of V and VM. Event handlers and other glue logic can be implemented more easily in code behind than elsewhere.

However, what is too easy is often too easy to be good. Throwing every bit of glue logic into one big class is poor modularization, poor separation of concern, poor layering. As an alternative, it’s probably wise to
move as many event handlers as possible out of code behind into the VM, esp if the handler action affects only the VM.


a WPF "command" is … a princess

(Consider also RequerySuggested)

Q: what is a command in wpf?

Best answer is found in the ICommand interface — a command Instance must offer
1) an Execute() method,
2) a capability-query method CanExecute(). It’s also a status-query method.
3) an event notification scheme, in the form of an event-pseudo-field CanExecuteChanged.

Today let’s focus on 3). I believe this event enables the infrastructure to adjust the appearance of the buttons/menus linked to the command

3 describes 2; 2 describes 1.

I say CanExecuteChanged is a “scheme” because the underlying plumbing is non-trivial to a java/c++ guy, but plain vanilla to a c# guy. To understand this scheme, we must first get a good grip on event-pseudo-field — a bunch of callback functors. See http://bigblog.tanbin.com/2011/09/an-event-pseudo-field-wrapper-over.html.

In the CanExecuteChanged context, when the command’s status switches between Enabled/Disabled or between CanExecute and CannotExecute, this event is raised. An (ordered) list of callbacks get invoked.

Each callback holds 2 pointers, one referencing a callback method, the other referencing its host object. Some people say …
Each callback holds 2 pointers, one referencing a Receiver object, the other referencing a method therein.

One of the things each callback does is to query the command instance via CanExecute(). Therefore, the CanExecuteChanged event is an invitation to “call me for my current status”. Command is a young princess with an army of suitors. They want to know when she’s available for dating. Once a while she sends an open invitation to “call my hotline to ask for my availability” — the princess has a dedicated hotline (CanExecute) to answer that query.

VaR — estimating portfolio value if there’s a downtown


Let me rephrase my last question at Newark. Say our IBM position has current market value of $1m. We want to know the likelihood of losing more than 100k in the next 2 weeks. We can use IBM stock volatility stats to compute the likelihood to be… say 5.5%. Meaning we have a 5.5% chance of losing $100k or more in 2 weeks.

Now the portfolio holds SUN stocks too. Current MV = 1m of IBM + 2m of SUN = 3m. What's the likelihood of losing $300k+?

First assume SUN and IBM are unrelated. The volatility of the portfolio can be computed based on the 2 volatility stats. We can then derive the likelihood of losing $300k+ as … say, 6%. We have a 6% chance of losing 300k ore more in the next 10 days.

In reality IBM and SUN stocks are correlated. I guess portfolio volatility can be adjusted based on the covariance.

Option valuation volatility is very similar to stocks, i guess? Reason — Probability distribution curve is very similar?

Makes sense?

let’s find out What the system is doing

A real, practical challenge in a low-latency, market-data system is to quickly find out “What’s the system doing”. Log files usually have a lot of details, but we also want to know what files/sockets our process is accessing, what kind of data it is reading and writing.

truss -s or -r can reveal actual data transferred(??)

if write() syscall is stuck, then perhaps disk is full.

lsof reads /proc to get open sockets/files


field-like event syntax restrictions

— based on http://www.ikriv.com/en/prog/info/dotnet/Delegates.html
All events (Field-like or not) always support 2 operations += and -=. You can call them sub/unsub or add/remove.

An event is always a non-static Member of a class. IF compiler accepts your event as a field-like event, then it will accept 2 other operations on it
a) MyEvent != null or == null
b) MyEvent(….);

Internally, these were translated to refer to the hidden private Dlg field generated for every event.

Now, a couple of implications
! subclass can’t use (a) or (b) since the hidden field is private
! You may see (a/b) quite often, but if your event is not field-like, they won’t compile.

##java trading interview topics

* annotations? I don’t know why so often asked
* multi-threading
* concurrent data structures
* thread pool
* deadlock prevention
* deadlock investigation
* wait-notify, synchronized
* dependency injection. I don’t know why so often asked
* garbage collection
* singletons
* serialization, externalization(??), probably needed for stream messaging
* generics
* immutable
* deep copy — needed for serialization and cloning
* producer/consumer

##java survival skills in a trading system?

* java/javac command line options
* null pointer prevention
* familiar with ide, esp. (remote) debugger
* familiar with logging tools/techniques to simplify logging to the extreme
** add logging without impacting existing code.
** tracing proxies?
* lots of asserts
* jconsole* get compiler to help prevent potential issues
* memory profiler?
* thread dump analysis
* sound concurrent architecture (high-level) to(low-level) idioms
* spring

Other survival skills/toolkit
* cvs familiarity
* lsof, tcpdump
* core dump analysis
* system memory investigation? never seen such a need
* unix scripting? probably
* vi, find, grep…

calling super.method1()

Use case: C.java extends B.java. Both defines a non-static m(). In C’s instance methods including C’s m(), and C’s constructors, you can write super.m(). For the justification, consider toString(), hashCode() and equals().


Suppose we have an object B b = new C() and C c =new C()


Illegal use case: calling c.super.m() from another class.


Conclusion: super.m() ie the parent’s version of m() is only accessible from the child’s methods.

hard-to-replace talent in financial IT: tech^dnlg^mgmt@@ #GS

What’s valuable and hard to replace in financial IT? Is it

1) technical know-how or
2) management skill or
3) domain knowledge?

I feel managers usually earn more salary. The more hands-off, the more salary. Problem is the political skill required, which I don’t have. Leadership is a combination of technical, domain knowledge and ….what I call people skill.

Technical and domain knowledge is real “knowledge”. These are like history or geography knowledge — if you know it, then everyone agrees you know it. If you don’t know it, you can’t pretend for too long (like Emperor’s new dress). As you can sense, I’m a big fan of tech and domain knowledge.

In GS, tech know-how is considered easily replaced. Find a fast learner. Throw him into the water and he becomes an expert in 6 – 12 months. I took 1.5 years. In other I-banks, tech know-how helps you keep your job. If you are the only system expert then employer won’t touch you.

In GS (my department) , 2) and 3) make a valuable combination. They feel such a person is hard to find. If necessary they would keep such a “manager” and replace all the hands-on developers under him. They believe this manager can then train up a new crop of developers.

counterparty to both seller and buyer

Say Bill Gates wants to buy something at $2m and S’pore government wants to sell the same thing at $1m.


In Equities, both buyer and seller can discover the last trade price. I think some exchanges also publish order books. Both seller and buyer will adjust their prices.  Not much of a bid/ask spread exists in such an open and liquid market. When filled, I guess buyer and seller know the counterparty.


In muni and other illiquid fixed income markets, bid/ask spread is large. Often the dealer acts as counterparty to both sides when he sees an arbitrage opportunity. Buyer and seller don’t know who they traded with – they each trade with the dealer.


In an illiquid market, dealer can also buy and hold. Car dealership model.  Again, dealer is counterparty to both sides.

wait/notify, yield and green thread

(taken from some website)

Scheduling is more of a worry for programs with green (simulated) threads that run in tight loops or that spend significant amounts of time running mathematical computations with no I/O. In those cases, a simple call to Thread.yield() is enough to give other threads of the same priority a chance to run.

To share the CPU with a lower-priority thread, a thread can call Thread.sleep() or, more precisely, call wait() on an object until the low-priority thread signals the end of its run by calling notify() on that object.

web skillset to keep our head above water

Outside trading domain, web (including spring MVC, dotnet, PHP, SOAP, ajax) is the mainstream technology. If we want to easily find a job in S’pore or US or China, then invest in web skillset.

Some Recruiters in trading are a bit arrogant. They don’t want to see web skillset on the CV.

I agree that at present (Jun 2010) most core trading components don’t use web, due to performance considerations.

By the way, more developers now are versatile in both java and dotnet. I think soon lots of resumes will start talking about “5 years java, 5 years dotnet, x years oracle, x years multithreading…” I was seen as a weak candidate for many years on the Singapore market because I had limited Oracle or Java experience.

buying a mortgage, buying an income generator

In MBS/ABS/CommercialPaper trading, people talk about selling and buying a mortgage. Let’s get comfortable with the concepts.

A bond is an *asset* because it generates (stable) income. What if i want to “buy” the movie revenue of a cinema? I buy it by lending money to the cinema.

If you see a student loan as an income generator, you can buy it from a bank as a “bond”. Think of it as a “personal bond”, issued by the student. Most students we assume are credit worthy so this income is
reliable, like treasuries.

When you sell a loan to an investor, you are selling an income-generator. Mortgage is special because it’s collateralized.

wrong way to look at option payoff graph

The at-expiration pnl graph looks stupid for a short call position i.e. when you write a naked call. The diagram shows limited reward but unlimited risk. Covered call is better but still limited-reward, almost-unlimited-risk. [1]

Why would anyone write a call? To answer that you had better compare the { PnL vs at-expiration underlier price} graph of short call vs a comparable strategy.
– Naked call-writing is comparable to a outright short position in the underlier.
– Covered call-writing is comparable to a outright long position in the underlier.

You will see that in many scenarios, the call writer profits more at expiration. If you have a view on the stock and its volatility, then you can take calculated risks writing a call.

[1] “Almost unlimited risk” basically means your position MV could drop to $0 meaning you lose all the money invested, which is a common downside. You get this “almost unlimited risk” whenever you buy a stock. What makes the graphs stupid is the “limited reward”.

In fact “unlimited risk” is common when you short anything.

drop-in replacement for a raw ptr – barebones

(see also my little post on auto_ptr implementation, and http://www.revergestudios.com/reblog/index.php?n=ReCode.SharedPtr) Any Smart pointer must be a drop-in replacement for a raw ptr. At the minimum this requires

– overload deref operator
– overload arrow operator
– when an existing func requires a raw ptr argument, you can pass in smart ptr — Implicit conversion by …. [1]
– when an existing func returns raw ptr, but you receive it in a smart ptr — Implicit conversion by …… [2]

Above the minimum, it needs
+ [optional] overload increment/decrement? This is indeed part of the drop-in deal. Not easy. Not widely implemented.
+ ctor, dtor, copier, op=
+ how about explicit cast between smart ptr and the corresponding [3] raw ptr? Not part of drop-in replacement.
+ overload address-of operator? I feel no need
+ overload reference to the smart ptr? I feel no need

However, there’s a more stringent requirement that shared_ptr, auto_ptr don’t meet … same size as a raw ptr. Which smart ptr can achieve this? [5]

How about const_cast, dynamic_cast and upcast on raw pointer??

[3] smart ptr is parametrized so each concrete smart ptr type covers one type of raw ptr
[2] conversion ctor??
[1] operator-overload conversion method
[5] intrusive_ptr

dtrace/truss, ptrace /proc/sys basics

On freebsd, truss works by stopping and restarting the process being monitored via ptrace()
On Solaris, truss works by stopping and restarting the process being monitored via /proc. Dtrace doesn’t stop/start a process, therefore adds lower overhead.
/proc is readable by cat not less.
/proc is mostly readonly, but on linux /proc/sys is writable !

http://www.linuxjournal.com/article/2365?page=0,0 is good intro. Wikipedia says

By using ptrace (the name is an abbreviation of “process trace”) one process can control another, enabling the controller to manipulate the internal state of its target. ptrace is used by debuggers such as gdb and dbx.

By attaching to another process using the ptrace call, a tool can single-step through the target’s code. The ability to write into the target’s memory allows not only its data store to be changed, but also the applications own code segment, allowing the controller to install breakpoints and patch the running code of the target.

ptrace is available as a system call on AIX, FreeBSD, Mac OS X, Linux, and HPUX up to 11. On Solaris, ptrace is implemented as a library call, built on top of Solaris kernel’s procfs filesystem; Sun notes that ptrace on Solaris is intended for compatibility, and recommends that new implementations use the richer procfs.

y commercial banks also have trading systems

I just had a clue to this question.

In general, broker-dealers do trading; Investment banks raise money for clients; commercial banks lend money. (In reality, every investment bank also has a substantial broker/dealer operation, as the money-raising is done on the so-called “capital market”.)

So why do commercial banks (excluding the conglomerate universal banks) need trading systems? This is what I guess —

A commercial bank tries to provide a full service to its big clients. BoA (before merging with ML) was a traditional commercial bank but it also maintained client accounts holding fixed income and equities assets. To provide a more complete service, BoA also provided hedging, risk measurement and other services, making it a partial trading system.

However, I feel this partial trading system was probably not designed to make money for the trader. This partial trading system was more of an extension of the position system or inventory system.

equity drv, from an OTC options perspective

* listed options (standardized contracts) are guaranteed by the exchange. Exchange is the counterparty of every trade. You don’t need to know who the real counterparty is. Like futures, For every long position out there, there’s a short position for the same contract. Exchange takes no outstanding position. No default risk. OTC options have credit risk, so credit needs checking. Collateral is required.
* OTC option is custom made, rather than standardized. If you want a specific option (some strike price, expiry…) you ask the banks. They each spend some effort (won’t waste time if your order is small) to give you a quote.
* You might sell the option you bought. No restriction for listed. For OTC, your counterparty may disallow it. Remember it’s a bespoke bilateral contract.
* Are there more calls than puts? Possible.
** For every long call, there’s a short call.
** For every long put, there’s a short put.
* eq deriv instruments include exchange-listed options, OTC options (ie buyer and seller both come to a broker/dealer to trade????), index futures, futures on individual stocks, swaps, but not convertibles.
** eq cash and eq deriv are separate trading desks.
* OTC option trading has no low-latency requirement since there’s no exchange involved.
* Valuation (rocket science) is a shared module of option pricing and market risk.
* before an eq deriv trader places a trade, system lets her assess the aggregate risk exposure of the entire firm. Just like prime brokerage risk systems (GSS), EqDeriv Risk measures risk to the bank, not risk to the client. I think this means the bank is risking its own money, probably as a dealer not a broker.
* Futures contracts are obligations; options are one-sided obligations. How were financial futures invented? As hedging tools just like commodity futures. If your (short/long) position (in stocks or other assets) shows correlation to a futures, then the futures can reduce your risk, but also will limit profit potential. You can also use futures to lock in profit.

aqua studio tips

* Ctrl-D (menu bar -> Query -> Describe) — Quickly see table properties
* Ctrl-F12 (menu bar -> Window -> …many items..) — hide list of servers on the left to get more real estate. There are similar tricks to save real estate. See “many items” above.

* to copy paste many rows into a temp table, List of servers on left pane -> choose your server -> Choose your database -> choose your table -> Right click -> Edit Table Data (Top 1000). Works for muni but not tempdb

* to turn on auto-complete, try Ctrl-Shift-U and Ctrl-Shift-O repeatedly until 2 buttons near MaxResults are depressed. The 2 buttons are AutoComplete and AutoOnAllSchemas

* If you see too many databases along with “master”, try
** Server Property -> Filter -> Filter Databases -> Exclude all
** Included Databases -> enter “tempdb”
** List of servers on left pane -> choose your server -> Choose your database -> Ctrl-Q

delta of a stock option – on last days

For any call/put option
– ATM options (call or put) have delta close to 50%, so ATM option’s MV moves about 50c when underlier moves $1. [3]
– Deep ITM options have delta close to 100% (“100 delta”) , so it feels like a regular stock [1];
– Deep OTM options have delta close to 0  (“0 delta”). [2].
– Therefore, a trader uses magnitude of delta as approximate likelihood of expiring ITM. See P28 [[Trading Option Greeks ]]

You can see part of the reason in the curve of [Px (call option)  vs  spotPx(underlier) ] on P276 [[complete guide to cap mkt]]. ITM call’s slope is almost parallel to slope of a long stock. OTM call’s slope is nearly flat.

Before reading further, remember a trader observes fluctuations in underlier and in volatility level. Forgive my long-winded reminder – within an hour on the expiration day, market could exhibit a sudden increase in implied-volatility. New vol will impact delta, valuation, unrealized PnL.. until you exit.

My friend Chuck Kang, who traded options before, described that just before expiration (like the Triple-witching), option *premiums* jump wildly in response to underlier price moves. I can understand why in the case of a ATM option on a fairly volatile stock.

However, P31 [[Trading Option Greeks]] suggests that On the last days deltas diverge from 50% towards 100% or 0. The impending expiration pushes out delta.

[1] I feel timeVal doesn’t affect how _likely_ the option will expire ITM. A deep ITM is 99% sure to expire ITM, so a single lot of this option feels equivalent to 100 shares of underlier, either long or short. The MV consists of mostly intrinsicVal. Delta(intrinsicVal) is 100% for an ITM.

[2] I feel timeVal doesn’t affect how _likely_ the option will expire ITM. When underlier shifts up and down, the deep OTM option still shows no promise of expiring ITM. Delta(timeVal) is nearly zero. Delta(intrinsicVal) == 0 for an OTM.

[3] If an option is still ATM on its last days, then market doesn’t know whether it will expire ITM or OTM. Too close to call.

delta of a call vs put (ex-div

Simplified put-call parity stipulates {{ call =~= put + underlier }}. PCP holds true whether underlier (say MSFT) spot is $20, $22.2 or whatever. Remember delta is always measured with tiny changes around a particular value of underlier SPOT price, so let’s assume MSFT spot price is now $20 ,

delta(call) =~= 1 + delta (put)

(You derive this by taking the first derivative of each item in the equation.)

Since delta(put) is always negative, you can see that given identical strike prices, the _magnitude_ of delta(call) + delta(put) is roughly 100%. — worth remembering.

There’s a bit of tricky fine print for the undaunted. In reality, the 2 magnitudes sometimes add up to exceed 100% for American options. I was told the key reason is early exercise [2]. Since the 2 options have identical strikes, exactly one of them is ITM. Just before dividend, the ITM option (either the put or the call) would have a higher delta thanks to the dividend. If 99% of the players in the market agree this ITM should be early exercised due to the dividend, then IMHO 1 lot of this ITM option feels like equivalent to 100 shares of MSFT, either long or short. Therefore delta of the ITM is similar to 100%.

Q: on the day before ex-dividend day, does the ITM option’s delta approach 100%?
A: I was told yes.

[2] there are other reasons like interest rate.

consistency vs liveness — 2 concurrency issues

2 main risks of concurrency: consistency ^ liveness

([[concur programming on windows]] also singles out these 2 “hazards”)

Concurrency risk with collections? Race condition (inconsistency problem) is the main risk.

While Consistency is explained in other posts, Liveness is still vague at this stage of my understanding. One way to define it is “every thread should make progress”. No waiting forever, no permanent blocking. No deadlock.

Now the upshot. To prevent inconsistency, use locks everywhere, but locks affect liveness.

Atomic variables and thread-safe collections [NO NO NO] seem to be an alternative.

Now I think thread-safe collections are a liveness hazard and can increase chance of deadlocks, because they use locks. Locks are by nature
* exclusive
* u must wait for them, potentially forever.

Single-threaded execution is free from consistency/liveness issues. If you synchronize and serialize too much, you might achieve (but hard to guarantee) consistency but your liveness may be worse than single-threaded due to blocking.

GC overhead quick calc

(Based on P120 [[JavaPerformance]]) There are many GC related command line options. These two have quite specific meanings —

C) -XX:PrintGCApplicationConcurrentTime
S) -XX:PrintGCApplicationStoppedTime

With these 2, the GC log will show something like

“app time: 0.527905 seconds” # due to (C)
“total time for which app threads where stopped: 0.0453124 sec” # due to (S)

If you divide the (S) duration by the Preceding (C) duration, you get a good estimate of GC overhead — .04531/.5279 = 8%

Warning — If you see Another “app time: …” right after, that would be another “uneventful period”, which would be followed by a minor/major GC.

It’s critical to find out if the (S) duration is a minor or major GC. You can find such details in the intervening messages in [GC…]

c# DYNAMIC keyword, again

Dynamic keyword is not easy to summarize. Let’s have a phrase book

A  DYNAMIC Variable (I didn’t say “object”) is type-checked at runtime rather than compile-time. So if a specified Member is non-existent you get the “compiler error” at runtime. Example — a regular variable “Student student1” is compile-time checked if we write code to access field/methods on student1. For a DTV student2, we can write code to access a member on it, and compiler won’t check. At runtime, if the member is non-existent on the runtime object, then we get exception.

DYNAMIC keyword replaces a type-name (like String, List) in a variable declaration, so this keyword specifies a special Variable type (i didn’t say “data type”)

The “+” example — You can have a util method to apply “+” to your dynamic type vars (DTV). This is an popular showcase of DTV, but it’s academic and contrived. Nevertheless [[c# in depth]] did a decent job.
Keywords dynamic vs var? often quizzed but the showcase examples are often contrived, obscure and not a mainstream usage of DTV. See other posts in this blog.

DTV is designed for COM-automation and interop. All other usages are unconventional and either complicated/overkill or unjustified….

Now how does this help interop? See [[c# in depth]] …

c# iterator ^ enumerator ^ enumerable

A common c# question.

Nowadays, nobody seems to write Current+MoveNext because yield (i.e. iterator) is so much easier. However, behind the scene a (generated) class still must implement Current+MoveNext.

— based on http://stackoverflow.com/questions/716238/distinction-between-iterator-and-enumerator
The generic task is to step through a (virtual) collection, one item at a item. 2 ways to implement it.

1) Without iterators, you write a private class implementing IEnumerator interface which specifies Current, MoveNext, and Reset.

2) Iterators are a way for the compiler to generate this class for you, using a simple syntax (yield). This lets you implement GetEnumerator() directly in your sequence class. yourSequenceClass.GetEnumerator() would instantiate the private class and return it.

Technically, IEnumerator [1] is a c# type whereas Iterator is a mere concept not a type.

[1] Note the spelling — No type named Enumerator; Enumeration types are enums

y are munis so popular in wealth-management

…early this year I went out on a limb to say it dominates the fixed-income space, in terms of trade volume. Now I see a Barron’s article estimating 70% of total muni market is retail; with insurance companies taking 16%, and 8% by commercial banks etc. Due to the retail nature, muni desk gets higher volume than other FI desks.

– Citi muni desk has a dedicated HighNetWorth business unit;
– GS pwm clients do more muni trades than other FI trades combined;
– ML muni desk gets more trades from the retail MLBM conduit than all institutional conduits combined.

I think “Most” private wealth accounts invest primarily in 1) eq, 2) fixed income with a very smaller [3] number of (perhaps large) trades in alternative investment such as illiquid funds and private equity. In general, the more illiquid, the lower trade volume. Munis have high bid/ask spread, therefore volume is much lower than equities. In my GS PWM experience, eq trades outnumber fixed income trades every single day.

[3] eq and bond trading can be done by yourself.

Asset-allocation wise, a common pattern is 35 – 50% eq, 25-35% FI. I am no expert in the large and important field of asset allocation, but I guess FI instruments have many wealth-preserving advantages over eq instruments. Many of the equity trades in private wealth accounts aren’t wealth-preserving — they book to brokerage accounts.

Further, I believe fixed income derivatives aren’t particularly popular for wealth preservation. These instruments are created and used by enterprises, and for different purposes.

MBS? no expert here but I don’t feel it has all the advantages of investment-grade bonds.

A bond can cover 20 years — compare equities. Among regular bonds,
– munis offer unique tax advantages
– munis are generally safer than corporate bonds
– minimum quantity is $5000 or lower for muni. Not sure about other bonds.
– munis target retail investors.
– muni is the only fixed-income segment where retail investors can move a market, according to a Barron’s interview.

concurrent GC does occasional stop-the-world

Folks often mention concurrent GC as the opposite of stop-the-world (STW) GC, but in fact in Java lingo “concurrent” actually involves short stop-the-world pauses.

* STW means always-STW.
* Concurrent means occasional-STW.

STW is simpler because … during concurrent marking you can miss some reachable objects. See https://java.sun.com/j2se/reference/whitepapers/memorymanagement_whitepaper.pdf  for the exact details.

Even in single-threaded STW you could design finalize() to perform resurrection like http://www.xyzws.com/Javafaq/what-is-resurrection-in-garbage-collection/47

making sense of swing models

Justification for models: created by swing team in the MVC fashion to promote modularized separation of concern. However, controller and view are too frequently coupled because a view-agnostic controller is rare and hard. Model, however, is easily “separable” and “decouplable” in the OO sense.

Example — Logically, a jtable is a view with an object holding its data. That object is the table model. In fact jtable api encourages[1] us to use the table model.

Example — a jtextComponent is a view with an object holding its data. That object has its own type name — “Document.java”

Other swing components are more “relaxed” and let you live with or without models.

Most models fall into 2 categories. Note a model must always sit behind a UI component, otherwise it’s nothing but a regular java object.
1) domain data model, which represents entities in the business domain. See examples above.
2) UI device model – it represents state of the UI component only. Eg toggle button model

[1] you can hardly use a jtable without a table model.


P22 [[threading in c#]] outlines c# locks.

Q: Mutex vs Semaphore
%%A: Mutext is a lock usable either locally or IPC. C# Semaphore is a counting semaphore.
%%A: Mutex is like a semaphore of count 1

Both are classes. In contrast, the lock and wait/pulse features don’t have a class.

Both can be used locally (inter-thread) or IPC.

Both derive from WaitHandle, with signalling capability

Diff: thread affinity

Note Mutex is about 50 times slower than a simple lock