July 2008
M T W T F S S
« Jun    
 123456
78910111213
14151617181920
21222324252627
28293031  

Chris Donnan : Programming - Brooklyn Style

software, trading, family, fun

Apache ActiveMQ

Apache ActiveMQ is a fast open source JMS 1.1 Message Fabric which supports clustering, peer networks, discovery, TCP, SSL, multicast, persistence, XA and integrates seamlessly into J2EE 1.4 containers, light weight containers and any Java Virtual Machine together with having a host of Cross Language Clients. ActiveMQ is released under the Apache 2.0 License 

I have been playing on and off with Apache’s ActiveMQ open source message queue project. It was really easy to get the server configured and running. I am impressed by the cross language access - as a ‘real’ message queue  product should/ would support. So far - the java connections were easy as pie. I have been able to download and build the C#/ .net client implementation of their ‘open wire’ format. My 1st crack at getting the unit tests running were unsuccesful so far, but I believe this is because I am running the server instance on a linux machine and the C# stuff is running on a windows box. I have been unsuccesful in reconfiguring their test suite it would seem… so far :) We shall see how this progresses -  another hour or so and I bet it will work nicely. Hopefully I will be able to get a server instance up and running, send messages to and from using C++, C# and Java. Then I will have met my goal with this project.

You can see examples of connecting with C++ here

C# here

Java here

Theoretically in Ruby via Stomp , Python via stomp

I say that is not too bad - providing it works nicely :)

-Chris


More reading - via Safari

Well - I am doing the Safari Subscription thing….. I am an info addict. Audible subscription, Safari subscription, magazines, more books …. AAAHHH. Love it.  Safari is pretty cool so far. Since I tend to read so much - this should make the bill a bit lower in general. I usually get my books from the Amazon.com marketplace for used books. This is a great cheaper mechanism than buying the books ‘brand new’. I still DO buy them brand new if the price is close etc, but - this on line bit with Safari works well for me.
Parallel and Distributed Programming Using C++

Great - unix-centric book on multi-threading, interprocess communication/ synchronization, etc. Also good coverage of MPI and distributed computing stuff. Like it lots - good book.

Prefactoring

I am not sold on this book yet. I will let you know when I have been through it. It is not that it is ‘wrong’ or ‘bad’ but I do not see anything novel yet.

Windows System Programming Third Edition

I just want to dig deeper and deeper into my (what I would humbly consider to be vast) knowledge of windows internals.  So far so good.
Mastering Algorithms with C

I have done my best to advise MANY of my friends, collegues, peers etc in the programming world about ‘how to get a better job’. Inevitably - knowing about datastructures, Big-O style notation, algorithms, etc comes up. I have given weaker references to ‘a good book on those topics’ in the past. Now - I will refer people to this book :) This is really a great book with pretty pics to help understand those topics. Even if you already understand those topics - it is still a well written book that talks about issues with different implementations of things like hashtables, trees, etc. Highly recommended!


Ever want to just look at all the events etc in your WinForms app?

Well - here you go - Managed Spy++. All the more interesting; you can open your running app - and modify properties - just like you would in visual studio:

Pretty impressive. We have been in need of this tool! So - all the more reason - to .net 2.0 ! The MSDN article also goes into some detail about Memory Mapped files for the implementation of ManagedSpy++. All interesting.

-Chris


Books I have been reading
Beyond the C++ Standard Library : An Introduction to Boost
CLR via C#
Behind Closed Doors : Secrets of Great Management
Pragmatic Version Control Using Subversion
Java Threads (3rd edition includes the latest JDK’s stuff)
Ajax Patterns and Best Practices

Mock Frameworks - C#/ .Net and Java

I just wanted to make a few quickie comments on mock frameworks. I have been using Rhino Mocks daily. It is great. In the past I had tried NMock and just found it too clunky.

