Archive for the ‘design’ Category

Doing The Google Test

Friday, November 7th, 2008


I am starting to use GoogleTest in development. I have not started using it YET, but I plan to roll it into my test framework. My little framework connects to a test database, and that is the thing I need to add to Google test.

I will still use my old framework. When I send work out to others , I use my framework so others do not have to worry about a xUnit framework. Not everyone uses xUnit you know.

I am a big believer in test driven development. That is just me and it has served me well.

Google’s framework for writing C++ tests on a variety of platforms (Linux, Mac OS X, Windows, Cygwin, Windows CE, and Symbian). Based on the xUnit architecture. Supports automatic test discovery, a rich set of assertions, user-defined assertions, death tests, fatal and non-fatal failures, type-parameterized tests, various options for running the tests, and XML test report generation.

I think it is great that Google released it.

Raydo Backing Store

Monday, November 3rd, 2008

Is dead….

I got rid of it over the summer. Raydo started out doing it’s own messaging/server/client thing. That was fine, it needed its own backing store then.

Now since we are using a message store, the message store can take care of persistence now.

The most interesting store is the BDBMessageStore on Qpid. The BDBMessageStore module utilises the BerkelyDB to provide persistence. Cool.

Anyway, the backing store code has been ripped out, thank you very much.

Morning Cup of Valgrind

Wednesday, April 9th, 2008

Valgrird logoValgrind is a memory checker and dynamic analysis program, named after a Norse myth. So the obvious question is how to pronounce “Valgrind”?  The “grind” is pronounced with a short ‘i’ like “grinned” (rhymes with “tinned”) rather than “grined” (rhymes with “find”). One of the big bonuses is Helgrind, a tool for checking race conditions in multithreaded code. It is still ‘experimental, but you now how ‘experimental’ is when it comes to open source codes.

    I am trying to integrate Valgrind with my unit testing framework, but I haven’t had the time. For Raydo, I develop on OSX, and run the Valgrind & unit tests on Linux, since Valgrind only works on Linux. This will catch Linux memory leaks and memory leaks from my code, but not any memory leaks that are specific to the Window platform or the GUI kit that you are using. Those leaks are the platform’s problem anyway. You will see a lot of memory leaks from other parts of you software , including wxWidgets, when you run Valgrind on Raydo. Such is life.

    Valgrind supports Linux on x86, x86-64 and PowerPC. There are ports to other the *BSD Unixes. There is no port for Microsoft Windows nor are there any plans for one. Valgrind works much better with C++/STL than with straight C. Valgrind does not check ranges in arrays, such as strings in C, which can be a problem.

So if you code C++/C on Linux, I highly recommend Valgrind.

WikiOverlords
Valgrind home page

Eating one’s own dog food

Tuesday, April 1st, 2008

    Stupid phrase, but a good one. According to Wikipedia, the term came from inside Microsoft. Despite the origin of the word, I still think it is quite descriptive.

    For the last few weeks, as my home grown code has been rolled into Raydo, I am using complete Raydo applications daily, instead of the piecemeal applications I was using before. You know what I mean, first you write an application, then you find another use and you extend it, and on and on and on.

According to our Wiki overlords, eating one’s own dog food has four benefits.

Using one’s own products has four primary benefits:

1. The product’s developers are familiar with using the products they develop.
2. The company’s members have direct knowledge and experience with its products.
3. Users see that the company has confidence in its own products.
4. Technically savvy users in the company, with perhaps a very wide set of business requirements and deployments, are able to discover and report bugs in the products before they are released to the general public.

    I say, sure. Whatever. But I think I have found a fifth benefit. You realize what is annoying to the end user using your product everyday and you want to change whatever feature. People say that writing open source software is like scratching an itch. Well, fixing an annoying GUI is drinking a Old Milwaukee. You deal with it, but you would really rather have a Heineken.

    So you use the application , and the same thing keeps buggin you so you end up tweaking the GUI. Does it a something to the bottom line, not but doing a GUI right is soooooooooo much better than just slapping any old GUI on an application. I guess my time spent at a company that really cares about user interfaces has permanently warped me. User interfaces should be all about the user. Not how the person designing it THINKS the user would use it. I think I am unique, because I wear both hats, I write software for trading , I trade everyday, and I love designing GUI’s. Well, that is more like 2.5 hats, but you get my meaning.

    If you are an engineer designing a GUI, please take a look at this book. Designing bad user interfaces is no way to go through life.

‘Databased’ Unit Tests

Friday, March 14th, 2008

I know ‘Databased’ is not a word. But it was the best word I could come up with. What I am doing now is connecting my unit test output to a MySql database.

By putting the unit tests, I can look back and see when things failed, which help when I pull old files out of svn. So I can sort by pass/fail test ( which is the most common method ) , the test performed and the class.




This image above is RUnit.php . I will include this file in the php/ subdirectory. It only has three parameters to modify at the top of the file and that is about it.

I use a simple homegrown unit test framework. Yet another C++ unit test framework, like we need another one. I needed a much less specific framework. But a very simple framework.

