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 http://www.fitnesse.info/fixturegallery:fitlibraryfixtures:setupfixture).
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

http://www.boost.org/doc/libs/1_37_0/libs/smart_ptr/smarttests.htm
describes linked list was once considered in Boost team, but the boost shared_ptr authors said in
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2351.htm :

“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?