In short - NMock leaves you with a lot more ’stringy’ stuff to deal with. Rhino is MUCH more in the language. You type normal code. Your refactoring tools work. Your IDE helps you, etc.
The purpose of using a mock framework is basically so you can just work on testing the CUT (class under test). The CUT should usually be the ONLY concrete class in the test. This all works when you are practicing IoC. When you are using IoC - you pass in dependencies from the outside. When you do this - and you are seperating your interfaces from implementation - you can pass mock interfaces to your CUT. Once you do that - the mock can act as a spy.

  1. The mock lets you wriggle into code branches so that you can test pieces of the code that are otherwise difficult to get to.
  2. The mocks make your tests simpler. You do not have to instantiate lots and lots of classes correctly - you just set up interfaces and expectations and you are good.
  3. The mocks make your tests more stable. You do not have to worry about changing test data etc.
  4. The mock can act as a spy and tell you if it is being treated as you expect while it is ‘on the inside’

This used in conjunction with a code coverage tool (like Clover or NCover) helps you to really work your tests to cover your codebase fully.

Carry this over to the Java world - Rhino is much more like EasyMock which I am now writing some tests with. I had formerly used JMock (sort of like NMock in usage) - but I just replaced my jar reference and updated several tests. The tests are immediately more understandable, cleaner and therefore - better.

More another day :) - Maybe I will get around to posting comparison examples.
Chris


TradeStation platform interoperation - using GlobalVariables
Many folks in the TradeStation community have requested this vanilla functionality. The GlobalVariable.dll is here:
http://www.tradestationsupport.com/discussions/Topic_Archive.aspx?Topic_ID=19622
The C++ source is there as well. Basically - the C++ code allocates a shared memory block and then the GlobalVariable.dll 
is used to put/ get from it - thus sharing between multiple exe’s. Have fun. 
-Chris
PS - there is also lots of code/ examples of c++ (win32) and c# interop at TradeStationworld.com search c# and you can 
see all my posts and code.
using System;
using System.Runtime.InteropServices;
namespace TradeStation.Interop
{
public class GlobalVariables
{

[DllImport("GlobalVariable.dll")]
public static extern int  GV_SetInteger( int iLocation, int iVal ) ;

[DllImport("GlobalVariable.dll")]
public static extern int  GV_GetInteger( int iLocation ) ;

[DllImport("GlobalVariable.dll")]
public static extern int  GV_SetNamedInt( string sIntVarName, int iVal ) ;

[DllImport("GlobalVariable.dll")]
public static extern int  GV_GetNamedInt( string sIntVarName, int iErrorCode ) ;

[DllImport("GlobalVariable.dll")]
 public static extern int  GV_SetFloat( int iLocation, float fVal ) ;

[DllImport("GlobalVariable.dll")]
 public static extern float  GV_GetFloat( int iLocation ) ;

[DllImport("GlobalVariable.dll")]
public static extern int  GV_SetNamedFloat( string sFloatVarName, float fVal ) ;

[DllImport("GlobalVariable.dll")]
public static extern float  GV_GetNamedFloat( string sFloatVarName, float fErrorCode ) ;

[DllImport("GlobalVariable.dll")]
public static extern int  GV_SetDouble( int iLocation, double dVal ) ;

[DllImport("GlobalVariable.dll")]
public static extern double  GV_GetDouble( int iLocation ) ;

[DllImport("GlobalVariable.dll")]
public static extern int  GV_SetNamedDouble( string sDoubleVarName, double dVal ) ;

[DllImport("GlobalVariable.dll")]
public static extern double  GV_GetNamedDouble( string sDoubleVarName, double dErrorCode ) ;

[DllImport("GlobalVariable.dll")]
public static extern int  GV_SetString( int iLocation, string sVal ) ;

[DllImport("GlobalVariable.dll")]
 public static extern int  GV_SetNamedString( string sStringVarName, string sVal ) ;

[DllImport("GlobalVariable.dll", EntryPoint="GV_GetNamedString")]
static extern IntPtr GetNamedString( string sStringVarName, string sErrorCode ) ;

[DllImport("GlobalVariable.dll", EntryPoint="GV_GetString")]
 static extern IntPtr GetString( int iLocation ) ;

 public static string GV_GetString( int iLocation )
{
IntPtr ptr = GetString(iLocation);
//return Marshal.PtrToStringAuto(ptr);
return Marshal.PtrToStringAnsi(ptr);
}

public static string GV_GetNamedString( string sStringVarName, string sErrorCode )
{
IntPtr ptr = GetNamedString(sStringVarName,sErrorCode);
//return Marshal.PtrToStringAuto(ptr);
return Marshal.PtrToStringAnsi(ptr);
}

}
}