fitnesse Q&&A

(We will intermix “fix” and “fixt” and “fixture.)

fitness runs with 2 JVM
* a long term infra jvm
* a jvm launched for the system under test

FIT system interprets HTML inbound and outbound. Fitnesse wraps FIT.

set commission rate -> setCommissionRate() will be called.

Q: automated build?
A: ant can trap the fit failures

Q: cvs?
A: fitness has versions for each page

Q: books on fit tricks
A: it may not sell, since the fitness guys did good documentation(?)

— 5 types of colors
* green: expected = actual
* red: obvious
* yellow: a broken (not found) fixture — Thanks to blog reader comment below.
* grey background: See the top summary saying “5 ignored” meaning “5 table cells ignored”. nothing-to-run. expected will show ……………
good for comments
We should leave “expected” output header empty.

* grey text: expected — we don’t care. Actual will show.
Good for debugging.
We should leave “expected” output header empty.

Q: Just want to execute a method and the result is not important (or the method is void)?
A: use the SetUpFixture instead (see
A: The ColumnFixture will also allow you to just print the result of the calculation, not testing it.
A: empty cell in a fitnesse table? Try it

—- various fixtures —-
one table => one fixture class. For doFixture, one page => one fixt class. Stateful fix

column/row fixt need one fixt class per TABLE; do fixt need a fixt class per PAGE. That’s the norm. However, a doFix can also instantiate a rowFix, like Peter Walker showed.

— col fixt —
one input column => one field
one output column => one method

— testing
Q: How do I know what type of ‘error’ matched my expected ‘error’?
A: provide another method that opens the exception…

Q: how to share an object between 2 column fixtures on a page, so that first fixt populates it for 2nd fixt?
A: use a new class to hold a static instance to the object

Q: other output columns for an error row?
A: leave blank

Q: how to say expected = null?
A: just spell out n u l l

Q: what if an “expected” is in camel case and confuses fitness
A: escape it with ! or “!-…-!”

Q: use fit to test non-public stuff?
A: not designed for that. try parallel tree

— wiki
Q: save the editor?
A: alt-S

Q: collapse or hide a table?
A: http://localhost/FitNesse.QuickReferenceGuide

Q: comment?
A: see notes on grey-background

Q: comment at end or elsewhere?
A: yes

!contents // will render to a table of links

has-a vs is-a — a fine point clarified

People say “Mortgage is-a Loan” — fine. You may say a HashMap has-a Entry — you mean a HashMap instance has-a Entry instance. The distinction between Class and Instance becomes critical when you study inner classes.

Generally, it’s more accurate to say an object (of class A) has-a pointer to another object (of class B). Usually, such a relationship is defined at compile time Before instance creation.

Therefore, we could afford to be imprecise as to say “class A has-a class B”.

In summary,
* is-a could be said of classes OR instances.
* has-a should be said of instances.

boost shared_ptr implementation choices
describes linked list was once considered in Boost team, but the boost shared_ptr authors said in :

“The default behavior of shared_ptr is to allocate its control block
using new.” No linked list.

However, it was then argued that op-new is not always appropriate to allocate memory for the ref counter.

treat verb as noun(OO design

So many OO patterns and designs model a verb as a noun that we don't even notice them — we model an operation as an object, an
action, a process, a behaviour as a thingy….

In my projects, verb objects out-number nount objects. Bulk of business logic is in verb objects, so we often need to break each
into many objects and perhaps apply patterns.

* command pattern
* strategy pattern
* visitor pattern
* observer pattern
* factory pattern — object-creation
* processor objects
* loader objects
* controller in MVC
* message routers
* DAO — read operations and writes
* logger
* MessageDrivenBean
* listener, publisher, consumer

margin account, briefly

By definition, an account holds securities. A margin account can hold long securities, short securities, long cash and short cash.

When you short 500 of IBM, sales proceeds go into margin account to cover the short position, since you are expected to buy back the stock.

The *equity* of the margin account is simply what is left when the debit balance is paid in full or the shorted stocks have been bought back and returned to the lender. Equity doesn’t mean stock. It probably means the total value of stocks and cash. For long accounts, Equity = long MV – DR ie debit balance.

The amount of margin (available to investor, calculated by House every day) will depend on the price of the securities. If margin is used to buy securities, then the amount of margin increases with price, but if the margin is used to short securities, then the amount of margin is inversely related to the price of the shorted securities, and vice versa.

stackVar^heap object

In a C++ program, there is exactly
* one heap
* one stack — locals (ie auto variables) and static locals.
* one global space — globalVar is defined outside all functions.

An object (float, int, user-defined…) lives in one of the 3

In terms of cleanup, heap objects need delete (never automatically deallocated); global var lives forever; auto var has automatic cleanup. static locals live forever. [[ absolute c++]]

You can reasonably seat your ptr at
* globals
* static locals
* autos in main()
* heap objects

core java iview 18/9/09

Q: what’s inside a hashmap? Give me some details.

Q: have you ever written a hashCode()?
I simply said “never” but didn’t take the chance to explain what i know about hashCode().

Q: what’s the search time complexity in a list? What if it’s sorted?

Q: which is fatest when adding an item — Vector, List or Set?

Q: how do you create a thread?

Q: how do you use a factory?

Q: what must you implement if your object is to be used in a collection?

java enum differences from regular classes

How is an enum class E different from regular classes?

* static field? ok
* inst field? ok
* static method? ok
* inst meethod? ok
* static methods returning an instance of E? ok
* inst methods returning an instance of E? ok

#2 difference — flat tree. enums can’t form a class hierarchy. All enum classes are on the same level — all leaf-nodes under the same parent.

* can an enum E extend ..? E’s superclass is always java.lang.Enum
* subclasse E? no
* E implementing interfaces? ok

#1 difference — constructor:

* constructors? private only => not subclass-able
* how many instances of the class can be created in a JVM? If there are 5 enum values declared, those are the only instances. All the pointers of type E point to one of the 5 instances.
* constructor with arg? ok
* no-arg constructor? ok

Prime Brokerage Risk technology IV #GS 30Hudson

Q: How do you see memory usage by a given unix process?

* I said “ps”. Indeed Linux ps command reports memory usage. See
** Sometimes ps -ef doesn’t show it, but ps aux does.

* I said “/proc has process id directories. In each directory there are many details about that process, including memory”. This is supported on linux. See

AA: ps # SZ = virt mem used; RSS = real mem used
AA: use top. says

M      Sort display by memory usage.  Shorthand for "o size".

Q: when do you use static
A: I said “I don’t use static unless …”. In most OO designs, there are far more non-static than static members. Encapsulation, inheritance and polymorphism need non-static.

high leverage = low margin requirement

forex: typically leverage of 100 ie margin requirement of 1%. (I traded copper and soybean in first half of 1997 using margin
account and leverage.)

You need to put $1K into your margin account to buy $100K of a currency. Your gains and losses are magnified 100 times. High
leverage, high risk.

When market moves against you to reduce your margin to below the required minimum, you get a margin call from the House. If you
don’t top up, the “House” liquidates your position.

“House” is the broker who lends you 99% of the money.

For stocks, typically 10%. With a 10% requirement, you can buy $10K worth of IBM using $1k, borring the rest from your broker.