I use cron to do automated tests. I pull the latest copy out of svn, compile run the unit tests, and store the results in the database. It is pretty sweet, but I do not have the failed compiles feeding into the database yet.

Symbology and the big change

Monday, March 3rd, 2008

About three years ago , the guys from the OCC got togethter and decided to make changes to the way options are quoted by the market. For an example, The Mar 08 120.00 Puts have the symbol QAAOD while the Mar 08 125.00 puts have the symbol APVOE. So after a few years of work, they came up with this :


Mar 08 120.00 Puts
QAAOD -> AAPL080322P00120000
( AAPL 08 03 22 P 00120 000 )

Not really too difficult to figure out the coding on this system. There are a lot of details concerning things like FLEX options and stocks splits/mergers etc. The big change is due for July 2009, so a about a year and a half we will have to move over. The old symbols will be suppressed after that date.

What does this have to do with the price of tea in China? Not much ( but you can check the tea futures contract ) and not much to do with Raydo.

Internally, we already use the new structure. Just an input filter to change the old symbols into the new symbols. After the big change, we will just drop the filter.

Interface Ergonomics

Tuesday, February 12th, 2008

    I am a big believer in interface ergonomics. Let me define what I mean by ergonomics in an interface. An ergonomic interface is one where the user feels comfortable using the application. Where using the interface feels intuitive. Clean, consistent and productive interfaces get the GUI out of the way so the user can spend his time using the software. I think my time at Apple ( Macbook Air…drool…. ) years ago has forever changed my perception of how user interfaces should work.

I would like to share three of my favorite links.

    The first one, Ten Ways to Make More Humane Open Source Software has a big of a misleading title. Is should be something like “10 ways to not mess up your GUI”. It is a great article, and well worth taking a look.

    The second article The Rise of Interface Elegance in Open Source Software. This article is more about creeping featuritis and learning to say no.

    The last article The Luxury of Ignorance: An Open-Source Horror Story, is a bonus. Just a rant on how difficult some interfaces are and mentions “Aunt Tillie”.

Here is a great rule from Joel on Software on UI design.

A user interface is well-designed when the program behaves exactly how the user thought it would.

CMake

Thursday, January 24th, 2008

I am testing out changing the build system to CMake. I want to make building Raydo as simple as possible. Right now I use make, which is not the friendliest way to build things. By using CMake, I can supply , for example, Visual C project file.

So to summarize:
Open Source
  Supports basically every UNIX, MS Windows (MSVC, Borland, cygwin, mingw) and Mac OS X
  Can generate Makefiles and *projects* for KDevelop3, MSVC 6,7, XCode
  Has no other dependencies except for a C++ compiler

So I will be able to supply Windows guys with project files.

More Pthreads-win32 madness

Monday, January 14th, 2008

    So I was dorking around this weekend with the threading model on Raydo. Mainly benchmarking the granularity of the threads. For what I normally do , everything seems fine, equities, futures, blah, blah,blah. Until I started simulating a market maker carrying tons of options quotes on his/her book. The old model started to have a ‘lag’ that I was not happy about. So I started benchmarking a finer/coarser grained threading models.

    I am using pthreads which run on real ( POSIX ) systems, and Pthreads-win32 for that other operating system. So I am looking through the pthreads documentation for pthreads read / write locks , in the Linux/Mac/rest of the world documentation, I see this.

To prevent writer starvation, writers are favored over readers.

Which is nice, and IMHO, the way reader/writer locks should be. However for Windows, I see this lovely pearl of wisdom,

Pthreads-win32 does not prefer either writers or readers in acquiring the lock – all threads enter a single prioritised FIFO queue. While this may not be optimally efficient for some applications, it does ensure that one type does not starve the other.

    Argh ! “optimally efficient”? How about sucks? I do not want a fresh tick quote to come in, and have 20 readers in the queue before the writer reading a stale tick quote. I want the writer bumped to the front of the queue, dump the new tick in, and have the readers read the new data. Another reason I don’t like windows.

    Pthreads is just a wrapper around Win32 threads, and from what I am reading, Win32 does not really support multi-read, single-write (MRSW) lock that does not have problems with writer starvation. ( In NT they have an undocumented lock, which I guess is only for some nefarious MS usage.) So don’t quote me on the Win32 API. I am not a Win32 API guy, but it seems the Win32 API has a problem with writer starvation in reader/writer locks. Please correct me if I am wrong.

    Whatever model I use, when running a lot of reader / writer threads, I think I will have not have the warm fuzzies using Pthreads.

[Update] Just changed the object model a little bit, and everything is back to goodness. I did learn something about the Win32 API along the way that I did not want to know.

The Problem with Threads

Thursday, January 3rd, 2008

The Problem with Threads is a paper written by the Edward A. Lee, the Chair of EE @ University of California at Berkeley

I especially liked one line from his conclusion,

Concurrent programming models can be constructed that are much more predictable and understandable than threads. They are based on a very simple principle: deterministic ends should be accomplished with deterministic means.

Until that day comes, we will still muddle along with pthreads. Once again, threads in Windows is a pain!

( Well not really a pain, just why do they have to be different ? )