<?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>James Gregory &#187; Work</title>
	<atom:link href="http://jagregory.com/writings/category/work/feed/" rel="self" type="application/rss+xml" />
	<link>http://jagregory.com</link>
	<description>Monkeying with the code</description>
	<lastBuildDate>Tue, 22 Jun 2010 11:07:25 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Waiting for change</title>
		<link>http://jagregory.com/writings/waiting-for-change/</link>
		<comments>http://jagregory.com/writings/waiting-for-change/#comments</comments>
		<pubDate>Wed, 26 Nov 2008 01:16:49 +0000</pubDate>
		<dc:creator>James Gregory</dc:creator>
				<category><![CDATA[Opinion]]></category>
		<category><![CDATA[Personal]]></category>
		<category><![CDATA[Work]]></category>

		<guid isPermaLink="false">http://blog.jagregory.com/?p=153</guid>
		<description><![CDATA[We&#8217;ve all been in a job where &#8220;things are going to get better&#8221;, not just yet, but very soon. Perhaps you&#8217;re finally going to get a new product to work on, or that rewrite that&#8217;s well overdue, or a new development machine, or any number of other things.
Assuming you&#8217;re actually bothered by the non-arrival of [...]]]></description>
			<content:encoded><![CDATA[<p>We&#8217;ve all been in a job where &#8220;things are going to get better&#8221;, not just yet, but very soon. Perhaps you&#8217;re finally going to get a new product to work on, or that rewrite that&#8217;s well overdue, or a new development machine, or any number of other things.</p>
<p>Assuming you&#8217;re actually bothered by the non-arrival of your desired improvement, it&#8217;s very important that you set a cut-off date for it to occur by. Not only that, you also should define what action you&#8217;re going to take when that date arrives; typically, that&#8217;d be &#8220;leave&#8221;.</p>
<p>Without a cut-off you can meander on, days turning to weeks, weeks to months, and months to years. Before you know it years have passed without any actual changes having occurred, only the constant dangling carrot of hope.</p>
<p>I&#8217;m not advocating that everyone quit their job just because they don&#8217;t get to do everything they want. This is about when you&#8217;ve done everything in your power to improve things, to instigate change, and when that still has no effect.</p>
<p>You have to know when something has become a lost cause, and when it&#8217;s time to move on.</p>
]]></content:encoded>
			<wfw:commentRss>http://jagregory.com/writings/waiting-for-change/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Empty NHibernate logs and poor performance</title>
		<link>http://jagregory.com/writings/empty-nhibernate-logs-and-poor-performance/</link>
		<comments>http://jagregory.com/writings/empty-nhibernate-logs-and-poor-performance/#comments</comments>
		<pubDate>Fri, 12 Sep 2008 17:33:28 +0000</pubDate>
		<dc:creator>James Gregory</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[NHibernate]]></category>
		<category><![CDATA[Work]]></category>
		<category><![CDATA[Logging]]></category>
		<category><![CDATA[Performance]]></category>

		<guid isPermaLink="false">http://blog.jagregory.com/?p=105</guid>
		<description><![CDATA[We had an issue recently where NHibernate was performing very poorly on our production server, but not on our developer machines or our test server. I investigated the issue and narrowed it down to two symptoms.
Symptom 1:
Very poor performance. I&#8217;m talking 10+ seconds per page load, with no more than 5 queries being executed by [...]]]></description>
			<content:encoded><![CDATA[<p>We had an issue recently where NHibernate was performing very poorly on our production server, but not on our developer machines or our test server. I investigated the issue and narrowed it down to two symptoms.</p>
<p><strong>Symptom 1:</strong><br />
Very poor performance. I&#8217;m talking 10+ seconds per page load, with no more than 5 queries being executed by NHibernate.</p>
<p><strong>Symptom 2:</strong><br />
Empty log files. None of our log files had any data in on the live server, but they did on our other systems.</p>
<p>I decided to investigate the second symptom first, as it may be causing the first (ends up it was).</p>
<p>Firstly, I noticed that our logging was set to DEBUG. Must&#8217;ve been a leftover from when we first deployed NHibernate, very sloppy, I know. So I reset that to WARN, but it had no effect.</p>
<p>When files aren&#8217;t being written to, you should always check the directory permissions. Low and behold, it was a permissions problem. Our test server had different users allowed to write to the Logs directory than our production server. I granted the same users access, NETWORK SERVICE and IUSR_MACHINENAME in our case.</p>
<p>After I recycled the IIS worker processes, we were flying again. We&#8217;re back to having < 1sec page loads.</p>
<p>This is pure speculation, but what I believe was happening is this: Logging was set to DEBUG, so it was logging <em>a lot</em>. With each log call, the logger was failing to get write access to the files and throwing an exception, that exception would probably have propagated a bit too. The combination of the sheer amount of data being written to the log, and an exception per log call, were responsible for the severe slowdown.</p>
<p>So in short: Always make sure NHibernate has write access to its own log directory!</p>
]]></content:encoded>
			<wfw:commentRss>http://jagregory.com/writings/empty-nhibernate-logs-and-poor-performance/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Freeing the model from its evil web-service oppressors</title>
		<link>http://jagregory.com/writings/freeing-the-model-from-its-evil-web-service-oppressors/</link>
		<comments>http://jagregory.com/writings/freeing-the-model-from-its-evil-web-service-oppressors/#comments</comments>
		<pubDate>Sun, 18 May 2008 15:39:24 +0000</pubDate>
		<dc:creator>James Gregory</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Work]]></category>

		<guid isPermaLink="false">http://blog.jagregory.com/2008/05/18/freeing-the-model-from-its-evil-web-service-oppressors/</guid>
		<description><![CDATA[The current system I&#8217;m working with has a setup whereby the model (data access objects) are being used by the web-services for delivery; this means that the consumers of the web-services are directly tied to our inner implementation of our data access code. On-top of that, it&#8217;s old full of bad conventions, and is in [...]]]></description>
			<content:encoded><![CDATA[<p>The current system I&#8217;m working with has a setup whereby the model (data access objects) are being used by the web-services for delivery; this means that the consumers of the web-services are directly tied to our inner implementation of our data access code. On-top of that, it&#8217;s old full of bad conventions, and is in need of refactoring.</p>
<p>This is my account of how I freed the model from the web-service.</p>
<pre name="code" class="c-sharp">
public class vehicle_info
{
    public int vehicle_id;
    public string vehicle_name;
    public string vehicle_manufacturer;
    public DateTime vehicle_manufactured_date;
    public int vehicle_number_produced;
}
</pre>
<p>That&#8217;s the existing model. You can see that these have some nasty naming conventions that I just can&#8217;t live with anymore.</p>
<p>A large problem with pushing your model out to the web-service consumers is that I can&#8217;t refactor the classes without breaking their implementations; if I rename a field in my model, the consumers will have to update their code to deal with it. This is an issue because not all the consumers are able to update their code. So we&#8217;re stuck with how the classes were built years ago, with awful naming conventions, and no ability to change.</p>
<p>What&#8217;s the ideal setup then? It&#8217;s my opinion that we should be using specialised DTOs (Data Transfer Objects) for this purpose, they&#8217;ll exist solely to be the transport mechanism for the web-service. With DTOs you&#8217;re separating what your service pushes out from what you use internally, which allows you to refactor your internal design without any problems with integration.</p>
<pre name="code" class="c-sharp">
public class VehicleWebServiceDto
{
    public int vehicle_id;
    public string vehicle_name;
    public string vehicle_manufacturer;
    public DateTime vehicle_manufactured_date;
    public int vehicle_number_produced;
}
</pre>
<p>There&#8217;s an issue with using DTOs in an existing web-service environment, it&#8217;s unlikely your DTOs will be named the same as your original objects (if they do, you&#8217;re fine). We can&#8217;t just swap it out with a DTO, because the signatures won&#8217;t match in the WSDL.</p>
<p>When we change the web-service to return those DTOs instead of the original classes, we end up with this mismatch in the output:</p>
<pre name="code" class="xml">
&lt;vehicle_info&gt;
  &lt;vehicle_id&gt;int&lt;/vehicle_id&gt;
  &lt;vehicle_name&gt;string&lt;/vehicle_name&gt;
	...

&lt;VehicleWebServiceDto&gt;
  &lt;vehicle_id&gt;int&lt;/vehicle_id&gt;
  &lt;vehicle_name&gt;string&lt;/vehicle_name&gt;
	...
</pre>
<p>How can we get around this? Make the signatures match.</p>
<p>You can control the way objects are serialized by the web-service through the serialization attributes; namely the <code>XmlRoot</code> and <code>SoapType</code> attributes are the ones you&#8217;re looking for, these allow you to override what name is output in the xml for your class. Slap on those attributes, one for the standard HTTP usage and the other for SOAP, and give them your old class name; then as far as the consumers of the webservice can see, you&#8217;re giving them the same old classes. Now you have a separate DTO from your domain layer, but without breaking the schema.</p>
<p>These are the updated DTO objects:</p>
<pre name="code" class="c-sharp">
[XmlRoot(&quot;vehicle_info&quot;), SoapType(&quot;vehicle_info&quot;)]
public class VehicleWebServiceDto
{
    public int vehicle_id;
    public string vehicle_name;
    public string vehicle_manufacturer;
    public DateTime vehicle_manufactured_date;
    public int vehicle_number_produced;
}
</pre>
<p>Which now produce this xml:</p>
<pre name="code" class="xml">
&lt;vehicle_info&gt;
  &lt;vehicle_id&gt;int&lt;/vehicle_id&gt;
  &lt;vehicle_name&gt;string&lt;/vehicle_name&gt;
	...
</pre>
<p>We are now free to refactor our code as much as we like, without affecting the output of the web-service.</p>
<pre name="code" class="c-sharp">
public class Vehicle
{
    public int ID { get; set; }
    public string Name { get; set; }
    public ManufacturingDetails ManufacturingDetails { get; set; }
}

public class ManufacturingDetails
{
    public Manufacturer Manufacturer { get; set; }
    public DateTime ManufacturedDate { get; set; }
    public int NumberProduced { get; set; }
}

public class Manufacturer
{
    public int ID { get; set; }
    public string Name { get; set; }
}
</pre>
<p>Magic.</p>
]]></content:encoded>
			<wfw:commentRss>http://jagregory.com/writings/freeing-the-model-from-its-evil-web-service-oppressors/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Amusing &#8220;Recommend a Friend&#8221; usage</title>
		<link>http://jagregory.com/writings/amusing-quotrecommend-a-friendquot-usage/</link>
		<comments>http://jagregory.com/writings/amusing-quotrecommend-a-friendquot-usage/#comments</comments>
		<pubDate>Thu, 15 Jun 2006 13:16:00 +0000</pubDate>
		<dc:creator>James Gregory</dc:creator>
				<category><![CDATA[Humor]]></category>
		<category><![CDATA[Work]]></category>

		<guid isPermaLink="false">http://blog.jagregory.com/?p=7</guid>
		<description><![CDATA[We’ve been sending out a (rather successful) e-mail campaign for Swift over the past few days, a good experience and definitely an eye opener. Something that amused me over the course of the project was the way people were using the “Recommend a Friend” feature of the e-mail.
If you’re presented by a form, which asks [...]]]></description>
			<content:encoded><![CDATA[<p>We’ve been sending out a (rather successful) e-mail campaign for <a href="http://www.swiftleisure.co.uk">Swift</a> over the past few days, a good experience and definitely an eye opener. Something that amused me over the course of the project was the way people were using the “Recommend a Friend” feature of the e-mail.</p>
<p>If you’re presented by a form, which asks for your friends name, e-mail address and some form of comment from yourself, what would you put in the name field? Common sense says that you should put their full name in, as generally that’s what people want; not these people though! Over 50% of the recommendations were supplied with first names only or nicknames &#8211; the most wonderful being “MUM”; yes, block capitals too.</p>
<p>So we have a nice collection of recommendations along the lines of:</p>
<ol>
<li>George</li>
<li>Sally</li>
<li>Geoff</li>
<li>liz</li>
<li>MUM</li>
</ol>
<p>How very helpful.</p>
<p>They’ll love the targeted e-mails they’re bound to receive too; “Dear MUM, we think…”.</p>
]]></content:encoded>
			<wfw:commentRss>http://jagregory.com/writings/amusing-quotrecommend-a-friendquot-usage/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>First working weekend</title>
		<link>http://jagregory.com/writings/first-working-weekend/</link>
		<comments>http://jagregory.com/writings/first-working-weekend/#comments</comments>
		<pubDate>Mon, 23 Jan 2006 21:45:00 +0000</pubDate>
		<dc:creator>James Gregory</dc:creator>
				<category><![CDATA[Work]]></category>

		<guid isPermaLink="false">http://blog.jagregory.com/?p=28</guid>
		<description><![CDATA[The weekend just past was my first that I’ve had to work since I left Tesco. Not an entirely unpleasant experience, although I would have much rather had my weekend.
The reason we had to work the weekend was down to us launching (re-launching actually) a product for the Swift Group’s extranet, something that a lot [...]]]></description>
			<content:encoded><![CDATA[<p>The weekend just past was my first that I’ve had to work since I left Tesco. Not an entirely unpleasant experience, although I would have much rather had my weekend.</p>
<p>The reason we had to work the weekend was down to us launching (re-launching actually) a product for the Swift Group’s extranet, something that a lot of people had been rather worried about. Mainly because, apparently, the previous time this product was launched it corrupted important data for six months without anyone noticing. Wonderful.</p>
<p>Something I wasn’t too happy about when I first inherited this project is that it was my sole responsibility. Slowly I came around to the idea though, it would be all my fault if everything went wrong, true, but it’d also be all down to me if everything went well; looks pretty good being responsible for a whole project only 10 months into a job.</p>
<p>Anyway, this is now day 1 of the launch at an end and a few niggling things aside, everything went swimmingly. No show stopping bugs at all, only minor things that took barely more than a minute to fix. I can safely say I’m in the good books.</p>
<p>Here’s to day 2 going as well as day 1.</p>
]]></content:encoded>
			<wfw:commentRss>http://jagregory.com/writings/first-working-weekend/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Launching woes</title>
		<link>http://jagregory.com/writings/launching-woes/</link>
		<comments>http://jagregory.com/writings/launching-woes/#comments</comments>
		<pubDate>Fri, 02 Sep 2005 23:10:00 +0000</pubDate>
		<dc:creator>James Gregory</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[Work]]></category>

		<guid isPermaLink="false">http://blog.jagregory.com/?p=37</guid>
		<description><![CDATA[Launch problems, they always occur. Yesterday (1st September) was no exception, we launched this years Swift Leisure website; a bloody huge site. As soon as it got up there it fell over, which was unfortunate. After some investigation we narrowed it down to the Url Rewriter that we have in place (unfortunately, solely my work!).
The [...]]]></description>
			<content:encoded><![CDATA[<p>Launch problems, they always occur. Yesterday (1st September) was no exception, we launched this years Swift Leisure website; a bloody huge site. As soon as it got up there it fell over, which was unfortunate. After some investigation we narrowed it down to the Url Rewriter that we have in place (unfortunately, solely my work!).</p>
<p>The big problem with it was that it replaces the Request.ApplicationPath in any requested path with a blank string to remove any unnecessary parts of the path; “SwiftLeisure2006/Caravans/Abbey” became “Caravans/Abbey”. This worked fine on our local setup but we didn’t account for possible changes in the Request.ApplicationPath when the site is situated directly in the root instead of a sub-folder. The Request.ApplicationPath became just “/” which means “/Caravans/Abbey” became “CaravansAbbey” instead of “Caravans/Abbey”. Simple fix once we figured this out and found any similar sections throughout our controls.</p>
<p>Live and learn, live and learn.</p>
]]></content:encoded>
			<wfw:commentRss>http://jagregory.com/writings/launching-woes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Exception Logging</title>
		<link>http://jagregory.com/writings/exception-logging/</link>
		<comments>http://jagregory.com/writings/exception-logging/#comments</comments>
		<pubDate>Mon, 18 Jul 2005 23:00:00 +0000</pubDate>
		<dc:creator>James Gregory</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[Work]]></category>

		<guid isPermaLink="false">http://blog.jagregory.com/?p=41</guid>
		<description><![CDATA[Something I’ve always been tinkering with for my ASP.Net applications has been exception logging. I often get irritated when users (or applications) supply me with misleading or incorrect error messages, or at least incorrect directions of how to recreate the error.
I worked for quite some time trying to create a Logging system that would cater [...]]]></description>
			<content:encoded><![CDATA[<p>Something I’ve always been tinkering with for my ASP.Net applications has been exception logging. I often get irritated when users (or applications) supply me with misleading or incorrect error messages, or at least incorrect directions of how to recreate the error.</p>
<p>I worked for quite some time trying to create a Logging system that would cater for my needs, and I got quite close to doing that. I created a small go-between object for the Trace and Debug logging and wrote that to my own XML file. The idea behind it, of course, was to make it easier for my self in debugging problems, if I could supply my self with all the data that I know I would require to trace an issue then, in theory, I could correct it much more quickly. This took me quite some time to create and of course was not perfect.</p>
<p>There were a few major (a.k.a. Huge) issues with my system, firstly the logger would only interact with your code wherever you explicitly told it to. Basically you had to write extra code wherever you wanted to log an exception. This was neither friendly nor desirable. The next issue was access rights for the XML files; this reared its head in a few shapes and forms. One of the instances didn’t occur very often but was a pain when it did; the writer was rejected write access due to another instance of itself actually writing to the file. I remedied this by making the writer wait until the other was done; this of course had performance implications though, having to stop everything within a page while the log writer sits idle. The other time it was an issue was whenever I wanted to archive the logs I had to wait until no other instances were accessing it, this also involved waiting but it takes longer to rename a file and create a new one than it does to simply amend a file.</p>
<p>The problem of having to explicitly declare any usage of the writer was the deciding factor in me binning my writer. Sad as it is to see something that I spent a fair amount of time creating deleted, it’s always slightly reassuring when you’re moving onto a product that is fully tested and working and also includes all source code! More on that soon though…</p>
]]></content:encoded>
			<wfw:commentRss>http://jagregory.com/writings/exception-logging/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Personal Note: The new job</title>
		<link>http://jagregory.com/writings/back-once-again/</link>
		<comments>http://jagregory.com/writings/back-once-again/#comments</comments>
		<pubDate>Mon, 06 Jun 2005 22:54:00 +0000</pubDate>
		<dc:creator>James Gregory</dc:creator>
				<category><![CDATA[Personal]]></category>
		<category><![CDATA[Work]]></category>

		<guid isPermaLink="false">http://blog.jagregory.com/?p=43</guid>
		<description><![CDATA[Since getting my new job I’ve been rather quiet on the blogging side of things, mostly do to the fact that I’m actually doing something with my time rather than just sitting around tinkering. Strange I know, but you get used to it.
As you’d probably expect, I’m not really supposed to talk about what I [...]]]></description>
			<content:encoded><![CDATA[<p>Since getting my new job I’ve been rather quiet on the blogging side of things, mostly do to the fact that I’m actually doing something with my time rather than just sitting around tinkering. Strange I know, but you get used to it.</p>
<p>As you’d probably expect, I’m not really supposed to talk about what I do for security reasons of course. It’s mostly working for the Swift group (caravans, motorhomes) doing their internal systems and web sites. Other things as well, but it’s mainly that. It’s all very interesting, a big change from serving customers in a supermarket thats for sure. It’s a really strange feeling actually going to work and learning something, I generally come home every night having picked something new up.</p>
<p>Since I started the job I’ve learnt that my coding abilities are much better than I thought they were, having being subjected to the woes that are legacy code. Definetly a nice feeling, it’s always rather hard to rate your abilities when you have nothing to compare them against. For better or for worse I’ve been developing in VB.Net, something I tried to stay away from when coding for my self but haven’t been able to avoid recently. Not my cup of tea really but it’s another addition to the CV. Speaking of legacy code, there’s been some serious Daily WTF material lying around. A prime example was this beauty:</p>
<pre><code>Sub Function GetTime(ByVal hours, ByVal minutes)
    Dim hours
    Dim minutes
    Dim yHours

    yHours = hours * minutes

    GetTime = (yHours / minutes) + (hours * minutes)
End Sub
</code></pre>
<p>Really interesting! Note the lack of any variable type declarations as well! It hasn’t all been like this, but there certainly a lot of amusing things.</p>
<p>One resource I’ve found invaluable since starting to code professionally is <a href="http://www.hanselman.com/">Scott Hanselman</a>’s <a href="http://www.hanselman.com/blog/content/radiostories/2003/09/09/scottHanselmansUltimateDeveloperAndPowerUsersToolsList.html">utilities list</a>, there are so many handy little tools there that I can’t believe I’ve managed to live without! Some perfect examples are <a href="http://www.aisto.com/roeder/dotnet/">Lutz’s Reflector</a> and <a href="http://www.sliver.com/dotnet/ruler/">Jeff Key’s Screen Ruler</a>. A tool for “reverse engineering” compiled .Net assemblys and a floatable screen ruler respectivly.</p>
<p>Hopefully I’ll be getting back into this properly soon, until then, have fun.</p>
]]></content:encoded>
			<wfw:commentRss>http://jagregory.com/writings/back-once-again/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Goodbye Tesco</title>
		<link>http://jagregory.com/writings/goodbye-tesco/</link>
		<comments>http://jagregory.com/writings/goodbye-tesco/#comments</comments>
		<pubDate>Mon, 11 Apr 2005 22:50:00 +0000</pubDate>
		<dc:creator>James Gregory</dc:creator>
				<category><![CDATA[Personal]]></category>
		<category><![CDATA[Work]]></category>

		<guid isPermaLink="false">http://blog.jagregory.com/?p=45</guid>
		<description><![CDATA[I’m outta there, finally free from the bounds of a supermarket job. I’ve been taken in by Evolution Interactive, a web/multimedia design company.
I’m now a ‘New Media Developer’, nicer than ‘Checkout Assistant’ if I do say so my self. It’s very strange to be in a real job, doing something that I actually want to [...]]]></description>
			<content:encoded><![CDATA[<p>I’m outta there, finally free from the bounds of a supermarket job. I’ve been taken in by Evolution Interactive, a web/multimedia design company.</p>
<p>I’m now a ‘New Media Developer’, nicer than ‘Checkout Assistant’ if I do say so my self. It’s very strange to be in a real job, doing something that I actually want to do (and like doing). This is going to take some getting used to…</p>
]]></content:encoded>
			<wfw:commentRss>http://jagregory.com/writings/goodbye-tesco/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
