<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>voyce &#187; Excel</title>
	<atom:link href="http://www.voyce.com/index.php/category/excel/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.voyce.com</link>
	<description>Programming and debugging tidbits</description>
	<lastBuildDate>Sun, 15 Jan 2012 13:10:46 +0000</lastBuildDate>
	
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>The 7 signs your UI was created by a programmer</title>
		<link>http://www.voyce.com/index.php/2009/09/14/the-7-signs-your-ui-was-created-by-a-programmer/</link>
		<comments>http://www.voyce.com/index.php/2009/09/14/the-7-signs-your-ui-was-created-by-a-programmer/#comments</comments>
		<pubDate>Mon, 14 Sep 2009 22:57:35 +0000</pubDate>
		<dc:creator>ian</dc:creator>
				<category><![CDATA[Excel]]></category>
		<category><![CDATA[Rant]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Usability]]></category>
		<category><![CDATA[GUI]]></category>
		<category><![CDATA[win32]]></category>

		<guid isPermaLink="false">http://www.voyce.com/?p=344</guid>
		<description><![CDATA[Programmers are notoriously bad at creating good user interfaces. How can you tell if your app was designed by a programmer? (Hint: it's easy).]]></description>
			<content:encoded><![CDATA[<p>Do you suspect a programmer may have put together the terrible user interface on that &#8220;enterprise&#8221; software you&#8217;re forced to use every day? There are some give-away indicators. Look out for them in your software, hunt down the developer and force them to read <a href="http://www.amazon.com/gp/product/0470084111?ie=UTF8&#038;tag=wwwvoycecom-20&#038;linkCode=as2&#038;camp=1789&#038;creative=9325&#038;creativeASIN=0470084111">a book about user interface design</a><img src="http://www.assoc-amazon.com/e/ir?t=wwwvoycecom-20&#038;l=as2&#038;o=1&#038;a=0470084111" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" />. If you&#8217;re suitably senior, force them to a) improve it, or even better b) get someone with real UI experience to fix it.</p>
<p><b>1. Exclamation marks in dialog box messages</b><br />
Look, it&#8217;s probably the 50th time I&#8217;ve seen this message today. The fact that this application &#8220;Cannot connect to database!&#8221; is no longer a surprise. You may have noticed that most professional software uses a neutral tone for its communication with the user. Try that. Also:<br />
<b>1a. Double negatives in confirmation dialogs</b><br />
&#8220;Are you sure you don&#8217;t want to lose your changes?&#8221; Err&#8230; what? No. I mean YES. Oh sh*t. Any dialog that requires you to stop and try to parse the question in order to work out if you&#8217;re about to destroy several hours of work is not doing its job. It&#8217;s getting in the way of you doing your job. In fact, convoluted messages are such a serious issue that Microsoft even tried to help developers to help their users by introducing a whole new kind of dialog box in Vista: the <a href="http://msdn.microsoft.com/en-us/library/aa511269(loband).aspx#questionDialogsLinks">question/task dialog</a>. Good luck with that.</p>
<p><b>2. No tab ordering defined\mouse only navigation</b><br />
Because no-one&#8217;s ever going to use the keyboard to navigate the zillion controls in your data entry app, are they? This one actually surprises me, because I&#8217;d have thought that developers would&#8217;ve needed to navigate quickly through the application while they&#8217;re writing it. Well, that doesn&#8217;t seem to be the case. Pretty much all commercial apps are good counter examples. I don&#8217;t mean to hold up Microsoft Office as a paragon of UI virtue, but they definitely do the &#8220;alternate way of navigating everything&#8221; thing well. Everything you need can be reached by both keyboard and mouse. Unplug your mouse and try that with your favourite piece of in-house software and see how you get on.</p>
<p><a href="http://72.47.193.211/wp-content/uploads/2009/09/groups.png"><img src="http://72.47.193.211/wp-content/uploads/2009/09/groups.png" alt="groups" title="groups" width="360" height="327" class="alignleft size-full wp-image-358" /></a><b>3. Group boxes around everything</b><br />
This is a bit of a WinForms specific one. The clue is in the name: group boxes are for <i>grouping</i> logically related controls, not for providing a kewl recessed border around <i>every single one</i> of the controls in your dialog. Don&#8217;t kid yourself that this is doing anything other than using up some valuable screen real estate. (See if you can spot another pet peeve in the example dialog, too).</p>
<p><a href="http://72.47.193.211/wp-content/uploads/2009/09/icon_editor.png"><img src="http://72.47.193.211/wp-content/uploads/2009/09/icon_editor.png" alt="icon_editor" title="icon_editor" width="128" height="128" class="alignleft size-full wp-image-361" /></a><b>4. Icons created in the IDE</b><br />
Look, Visual Studio&#8217;s a really good integrated development environment, but it ain&#8217;t no Photoshop. Don&#8217;t try and use it to create icons. And while you&#8217;re at it, please don&#8217;t make icons consisting solely of the name of your application (inevitably an acronym) in pixel font and primary colours. Oh, and don&#8217;t just steal various icons from another application, unless you&#8217;re going to steal the whole lot; one of the key visual aspects of a good UI is consistency. Mixing your hand-drawn 4-bit icons with the glorious 32-bit shiny ones you borrowed is going to be jarring. In fact, why not go the whole way and get someone who can actually draw to create your icons for you? After all, you wouldn&#8217;t have someone who wasn&#8217;t a programmer writing the code, would you&#8230;?</p>
<p><b>5. Data grids</b><br />
Otherwise known as the &#8220;Excel is the pinnacle of user interface design&#8221; disease. Break the habit. Generally, the more types of controls that are embedded in your grid, the less likely that it&#8217;s the right kind of interface paradigm. Yeah, I&#8217;m looking at you, person embedding a calendar control, drop down box, graph, slider and checkbox in each row of a data grid. And whatever your 3rd-party grid provider of choice says, it&#8217;s not going to do screen redraw performance any good, either.</p>
<p><b>6. Not implemented message boxes</b><br />
Ahh, the GUI equivalent of source code TODO comments. Of course, it&#8217;s an in-house software give-away; no commercial (desktop) software would be brazen enough to ship with bits of functionality dangling from the stumps of buttons and menu items. Would it? Feel free to provide counter-examples if you have them.</p>
<p><a href="http://72.47.193.211/wp-content/uploads/2009/09/dialog_dialog.png"><img src="http://www.voyce.com/wp-content/uploads/2009/09/dialog_dialog-300x114.png" alt="dialog_dialog" title="dialog_dialog" width="300" height="114" class="alignright size-medium wp-image-365" /></a><b>7. Excessive use of dialog boxes</b><br />
Warning: dialog boxes are considered harmful (to usability). They&#8217;re the equivalent of restraining your user by force and preventing her from moving until she answers your question. That might be OK for matters of life or death (i.e. data loss), but not otherwise. Every time you find yourself about to add a new message box, stop, take a deep breath and consider whether it&#8217;s really necessary.</p>
<p>So, if you&#8217;re a victim or one, many, or all of these user interface faux pas, all I can say is: sorry. I&#8217;ve been responsible for doing at least one of these things myself over the years. Consider this post repentance for my user interface sins.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.voyce.com/index.php/2009/09/14/the-7-signs-your-ui-was-created-by-a-programmer/feed/</wfw:commentRss>
		<slash:comments>43</slash:comments>
		</item>
		<item>
		<title>Ending the love affair with Excel</title>
		<link>http://www.voyce.com/index.php/2009/07/08/ending-the-love-affair-with-excel/</link>
		<comments>http://www.voyce.com/index.php/2009/07/08/ending-the-love-affair-with-excel/#comments</comments>
		<pubDate>Wed, 08 Jul 2009 22:30:17 +0000</pubDate>
		<dc:creator>ian</dc:creator>
				<category><![CDATA[Excel]]></category>
		<category><![CDATA[Finance]]></category>
		<category><![CDATA[UI]]></category>

		<guid isPermaLink="false">http://www.voyce.com/?p=171</guid>
		<description><![CDATA[It's a well known fact that the financial services industry (where I mean banks, hedge funds, pension providers, fund managers etc) is deeply in love with Excel. But what is it about the Excel ecosystem that makes it so appealing, and how can we move seamlessly to a more robust, maintainable platform?]]></description>
			<content:encoded><![CDATA[<p><div id="attachment_214" class="wp-caption alignleft" style="width: 160px"><a href="http://72.47.193.211/wp-content/uploads/2009/07/spreadsheets_mug.png"><img src="http://www.voyce.com/wp-content/uploads/2009/07/spreadsheets_mug-150x150.png" alt="I heart spreadsheets" title="I heart spreadsheets" width="150" height="150" class="size-thumbnail wp-image-214" /></a><p class="wp-caption-text">I heart spreadsheets</p></div>It&#8217;s a well known fact that the financial services industry (where I mean banks, hedge funds, pension providers, fund managers etc) is deeply in love with Excel. But what is it about the Excel ecosystem that makes it so appealing?</p>
<p>Unfortunately, given the ever-increasing focus on accountability and scalability in these domains, Excel is also an increasingly inappropriate platform for delivery of this sort of functionality. How can organisations ease the transition away from this environment to something more easily manageable, while retaining it&#8217;s positive benefits?</p>
<p><span id="more-171"></span></p>
<blockquote><p>Disclaimer: These are my own views and not those of my employer. The scenarios I describe are fictitious and not based on actual practices at my place of employment. Any similarity to actual events and behaviours is coincidental.
</p></blockquote>
<p>I see two main aspects of Excel&#8217;s operation that prove valuable in general, and in finance in particular: visibility and immediacy.</p>
<h3>Visibility</h3>
<p>From an end user&#8217;s point of view, one of the most positive aspects of Excel is it&#8217;s transparency. Even in an environment where complex processing goes on inside a plugin &#8211; say, an Excel user defined function (UDF) packaged as an XLL &#8211; it&#8217;s still only in the scope of a single function call in a single cell. You continue to get good visibility of the inputs and outputs from the function.</p>
<p>You can also get a good higher-level view of how the different parts of the calculation fit together. Either by inspection, editing the formula to quickly see which cells it references, or by using the formula auditing toolbar to get an overlay of dependent and precedent functions, you can see roughly how various parts of the calculation fit together.</p>
<p>This, combined with the logical separation of functionality into separate worksheets, gives you the impression of understandability.</p>
<p>The problem is that it&#8217;s just that &#8211; an impression &#8211; there is no structure enforced by the worksheet separation, you&#8217;re free to link between them as you see fit, and this can result in an extremely complex and virtually indecipherable &#8220;flow&#8221; of calculation within a workbook.</p>
<h3>Immediacy</h3>
<p>Luckily, to offset the complexity we have another important aspect of Excel&#8217;s usability: it&#8217;s immediacy.</p>
<p>Trading users can very quickly modify calculation trees to perform ad-hoc additional calculations such as applying spreads, and to gauge the effect of market moves on their portfolio, i.e. &#8220;what-if&#8221; scenarios.</p>
<p>Structuring users can fairly easily &#8211; given an existing set of functional pieces &#8211; assemble a model to price a complex new trade type. Although this is a much less common use case now that the demand for getting new structured products to market quickly has essentially vanished.</p>
<p>As well as this type of gross modification, it&#8217;s also possible to just repeatedly re-evaluate some small part of the calculation to quickly determine how it is affected by other changes.</p>
<p>The immediacy of the Excel environment, combined with the use of the Visual Basic for Applications (VBA) scripting language, enables both business and IT users to rapidly build out new sheets to perform ad-hoc tasks. Rapid application development, or RAD as it&#8217;s known, is all well and good for performing some transient, ad-hoc calculation for limited use, but unfortunately these tools have the habit of becoming indispensable parts of an organisation&#8217;s workflow. That&#8217;s when you start to see serious problems with scalability and maintainability.</p>
<h3>The problem?</h3>
<p>So the fundamental tension here is that exactly the same features which make Excel useful to traders, structurers, etc., also make it highly unsuitable for use in these environments. You really don&#8217;t want traders to be able to subtley alter the flow of the calculation, as much as they might like to. Excel should really be a read-only view on some underlying trade data source and calculation engine, but this isn&#8217;t always how it&#8217;s implemented.</p>
<p>You also want to provide some flexibility &#8211; the ability to experiment, explore and examine &#8211; but within certain constraints and without compromising future requirements. Being able to price a trade is a good start, but you will subsequently need to book it easily, re-value it reliably and potentially risk manage a large portfolio of them.</p>
<h3>Moving away from Excel</h3>
<p>Many houses provide underlying quant analytics implemented in C++, with a native C++ interface and a variety of other (sometimes auto-generated) wrappers that make it accessible in other environments. Ideally, the amount of actual functionality in these wrapper layers should be kept to an absolute minimum. It should be commodity code that can be regenerated as and when required.</p>
<p>However, even if this is the case, unless you have the ability in the underlying code to fan-out the processing you will still be constrained by the operating system process limits, e.g. 4gb address space.</p>
<p>The common alternative to hosting pricing and risk management within Excel is to write new dedicated applications to perform the calculations and (hopefully) provide a means to inspect and troubleshoot it.</p>
<p>Unfortunately these systems are built by teams who aren&#8217;t particularly familiar with the way the front office uses Excel. It&#8217;s often the case that spreadsheet development teams and systems development teams don&#8217;t interact; the former tend to be based on the trading desk while the latter are in another part of the building.</p>
<p>So the end result can end up being systems that work in a way developers feel comfortable with, rather than the way business users would like them to work. This can make the system seem like a black box to it&#8217;s users. And to make it worse these are the users who are accustomed to Excel&#8217;s high levels of transparency.</p>
<p>Although the system may be enforcing the fact that trade value is strictly a function of the trade, market and static data, having some transparency can still be valuable in giving skilled users confidence in the underlying calculation. They can apply their not-inconsiderable intuitive abilities to quickly gauge the correctness or otherwise of the valuation. It can help the quants move away from their native Excel/Matlab-style iterative development environment. And when groups need to work together to reconcile differences, everyone can benefit.</p>
<p>The problem? This amount of transparency has to be built into the system or the quant library pretty much from the ground up.</p>
<h3>Solutions</h3>
<p>One possible approach is to make your system a general purpose calculation engine. This has some appeal, but you have to be careful about sacrificing performance for generality. You might be tempted to try exactly matching the semantics of Excel&#8217;s calculation and type system. This can be a nightmare, with all sorts of limitations and nasty edge cases. For example, the fact that errors are a simple numeric value with no facility to carry extra information is crippling, and also the lack of support for objects as first class values in the type system.</p>
<p>However you choose to implement your calculation engine, ensure that it&#8217;s loosely coupled enough to be run out-of-process or across machine boundaries without code changes.</p>
<p>Here are some bullet-point takeaways for easing the transition:</p>
<ol>
<li><strong>Provide a means for users to examine intermediate calculations, and surface it in the UI.</strong><br />
This will give your intermediate and end users confidence in the calculations
</li>
<li><strong>Provide a means to capture and re-play valuations, including all their inputs and outputs.</strong><br />
	This will assist in reconciling valuations, and in passing snapshots around between groups.
</li>
<li><strong>Provide the ability to drive the system programatically.</strong><br />
	Along with persistent valuations, this will help in regression testing
</li>
</ol>
<p>I hope this post has served to give you some insights into the potential challenges of moving users away from Excel into more robust systems, why some of those users may be reluctant to move, and how you can help to ease the transition. And of course, let me know via the comments if you&#8217;ve got any observations on the subject.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.voyce.com/index.php/2009/07/08/ending-the-love-affair-with-excel/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Beware cached IDispatch</title>
		<link>http://www.voyce.com/index.php/2008/11/10/beware-cached-idispatch/</link>
		<comments>http://www.voyce.com/index.php/2008/11/10/beware-cached-idispatch/#comments</comments>
		<pubDate>Mon, 10 Nov 2008 11:32:15 +0000</pubDate>
		<dc:creator>ian</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[COM]]></category>
		<category><![CDATA[Debugging]]></category>
		<category><![CDATA[Excel]]></category>
		<category><![CDATA[F#]]></category>
		<category><![CDATA[IDispatch]]></category>
		<category><![CDATA[VBA]]></category>
		<category><![CDATA[VBScript]]></category>

		<guid isPermaLink="false">http://www.voyce.com/?p=51</guid>
		<description><![CDATA[I&#8217;ve kinda given it away there with the title, but we had an interesting set of symptoms exhibited the other day while trying to call a function in an Excel workbook via F#. It appeared that the function being called would fail depending on what had been called previously. Very odd.
A bit of background: as you [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve kinda given it away there with the title, but we had an interesting set of symptoms exhibited the other day while trying to call a function in an Excel workbook via F#. It appeared that the function being called would fail depending on what had been called previously. Very odd.</p>
<p>A bit of background: as you may know, if you add functions to the worksheet or workbook code in Excel then they appear as callable methods on the objects themselves. This is achieved with the use of dynamic dispatch and IDispatch. For example, creating a workbook with this function in it&#8217;s VBA code:</p>
<p><code>Public Function Foo() As Double<br />
    Foo = 100<br />
End Function</code></p>
<p>Means you can call it like this:</p>
<p><code>MsgBox CStr(ThisWorkbook.Foo)</code></p>
<p>As well as being able to call it like this from within the Excel session (i.e. in other VBA code in the process), you can also access it externally using the COM object model that Office applications expose. For instance, you can use VBScript:</p>
<p><code>Dim excel, wkb<br />
Set excel = CreateObject("Excel.Application")<br />
Set wkb = excel.Workbooks.Open("a.xls")<br />
WScript.Echo wkb.Foo<br />
</code></p>
<p>Or, more interesting, using F#:</p>
<div style="font-family: Lucida Sans Typewriter; font-size: 10pt; color: black; background: white;">
<p style="margin: 0px;">    <span style="color: #0000ff;">let</span> excel = <span style="color: #0000ff;">new</span> Excel.ApplicationClass()</p>
<p style="margin: 0px;">    <span style="color: #0000ff;">let</span> wkb = excel.Workbooks.Open(<span style="color: #a31515;">@&#8221;c:\a.xls&#8221;</span>)</p>
<p style="margin: 0px;">    wkb.GetType().InvokeMember(<span style="color: #a31515;">&#8220;Foo&#8221;</span>, BindingFlags.InvokeMethod, <span style="color: #0000ff;">null</span>, wkb, <span style="color: #0000ff;">null</span>)</p>
</div>
<p>The key part here is that we&#8217;re using wks.GetType() to get a managed representation of the unmanaged Excel COM interface. Under the covers this is creating a runtime callable wrapper (RCW) to wrap the worksheet COM object.</p>
<p>However, the problem we were seeing was that opening multiple sheets resulted in failures to call the method in certain situations. Although the VBA signature was exactly the same in all of the sheets, it seemed that opening b.xls after a.xls, would fail; returning null when we expected it to return a value. If we opened c.xls after b.xls, it would fail in a different way; never actually making it to the body of the function. Very odd.</p>
<p>My first suspicion was that it was somehow related to COM object vs .NET object lifetime. This is quite a common problem whens invoking Excel using managed code. It&#8217;s bad mixing COM and .NET anyway; generally deterministic, reference-counted lifetime semantics don&#8217;t play well with the garbage collector. Throwing an app with a full-blown UI being managed as COM object into the mix just complicates matters further. Anyway, it&#8217;s been widely discussed, so I won&#8217;t say any more about it here; suffice to say that calling Marshal.ReleaseCOMObject and GC.Collect got us to the point where we could see the Excel process terminating, so we knew that the failure wasn&#8217;t due to some state being cached inside there.</p>
<p>So we concentrated on different aspects of the problem:</p>
<ul>
<li>Given the pattern of failures, it seemed that the order of opening the sheets and calling affected the outcome. This hinted that something was persisting betweeen calls, but not in the client (Excel) site.</li>
<li>The code had previously worked when written in VBScript, so there was nothing intrinsically wrong with the operations we were performing.</li>
</ul>
<p>This seemed to strongly indicate that something was being cached at the .NET level. And the major difference between the .NET code and the VBScript was that the former used Type.GetType() on the worksheet object to get it&#8217;s managed representation, while the latter used the IDispatch directly.</p>
<p>So it looked like GetType() was caching some information about the particular IDispatch implementation that it encountered first, then reusing that for subsequent worksheet implementations which actually had a slightly different layout, i.e. although they also had the Foo function which we were trying to call, they had a different set of other dynamic functions too.</p>
<p>After a bit of digging about I uncovered this gem: <a href="http://blogs.msdn.com/mbend/archive/2007/04/18/the-mapping-between-interface-pointers-and-runtime-callable-wrappers-rcws.aspx">the mapping between interface pointers and runtime callable wrappers</a>. Which seemed to describe exactly what we were seeing. The first time through the loop, the runtime is asked to get the type and is given a COM pointer, for which it creates a RCW that we can use to invoke Foo. The second time through the loop, the runtime thinks it&#8217;s seen the object before, so rather than perform the expensive operation of creating the RCW again, it just returns the original one. The problem is, the underlying COM object is different!</p>
<p>So, in order to prevent the runtime for trying to cache the RCW, we need to use <a href="http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.marshal.getuniqueobjectforiunknown(VS.80).aspx">Marshal.GetUniqueObjectForIUnknown</a> and that does the trick nicely. We first need to get an IUnknown for our object, than convert that back into an object, which is actually a RCW:</p>
<div style="font-family: Lucida Sans Typewriter; font-size: 10pt; color: black; background: white;">
<p style="margin: 0px;">    <span style="color: #0000ff;">let</span> wkb = Marshal.GetUniqueObjectForIUnknown(Marshal.GetIUnknownForObject(wkb))</p>
</div>
<p>Although it&#8217;s less efficent, at least the code works, and it finally allows us to call the dynamic methods on the workbook object from F# .NET.</p>
<p>It will be interesting to see how <code>dynamic</code> in .NET 4.0 addresses this kind of issue.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.voyce.com/index.php/2008/11/10/beware-cached-idispatch/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Static libraries are Evil</title>
		<link>http://www.voyce.com/index.php/2008/09/24/static-libraries-are-evil/</link>
		<comments>http://www.voyce.com/index.php/2008/09/24/static-libraries-are-evil/#comments</comments>
		<pubDate>Wed, 24 Sep 2008 15:27:27 +0000</pubDate>
		<dc:creator>ian</dc:creator>
				<category><![CDATA[COM]]></category>
		<category><![CDATA[Excel]]></category>
		<category><![CDATA[Rant]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[c++]]></category>
		<category><![CDATA[dll]]></category>
		<category><![CDATA[lib]]></category>

		<guid isPermaLink="false">http://www.voyce.com/?p=41</guid>
		<description><![CDATA[In my opinion.
Why? Well, because it&#8217;s too easy to use them as an excuse for not defining your shared library interfaces properly.
The reason this is on my mind recently is that several hundred, yes, you heard that right, several hundred DLLs have been released by my group over the last, ooh, 10 years or so. [...]]]></description>
			<content:encoded><![CDATA[<p>In my opinion.</p>
<p>Why? Well, because it&#8217;s too easy to use them as an excuse for not defining your shared library interfaces properly.</p>
<p>The reason this is on my mind recently is that several hundred, yes, you heard that right, several <em>hundred</em> DLLs have been released by my group over the last, ooh, 10 years or so. They are all still in use. Each of them has burned into it a copy of the library that deals with interfacing with Excel. That means each of these has it&#8217;s own little internal copy of the current state-of-the-art. The problem with that is; the state-of-the-art moves on. And how do you go about updating the DLLs that are already in production? You have to re-release them. In an environment where thes DLLs are used for marking the profit and loss on a large derivatives trading book, that&#8217;s not a small undertaking. And it&#8217;s made worse if, say the DLL in question was last released with a different version of the compiler.</p>
<p>My approach would be to refactor this shared static library (.lib) into a stand-alone DLL.</p>
<p>At this point, people start saying &#8220;oh, but then you&#8217;ve got a single point of failure, if you release a broken version of that DLL, everything will stop working!&#8221;. Not exactly a compelling argument. If the functionality of the DLL is well defined, and there are well known entry points it should be easy to put together a comprehensive black-box test suite. In fact we already do that with all our other DLLs (COM servers). The fact that this shared library *isn&#8217;t* a DLL has meant that it&#8217;s fallen through the testing cracks; another good reason to refactor it.</p>
<p>The internal interface to the shared library is already relatively well defined. It has a set of header files that define all of the functions and classes that are consumed by others. It&#8217;s a relatively small step to compile it as a DLL, rather than a static library. The problem then becomes one of maintenance, dealing with the inevitable changes to the external interface in a backwardly compatible way.</p>
<p>And that&#8217;s the problem. It requires some effort. Elsewhere in our codebase we use COM as a magic cure-all for avoiding having to deal with versioning: interface immutability rules. All interfaces are public, no published interface ever changes, object identity is based purely on interfaces supported. If you haven&#8217;t got these crutches to rely on, then you have to enforce the rules yourself, which can be both logistically and technically difficult when you&#8217;re dealing with C++.</p>
<p>But it&#8217;s not impossible. And I really think it would be better than having hundreds of DLLs all containing subtley different versions of the same code, and being unable to change behaviour across the board without having to build, test and release them all.</p>
<p>Maybe you&#8217;ve got a different opinion?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.voyce.com/index.php/2008/09/24/static-libraries-are-evil/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dumping Excel XLL add-in calls</title>
		<link>http://www.voyce.com/index.php/2007/08/30/dumping-excel-xll-add-in-calls/</link>
		<comments>http://www.voyce.com/index.php/2007/08/30/dumping-excel-xll-add-in-calls/#comments</comments>
		<pubDate>Thu, 30 Aug 2007 23:40:55 +0000</pubDate>
		<dc:creator>ian</dc:creator>
				<category><![CDATA[Debugging]]></category>
		<category><![CDATA[Excel]]></category>
		<category><![CDATA[WinDbg]]></category>

		<guid isPermaLink="false">http://www.voyce.com/?p=19</guid>
		<description><![CDATA[Using WinDbg it’s possible to get a dump of each XLL call that is made by Excel as it calculates. If you’re using Excel 2003, create the following breakpoint that dumps the symbol at eax+4 (the entry point that is about to be called), then continues.:
bu EXCEL!MdCallBack+0xa880 "dds @eax+0x4 L1; g"
You’ll need to adjust the [...]]]></description>
			<content:encoded><![CDATA[<p class="postentry">Using WinDbg it’s possible to get a dump of each XLL call that is made by Excel as it calculates. If you’re using Excel 2003, create the following breakpoint that dumps the symbol at eax+4 (the entry point that is about to be called), then continues.:</p>
<p><code>bu EXCEL!MdCallBack+0xa880 "dds @eax+0x4 L1; g"</code></p>
<p>You’ll need to adjust the offset for other versions of Excel &#8211; and I haven’t tried it yet with 2007. Assuming you’ve got symbols available for the XLLs being called, you’ll get something like this:</p>
<p><code>0013bc50 15109730 addin1!addin1_function1<br />
0013bc50 12c0e918 addin2!addin2_anotherfunctions</code></p>
<p>This technique can be useful when troubleshooting &#8211; to identify the last addin call being made before a failure perhaps &#8211; and is also quite interesting to just watch and see the pattern in which your XLL UDFs get called.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.voyce.com/index.php/2007/08/30/dumping-excel-xll-add-in-calls/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Modular Excel Spreadsheets</title>
		<link>http://www.voyce.com/index.php/2007/04/19/modular-excel-spreadsheets/</link>
		<comments>http://www.voyce.com/index.php/2007/04/19/modular-excel-spreadsheets/#comments</comments>
		<pubDate>Thu, 19 Apr 2007 22:30:43 +0000</pubDate>
		<dc:creator>ian</dc:creator>
				<category><![CDATA[Excel]]></category>
		<category><![CDATA[Software Development]]></category>

		<guid isPermaLink="false">http://www.voyce.com/?p=12</guid>
		<description><![CDATA[Where I work there is no escape from the clutches of Excel. It gets everywhere. Everyone uses it for everything.One of the projects I’ve been responsible for is an attempt to modularise Excel workbooks in order to make them easier to create and manage. This is done by creating a manifest for each “component” (a [...]]]></description>
			<content:encoded><![CDATA[<p>Where I work there is no escape from the clutches of Excel. It gets everywhere. Everyone uses it for everything.One of the projects I’ve been responsible for is an attempt to modularise Excel workbooks in order to make them easier to create and manage. This is done by creating a manifest for each “component” (a worksheet, and optionally some VBA code-behind) that expresses the inputs that it consumes, and the outputs it provides. Then it’s simply a matter of recursively creating and joining these components together until we get a complete workbook.It turns out that making the abstraction that a component is nothing more than a set of inputs and outputs, and having the joining framework know nothing about the functionality of each component, means we can easily apply it across a wide range of applications. Generally it’s used by structurers to construct quite complex spreadsheets for valuing derivatives on one or many underlying assets, but it can also be used to construct “trading book” type spreadsheets that download a set of trade data and value them, automatically creating the market data components required to do the valuation.</p>
<p>The framework itself is written as a COM server that lives inside the Excel process, and controls it via automation, although it also works out-of-process. It supports IDispatch, so is usable from scripting languages, too. For instance I’ve put together an HTML/JavaScript based UI that can invoke the framework directly from a web browser.</p>
<p>The main problem is the fact that Excel is the host application. There are lots of strangenesses around the Excel automation API, but it still does a pretty good job, in my opinion, of exposing so much functionality. The real issue is that it’s a black-box. As is the VBA engine (VBE.DLL). This can make it difficult to track down problems, especially where I’m crossing backward and forward between native C++/COM code and VBA callbacks.</p>
<p>Still, this is a satisfying project, because it helps to formalise people’s use of spreadsheets, without them even realising. It’s easier for end-users to drive; they select what type of product they want to value from a simple GUI and the framework does the rest. And from a development point of view it means the analytics group have fewer monolithic and difficult to maintain spreadsheets. And of course, forcing us to think about the model in component terms also means that if we should ever move away from Excel (!) we would, at least in theory, have an easier migration path.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.voyce.com/index.php/2007/04/19/modular-excel-spreadsheets/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

