<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom">
 
  <title>kieransenior.co.uk</title>
  <link href="http://kieransenior.co.uk/"/>
  <link type="application/atom+xml" rel="self" href="http://kieransenior.co.uk/atom.xml"/>
  <updated>2012-01-16T20:42:33+00:00</updated>
  <id>http://kieransenior.co.uk/</id>
  <author>
    <name>Kieran Senior</name>
    <email>kieran@kieransenior.co.uk</email>
  </author>

  
  <entry>
    <id>http://kieransenior.co.uk/2012/01/cURL-HTTPS-Excess-found-in-a-non-pipelined-read</id>
    <link type="text/html" rel="alternate" href="http://kieransenior.co.uk/2012/01/cURL-HTTPS-Excess-found-in-a-non-pipelined-read/"/>
    <title>cURL HTTPS&colon; &quot;Excess found in a non pipelined read&quot;</title>
    <updated>2012-01-16T19:35:00+00:00</updated>
    <author>
      <name>Kieran Senior</name>
      <uri>http://kieransenior.com/</uri>
    </author>
    <content type="html">&lt;p&gt;At my primary job we run automated processes that upload XML data to web services via POST requests. This suits us fine because it means we can upload the data from any authenticated location. To do this I use cURL. Recently however the process just stopped working.&lt;/p&gt;

&lt;p&gt;Many changes had been made to the application in question so I could put it down to a number of things. To test it I manually ran the process from the calling server and was confused when I saw the following:&lt;/p&gt;

&lt;p&gt;&amp;#8220;Excess found in a non pipelined read&amp;#8221;&lt;/p&gt;

&lt;p&gt;This message is particularly useless when searching on google. It seems no-one has any idea why it&amp;#8217;s occurring in certain circumstances. A 302 was seen in the request and then it clicked. We are now using HTTPS as opposed to HTTP, it was down to the fact that the request was failing due to security.&lt;/p&gt;

&lt;p&gt;So, go to &lt;a href='http://www.paehl.com/open_source/?CURL_7.23.1'&gt;http://www.paehl.com/open_source/?CURL_7.23.1&lt;/a&gt; and get the SSH2/SSL version of cURL and also get the OpenSSL DLL&amp;#8217;s. If you place the OpenSSL DLL&amp;#8217;s in the same directory it then the SSH2/SSL version of cURL will work just fine.&lt;/p&gt;

&lt;p&gt;In my environment I used the -k flag to ignore the SSL certificate that would ultimately cause the request to fail once again. Also ensure you&amp;#8217;re using &amp;#8220;https&amp;#8221; in your request and not &amp;#8220;http&amp;#8221;.&lt;/p&gt;

&lt;p&gt;Basically, the error message you receive in this instance isn&amp;#8217;t reflective of what&amp;#8217;s actually going on behind the scenes. The error message does make sense if you take a look at the C source code hosted in various places. Just do a search for the message you receive once the request is received and you&amp;#8217;ll see why it happens. It doesn&amp;#8217;t matter though, provided you&amp;#8217;ve got the correct libs and are making the correct request then it&amp;#8217;ll work fine.&lt;/p&gt;</content>
  </entry>
  
  <entry>
    <id>http://kieransenior.co.uk/2011/09/avchd-in-imovie</id>
    <link type="text/html" rel="alternate" href="http://kieransenior.co.uk/2011/09/avchd-in-imovie/"/>
    <title>AVCHD in iMovie</title>
    <updated>2011-09-06T15:54:35+01:00</updated>
    <author>
      <name>Kieran Senior</name>
      <uri>http://kieransenior.com/</uri>
    </author>
    <content type="html">&lt;p&gt;Someone at Apple headquarters messed up seeing as though iMovie doesn&amp;#8217;t support a very popular video format, AVCHD used across all of the Panasonic range of HD video cameras. I finally decided to cave and get some software, however I saw an &lt;a href='http://www.macworld.com/article/147011/2010/03/convert_avchd_imovie.html'&gt;article&lt;/a&gt;&amp;#8221; about using &lt;a href='http://www.clipwrap.com/'&gt;ClipWrap&lt;/a&gt; which &amp;#8220;wraps&amp;#8221; the video. You have a queue of MTS files straight from your video camera and simply convert them to .mov format. From here you&amp;#8217;d then import them into iMovie if you wanted to cut and edit the videos. It takes a long time on my 3 year old MBP with 1080 videos. A 5 minute video takes about 25 minutes to import into iMovie, and just a few minutes to convert. You can then watch them immediately in their .mov format. It&amp;#8217;s a simple-to-use piece of software, but I thought I&amp;#8217;d recommend it as there&amp;#8217;s a few out there that don&amp;#8217;t seem great. I better finish up before my laptop melts.&lt;/p&gt;</content>
  </entry>
  
  <entry>
    <id>http://kieransenior.co.uk/2011/09/noah-bladon-senior-born-31082011</id>
    <link type="text/html" rel="alternate" href="http://kieransenior.co.uk/2011/09/noah-bladon-senior-born-31082011/"/>
    <title>Noah Bladon Senior - Born 31/08/2011</title>
    <updated>2011-09-03T21:59:59+01:00</updated>
    <author>
      <name>Kieran Senior</name>
      <uri>http://kieransenior.com/</uri>
    </author>
    <content type="html">&lt;img alt='' height='612' src='http://images.instagram.com/media/2011/09/01/0224371b6e1047338f73426a4ea265ae_7.jpg' width='612' /&gt;
&lt;p&gt;Say hello to Noah, our son who was born this week. Cute indeed!&lt;/p&gt;</content>
  </entry>
  
  <entry>
    <id>http://kieransenior.co.uk/2011/08/the-one-size-glove</id>
    <link type="text/html" rel="alternate" href="http://kieransenior.co.uk/2011/08/the-one-size-glove/"/>
    <title>The One-Size Glove</title>
    <updated>2011-08-19T11:45:58+01:00</updated>
    <author>
      <name>Kieran Senior</name>
      <uri>http://kieransenior.com/</uri>
    </author>
    <content type="html">&lt;p&gt;I&amp;#8217;m sure you&amp;#8217;ve heard that marketing statement &amp;#8220;One Size Fits All!&amp;#8221; before, and I&amp;#8217;m also sure you&amp;#8217;re fully aware that whilst the statement holds true in the majority of cases, it&amp;#8217;s also true that it isn&amp;#8217;t a great fit. Taylorism is okay for that which can be used in a specific manner. A car is a good example, as in 99% of cases it will be perfectly suited to the driver. 1% of those won&amp;#8217;t be able to use the car for one reason or another, or it may be troublesome for them to use it.&lt;/p&gt;

&lt;p&gt;In software this is also the case, however the percentile division is much greater because it&amp;#8217;s not a case of getting from A to B but instead of dealing with unique problems. Many software systems nowadays fulfil the most common tasks very well, but anything beyond this has a number of effects.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;That the system cannot fulfil the required task at all, and that the adoption of such software was short sightedness on behalf of the analysts.&lt;/li&gt;

&lt;li&gt;Enhancing the existing software package comes at a great cost in software development resources - in some cases it would&amp;#8217;ve been more beneficial to develop a software system from scratch&lt;/li&gt;

&lt;li&gt;The system &lt;em&gt;can&lt;/em&gt; do the required task, but only by using the system incorrectly.&lt;/li&gt;

&lt;li&gt;There is no funding available to enhance the system and so a number of methods are adopted to counter the lack of functionality. In some cases, I&amp;#8217;ve seen people using both filing systems and computer systems to carry out a single task.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So people sometimes say to me &amp;#8220;Why not just use WordPress?&amp;#8221; or &amp;#8220;Why not just use CRM?&amp;#8221; and then I highlight the above points. Recently I had a meeting with two companies who did the exact same thing, and the plan was to develop a single software system at a reduced cost because we&amp;#8217;d essentially be building the same thing, but upon closer review of their processes it was shown that not only do they record data differently but the very process of recording data was different. Even the database schema itself wouldn&amp;#8217;t be the same, and yet these companies offer the exact same services.&lt;/p&gt;

&lt;p&gt;So what&amp;#8217;s truly the problem? It&amp;#8217;s neglecting the ever important details of software systems that determine its success or failure. It&amp;#8217;s noticing that company A do things very differently from company B. We suffer from a tunnel vision, blinkers of &amp;#8220;the one-size glove&amp;#8221;. It&amp;#8217;s a kind of wishful thinking that actually causes us to doubt our own skills when we&amp;#8217;re in the midst of software development.&lt;/p&gt;

&lt;p&gt;What&amp;#8217;s the result of the problem? It&amp;#8217;s bad practises. Very, very bad practises. Nowadays I read articles saying &amp;#8220;it&amp;#8217;s perfectly okay not to have any DB-level constraints!&amp;#8221; (although this is a topic for another article entirely). I cringe at this, not because I suffer from acute pedantry, but because the statement shows how people are happy to forfeit good principles for an easier ride on the software train.&lt;/p&gt;

&lt;p&gt;Fortunately I only ever really develop bespoke systems, but if there&amp;#8217;s one thing I&amp;#8217;ve learnt from working in the software industry is that this syndrome of the one-size glove is becoming ever more present as a result of the rise in popularity of software systems capable of achieving many tasks. It generates huge problems in that businesses are spending more money to get less than what they could&amp;#8217;ve got had they developed a bespoke system, and even when they get what they want it doesn&amp;#8217;t end up doing it very well.&lt;/p&gt;

&lt;p&gt;Fordism/Taylorism has its place even in software, but only for very common tasks. If your problem scope differs even very slightly from someone else&amp;#8217;s, then you&amp;#8217;re probably looking at a different software system to achieve your goals. Unfortunately most people find out only until it&amp;#8217;s too late.&lt;/p&gt;</content>
  </entry>
  
  <entry>
    <id>http://kieransenior.co.uk/2011/08/nhibernate-3-2-initial-thoughts</id>
    <link type="text/html" rel="alternate" href="http://kieransenior.co.uk/2011/08/nhibernate-3-2-initial-thoughts/"/>
    <title>NHibernate 3.2 - Initial Thoughts</title>
    <updated>2011-08-09T12:40:27+01:00</updated>
    <author>
      <name>Kieran Senior</name>
      <uri>http://kieransenior.com/</uri>
    </author>
    <content type="html">&lt;p&gt;You may have seen that NH 3.2 is out in the wild and being scarcely used due to its significant lack of documentation verbose enough to make any kind of sense. I have been on an uphill struggle trying to figure out how much of it works comparative to my previous use of NH 3.1 with a Fluent NHibernate configuration. This isn&amp;#8217;t a limitation to the framework, it&amp;#8217;s just because there aren&amp;#8217;t many examples out there yet so hopefully this post will clear up a few things on how to set your environment up as well as having more complicated mappings.&lt;/p&gt;

&lt;p&gt;As you may know, NH 3.2 has a fluent-like mapping which isn&amp;#8217;t actually fluent (it uses ConfORM), there has been a mixed reaction from the community in regards to this, some saying it&amp;#8217;s too heavy-weight for the NH framework and should be kept in its own library. From the examples I&amp;#8217;ve seen of the new mapping configuration I think it&amp;#8217;s brilliant for a number of reasons.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It matches the XML mapping configurations often seen containing concepts such as Set, Bag, OneToMany, ManyToOne etc. etc.&lt;/li&gt;

&lt;li&gt;You can specify your own mapping configuration, so if you were to port your Fluent NHibernate (FNH) mapping configuration over to NH 3.2 then you&amp;#8217;d only have to add a couple of lines of code to get it working despite looking the same as the FNH configuration.&lt;/li&gt;

&lt;li&gt;Like some prior options, you can actually create/update your schema directly from your mappings, and it works very well too. There are &lt;a href='http://twitter.com/#!/kieransenior/status/85680133431758848'&gt;some quirks that I had noted however&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id='setting_up_your_environment'&gt;Setting Up Your Environment&lt;/h2&gt;

&lt;p&gt;There is barely any documentation whatsoever in regards to this, so beware. My environment was mainly written from scratch with some inspiration from various areas, so it may seem a little weird to you, but it fit the needs of applications I have developed quite well. I&amp;#8217;ll give the entire scope so you can understand. There&amp;#8217;s a number of key files that make up my architecture giving the overall picture. Don&amp;#8217;t worry for now, I&amp;#8217;ll cover these in more detail later on.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Utils&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Mappings.cs&lt;/strong&gt;: in other projects I separated out all of my mappings for each entity, however one of my current projects - as a result of the transition to NH 3.2 - contains a single class called Mappings with a public static method GetMappings() which sets up all of the mappings.&lt;/li&gt;

&lt;li&gt;&lt;strong&gt;NHibernateSessionPerRequest.cs&lt;/strong&gt;: quite a long name, but this basically manages my sessions on a per-request basis. There is some NH 3.2 stuff in here so it&amp;#8217;s worth covering.&lt;/li&gt;

&lt;li&gt;&lt;strong&gt;WindsorControllerFactory.cs&lt;/strong&gt;: you&amp;#8217;d have probably seen this code around the Internet quite often, it&amp;#8217;s just part of IoC to get the concrete instance of a controller.&lt;/li&gt;

&lt;li&gt;&lt;strong&gt;NHibernateInstaller.cs&lt;/strong&gt;: this specifically defines the IoC registration so for an occurrence of an interface it uses whichever concrete implementation I choose.&lt;/li&gt;

&lt;li&gt;&lt;strong&gt;ControllerInstaller.cs&lt;/strong&gt;: heck, I&amp;#8217;ve forgotten what this does, but I know it should be there. Hey, at least I&amp;#8217;m honest.&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;

&lt;li&gt;
&lt;p&gt;Repositories&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;SessionHandler.cs&lt;/strong&gt;: this handles my session state by getting the current session for me from NHibernateSessionPerRequest. It&amp;#8217;s kept with the repositories though.&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I also use AutoMapper to map my models to view models and vice versa.&lt;/p&gt;

&lt;h3 id='mappings'&gt;Mappings&lt;/h3&gt;

&lt;p&gt;The Mappings.cs file is the most important class here as it&amp;#8217;s used to set up all of the mappings. I&amp;#8217;ve only actually worked with two entities so far, however they&amp;#8217;re going to be getting quite complicated as they&amp;#8217;re self-referential and have virtual mappings (entities which don&amp;#8217;t exist at the DB-level). In my case all of my mappings are set up in this single file, but in previous projects I&amp;#8217;d have a class per entity mapping (that is, derivations of a class may exist in the same mapping class). Because of the matching against the XML mapping configurations you can use your prior knowledge in these files.&lt;/p&gt;

&lt;h3 id='nhibernatesessionperrequest'&gt;NHibernateSessionPerRequest&lt;/h3&gt;

&lt;p&gt;This file begins and ends transactions. There&amp;#8217;s pro&amp;#8217;s and con&amp;#8217;s to this implementation, and I&amp;#8217;ve actually weighed up a few. Some people prefer to explicitly open and close their sessions, you can do this in languages such as C# by using &amp;#8220;using&amp;#8221; statements. My implementation was a mixture of other solutions I had seen, when an entire web request finishes, that&amp;#8217;s when the session is committed to the database. This does run the risk that if your presentation layer for some reason fails unexpectedly then it may mean the session didn&amp;#8217;t complete. This may seem illogical but to the end-user it may make sense &amp;#8220;I didn&amp;#8217;t see something finish therefore it can&amp;#8217;t have completed&amp;#8221;.&lt;/p&gt;

&lt;p&gt;This file also creates my session factory like so:&lt;/p&gt;

&lt;p&gt;&lt;span&gt;gist id=1133791&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;Be very careful as to what &amp;#8220;SchemaAction&amp;#8221; you use, otherwise you could end up deleting your data when new sessions are set up. I&amp;#8217;ve found that updating key fields to have identity specifications don&amp;#8217;t work using SchemaAutoAction.Update, but they work when creating new columns. It&amp;#8217;s a bit buggy, so you may want to stick to migrations until they improve this functionality.&lt;/p&gt;

&lt;h2 id='the_mapper'&gt;The Mapper&lt;/h2&gt;

&lt;p&gt;To set the mapper up you first instantiate a ModelMapper instance and then use this to &amp;#8220;do stuff&amp;#8221;. To be honest, the possibilities are quite endless, and it&amp;#8217;s all dependent on your DB structure. Let&amp;#8217;s take a full example to start with:&lt;/p&gt;

&lt;p&gt;&lt;span&gt;gist id=1133812&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;This is very simple, and there&amp;#8217;s a few oddities. I specify the column because by default it doesn&amp;#8217;t use this convention, so you have to explicitly state it. The identity generator doesn&amp;#8217;t work if you add it after the schema has been created, prompting me to drop and re-create my schema quite a lot. It&amp;#8217;d be easier if you added this and also added a migration, but always make sure you watch the issued SQL statements to ensure the updates to your DB have been issued. There&amp;#8217;s likely a very good reason for this, because in some circumstances data can be damaged or lost during the update so it&amp;#8217;s better if you run the migrations yourself. Here&amp;#8217;s a slightly more complicated example:&lt;/p&gt;

&lt;p&gt;&lt;span&gt;gist id=1133801&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;And finally, a fuller example:&lt;/p&gt;

&lt;p&gt;&lt;span&gt;gist id=1133804&lt;/span&gt;&lt;/p&gt;

&lt;h2 id='conclusion'&gt;Conclusion&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Some updates to your mapping file don&amp;#8217;t issue updates to the DB. I assume this is for safety reasons.&lt;/li&gt;

&lt;li&gt;You should write a migration of some form or shape to do the more complicated updates for your (which could, for example, drop and re-create columns in your tables).&lt;/li&gt;

&lt;li&gt;There&amp;#8217;s a lot of set up work involved in getting these more complicated mappings working, but the end result is worth it, and the framework is transferable to other projects quite simply.&lt;/li&gt;

&lt;li&gt;Some aspects are quite confusing, such as inverse mappings which in some cases are required even if you thought they don&amp;#8217;t belong.&lt;/li&gt;

&lt;li&gt;Specify key columns with their respective names manually, otherwise NH3.2 will use default naming conventions which may not meet your company DB-naming conventions.&lt;/li&gt;

&lt;li&gt;When firing up your web instance, use something like SQL Profiler to watch what schema updates are occurring relational to your changes in the mapping file - this will ensure the correct updates are being issued reflective of your changes to the schema. Identity generators for example may not work if they were changed after the table has been created.&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry>
  
  <entry>
    <id>http://kieransenior.co.uk/2011/06/model-management</id>
    <link type="text/html" rel="alternate" href="http://kieransenior.co.uk/2011/06/model-management/"/>
    <title>Model Management</title>
    <updated>2011-06-28T08:20:20+01:00</updated>
    <author>
      <name>Kieran Senior</name>
      <uri>http://kieransenior.com/</uri>
    </author>
    <content type="html">&lt;p&gt;I&amp;#8217;ve spent quite a few years working with MVC architectures, but of course many architectures employ a model-oriented approach to developing software systems. There are many great reasons to do this especially if you&amp;#8217;re looking to port your system or re-use the models of your existing system elsewhere. You may often get told that there are no plans to port the system, or to re-use the existing models for other purposes (some derivations of the system perhaps). Either way it doesn&amp;#8217;t matter, it&amp;#8217;s good practice to keep your models as close to the actual representation of the entity/object - or whatever you want to call it -as possible.&lt;/p&gt;

&lt;p&gt;There will be times when you need to extend your models somewhat for domain-specific reasons. Let&amp;#8217;s say for example you had a model, &amp;#8220;City&amp;#8221; which had an attribute of &amp;#8220;Population&amp;#8221; and you&amp;#8217;re asked a question; &amp;#8220;what constitutes a small, medium and large city?&amp;#8221; The thing with this is dependent upon the context in some instances, so in one system it may be small and yet in another it could be large for the same population group. Don&amp;#8217;t ask me why this happens, it just happens. Of course there&amp;#8217;s many approaches to domain-dependent properties like this, some are database-driven, others are stored by text in XML configuration files, and others are compiled into the source code. Our system may depend upon these specifications so we need a way to keep our models as realistic as possible without tarnishing their correctness. There&amp;#8217;s a few methods to doing this, and it will also depend upon your environment/tools available through your language. As I spend 95% of my time working in C# then you&amp;#8217;ll find these examples quite specific to C#.&lt;/p&gt;

&lt;h2 id='1_subclassing'&gt;1. Subclassing&lt;/h2&gt;

&lt;p&gt;Okay I&amp;#8217;ll admit it, I&amp;#8217;ve never actually done this, but it&amp;#8217;s an idea I had the other day. A derivation of the model is technically a specialisation, so I couldn&amp;#8217;t see any reason why this wouldn&amp;#8217;t be valid (until proven to me otherwise). Let&amp;#8217;s again take the example of a model called &amp;#8220;City&amp;#8221;. If we wanted a property called &amp;#8220;PopulationGroup&amp;#8221; on it then we could do something like the following:&lt;/p&gt;

&lt;p&gt;&lt;span&gt;gist id=1039578&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;This way the parent class doesn&amp;#8217;t get littered with unnecessary properties that won&amp;#8217;t be used in other systems. Of course by strict OO principle it means that this subclass is a specialisation of its parent, which to some degree is true because it&amp;#8217;s specialised for the context it is set in. I&amp;#8217;d love to hear feedback on this first point.&lt;/p&gt;

&lt;h2 id='2_partial_classes'&gt;2. Partial Classes&lt;/h2&gt;

&lt;p&gt;Supposedly evil, yet they&amp;#8217;ve proved useful to many over the years for .NET. The concept is very similar to the last one except you&amp;#8217;re not extending, the final built code is a combination of all the partial classes (as long as they&amp;#8217;re in the same namespace I believe). So, much like before, you get the following.&lt;/p&gt;

&lt;p&gt;&lt;span&gt;gist id=1039581&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;The benefit being that it&amp;#8217;s not a specialisation, yet the code is separated out enough that if you were to port the original models then you could without them being littered with these domain-specific methods.&lt;/p&gt;

&lt;h2 id='3_extension_methods'&gt;3. Extension Methods&lt;/h2&gt;

&lt;p&gt;Again these are specific to .NET I believe, but once again they separate out the domain-specific code for them to be viably used. Instead, you&amp;#8217;d get something like the following:&lt;/p&gt;

&lt;p&gt;&lt;span&gt;gist id=1050675&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;Extension methods are used all over the place it seems, one reason for this is that you can extend the core language API&amp;#8217;s functionality using them which is particularly useful dependant on how you feel about defining your own functionality on top of pre-build API&amp;#8217;s.&lt;/p&gt;

&lt;h2 id='4_helpers'&gt;4. Helpers&lt;/h2&gt;

&lt;p&gt;When I say helpers, I don&amp;#8217;t mean those domain-specific ones which are used in views, I just mean in general helpers which you can pass data and a value being returned. In the previous example we could instead pass just the value to a helper which would return what we want. I always find these are &lt;em&gt;too &lt;/em&gt;decoupled from the original code, however. They would make no sense outside of the context of the domain, hence why I believe one of the previous methods makes more sense. Plus, it encourages code to be managed in an untidy manner in my opinion causing lots of code-crumbs (code that gets left behind once something has been removed from the system). Very simply we&amp;#8217;d have something that looks like the following:&lt;/p&gt;

&lt;p&gt;&lt;span&gt;gist id=1050678&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;It sure looks very clean, but there is such thing as being a clean freak which can have its drawbacks in these examples.&lt;/p&gt;

&lt;h2 id='conclusion'&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;There&amp;#8217;s a lot of varying opinions out there. After talking to some people in the industry I found that they tightly integrated their models with DAL which seemed odd to me, but only because I&amp;#8217;m used to writing systems with portable models in the event that it does need to be used elsewhere, or we are to change the underlying DAL architecture. Sure, it&amp;#8217;s like preparing for nuclear attack in a peaceful country but when it only requires a few minutes more work then the time-cost benefit is quite great. Furthering this, you can obviously identify what&amp;#8217;s part of the core system and what lay on the outer edges. This can be important during database development not to confuse higher-level model features with what should and shouldn&amp;#8217;t be stored in the database. Quite often application-level derivations of model data can be hugely beneficial, especially considering the computation overhead being so low, and process of managing your data being so much easier.&lt;/p&gt;

&lt;p&gt;I haven&amp;#8217;t got it perfect by any means, and there&amp;#8217;s a fine balance that&amp;#8217;s dependant upon your application. I don&amp;#8217;t believe it&amp;#8217;s a general rule but you should take into consideration the bigger picture when it comes to your application. For example, if another developer came along and wanted to look at a class that contains just the model information, yet held within it is a monstrosity of DAL, model data, and helpers then it makes life more difficult for newly introduced programmers, or generally others trying to manage your code.&lt;/p&gt;</content>
  </entry>
  
  <entry>
    <id>http://kieransenior.co.uk/2010/08/monorails-incorrect-executeenum-in-v2-0</id>
    <link type="text/html" rel="alternate" href="http://kieransenior.co.uk/2010/08/monorails-incorrect-executeenum-in-v2-0/"/>
    <title>MonoRail's Incorrect "ExecuteEnum" in v2.0</title>
    <updated>2010-08-13T09:10:07+01:00</updated>
    <author>
      <name>Kieran Senior</name>
      <uri>http://kieransenior.com/</uri>
    </author>
    <content type="html">&lt;p&gt;Just as a quick note, MonoRail&amp;#8217;s guides are quite inconsistent, so for those tearing their hair out over &lt;a href='http://www.castleproject.org/monorail/documentation/v20/usersguide/filters.html#accessingparams'&gt;MonoRail's &quot;Filters&quot; article&lt;/a&gt; just be reminded that ExecuteEnum does not exist in v2.0, it has since been replaced with ExecuteWhen - so anywhere you see ExecuteEnum.BeforeAction (or whatever constant you choose) should instead be ExecuteWhen.BeforeAction. I had to post as it&amp;#8217;s wasted 30 minutes of my morning.&lt;/p&gt;</content>
  </entry>
  
  <entry>
    <id>http://kieransenior.co.uk/2010/02/mysql-cant-connect-using-ruby-on-rails-mac-os-x-snow-leopard</id>
    <link type="text/html" rel="alternate" href="http://kieransenior.co.uk/2010/02/mysql-cant-connect-using-ruby-on-rails-mac-os-x-snow-leopard/"/>
    <title>MySQL Can't Connect Using Ruby On Rails Mac OS X Snow Leopard</title>
    <updated>2010-02-04T20:31:13+00:00</updated>
    <author>
      <name>Kieran Senior</name>
      <uri>http://kieransenior.com/</uri>
    </author>
    <content type="html">&lt;p&gt;I&amp;#8217;ve spent literally a week trying to get MySQL to work with Ruby On Rails. After much hair pulling, screaming, and crying I finally figured it out. Much of this article is based on the following command:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;sudo gem install mysql -- - with-mysql-config=/usr/local/mysql/bin/mysql_config&lt;/code&gt;&lt;/pre&gt;

&lt;h2 id='install_directories_arent_all_the_same'&gt;Install Directories Aren&amp;#8217;t All The Same&lt;/h2&gt;

&lt;p&gt;Contrary to the many articles out there, mysql doesn&amp;#8217;t necessarily install to the same path every time. The most common location for it to be installed to is &lt;code&gt;/usr/local/mysql/&lt;/code&gt;. Don&amp;#8217;t take this as gospel when you see it splashed around the Intarwebs. In fact, your install location could well be &lt;code&gt;/opt/local/var/db/mysql5/&lt;/code&gt; depending on the version. To find out where your mysql version is simply run &amp;#8220;location mysql_config&amp;#8221; and it should narrow your search results. If it&amp;#8217;s the first time you&amp;#8217;ve run location then the terminal will give you command required to install it. So, first of all, locate the correct mysql location.&lt;/p&gt;

&lt;h2 id='gem_install'&gt;Gem Install&lt;/h2&gt;

&lt;p&gt;Running &lt;code&gt;sudo gem install mysql&lt;/code&gt; doesn&amp;#8217;t necessarily do what you want it to do. There&amp;#8217;s no real way of checking until you specify &lt;code&gt;--with-mysql-config&lt;/code&gt; as a parameter option to the gem install. This will fall over and give you some error such as &amp;#8220;can&amp;#8217;t connect to local MySQL server through socket &amp;#8216;/tmp/mysql.sock&amp;#8217;&amp;#8220;. Realistically this doesn&amp;#8217;t help you. What it really means is that you&amp;#8217;re probably pointing to the wrong path, so as the previous step mentioned, make sure you find the correct path.&lt;/p&gt;

&lt;h2 id='xcode'&gt;XCode&lt;/h2&gt;

&lt;p&gt;It&amp;#8217;s a very good idea to install the version of XCode from the Snow Leopard DVD, otherwise things won&amp;#8217;t work. Also, Snow Leopard supports 64-bit installs now which is another reason to use it.&lt;/p&gt;

&lt;h2 id='build_from_source'&gt;Build From Source&lt;/h2&gt;

&lt;p&gt;Personally I built from source. The last link I have provided shows how to do this. There&amp;#8217;s many-a-reason to do it, most of all is the flexibility. It will take roughly half an hour to do.&lt;/p&gt;

&lt;h2 id='resources'&gt;Resources&lt;/h2&gt;

&lt;p&gt;&lt;a href='http://stackoverflow.com/questions/1357997/snow-leopard-ruby-1-9-1-mysql-gem-huge-problems'&gt;http://stackoverflow.com/questions/1357997/snow-leopard-ruby-1-9-1-mysql-gem-huge-problems&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href='http://stackoverflow.com/questions/1923265/installing-mysql-and-mysql-gem-on-snow-leopard'&gt;http://stackoverflow.com/questions/1923265/installing-mysql-and-mysql-gem-on-snow-leopard&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href='http://www.icoretech.org/2009/08/install-mysql-and-mysql-ruby-gem-on-snow-leopard-64-bit/'&gt;http://www.icoretech.org/2009/08/install-mysql-and-mysql-ruby-gem-on-snow-leopard-64-bit/&lt;/a&gt; (read this one first)&lt;/p&gt;</content>
  </entry>
  
  <entry>
    <id>http://kieransenior.co.uk/2010/01/jquery-visible-bug</id>
    <link type="text/html" rel="alternate" href="http://kieransenior.co.uk/2010/01/jquery-visible-bug/"/>
    <title>jQuery :visible Bug</title>
    <updated>2010-01-04T23:03:42+00:00</updated>
    <author>
      <name>Kieran Senior</name>
      <uri>http://kieransenior.com/</uri>
    </author>
    <content type="html">&lt;p&gt;Pottering around with jQuery I spent a couple of hours trying to figure out why alternating row styles weren&amp;#8217;t working for hidden rows correctly. For the life of me I couldn&amp;#8217;t figure it out, I had done every test imaginable without any results. The selector &lt;code&gt;$(&amp;quot;tr:visible:even&amp;quot;)&lt;/code&gt; didn&amp;#8217;t work correctly, certain rows were having the wrong class applied to them, despite working in a clean environment. When I face a problem for a number of hours I eventually think to myself &amp;#8220;why not try the inverse?&amp;#8221;, so I did just that. &lt;code&gt;$(&amp;quot;tr:not(:hidden):even&amp;quot;)&lt;/code&gt; did exactly what I wanted. Strange you say? Indeed it is. I can&amp;#8217;t help but think the inverse of visible isn&amp;#8217;t equivalent to hidden. This may highlight the difference between display:none and visibility:none, I&amp;#8217;m not certain.&lt;/p&gt;

&lt;p&gt;Anyway, the problem was overcome as mentioned in case you face this issue. This applies to 1.3 I believe.&lt;/p&gt;</content>
  </entry>
  
  <entry>
    <id>http://kieransenior.co.uk/2009/06/multiple-shapes-in-asp-net-mvc-part-2</id>
    <link type="text/html" rel="alternate" href="http://kieransenior.co.uk/2009/06/multiple-shapes-in-asp-net-mvc-part-2/"/>
    <title>Multiple Shapes in ASP.NET MVC - Part 2</title>
    <updated>2009-06-22T19:33:14+01:00</updated>
    <author>
      <name>Kieran Senior</name>
      <uri>http://kieransenior.com/</uri>
    </author>
    <content type="html">&lt;p&gt;In my &lt;a href='http://www.kieransenior.co.uk/2009/06/18/multiple-shapes-in-asp-net-mvc/'&gt;last article&lt;/a&gt; I discussed multiple shapes in ASP.NET MVC, in this article I&amp;#8217;ll discuss to get around some of the problems that I&amp;#8217;ve faced.&lt;/p&gt;

&lt;h2 id='problem_1_theres_no_constructor__solved'&gt;Problem 1: There&amp;#8217;s no constructor - solved!&lt;/h2&gt;

&lt;pre&gt;&lt;code&gt;&amp;#39;System.Data.Linq.DataContext&amp;#39; not contain a constructor that takes &amp;#39;0&amp;#39; arguments&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The first issue was to do with the error shown above which was received upon trying to build the project.&lt;/p&gt;

&lt;p&gt;Today I returned to my development environment with a clean conscience and a load of caffeine. Quite often you&amp;#8217;ll find that ignoring the issue altogether and coming back to it helps, as well as spending the weekend reading some &lt;a href='http://en.wikipedia.org/wiki/Out_of_the_Silent_Planet'&gt;C. S. Lewis novel&lt;/a&gt;. Again I tried to build the project where I was yet again greeted with the same frustrating message. I had discussed the issue on Stack Overflow but the answers I was receiving didn&amp;#8217;t fully tie in with the issue at hand. I considered the partial class to inherit the same class as any other share partial class, which is indeed true, but there were some factors that I hadn&amp;#8217;t previously noticed. If, when you create a dbml file, you right-click and hit &amp;#8220;View Code&amp;#8221; it will create a partial class for the name of the dbml file which is expected. The only issue with this newly created partial class (for placing custom code where you may return multiple shapes from stored procedures which LINQ can&amp;#8217;t do for you) is that it places the partial class in the &lt;em&gt;&lt;em&gt;root namespace&lt;/em&gt;&lt;/em&gt;. I&amp;#8217;ve reproduced this problem with other dbml files so I think it&amp;#8217;s a bug. If someone could confirm I would be most grateful. So, the solution? Append the rest of the namespace! Make sure your &lt;code&gt;&amp;lt;filename&amp;gt;.designer.cs&lt;/code&gt; for your dbml file has a namespace that matches that of the &lt;code&gt;filename.cs&lt;/code&gt; partial class. &lt;em&gt;Do not modify the &lt;code&gt;&amp;lt;filename&amp;gt;.designer.cs&lt;/code&gt; file&lt;/em&gt;, Visual Studio will delete it and you will lose everything.&lt;/p&gt;

&lt;h2 id='problem_2_passing_a_type_failed_to_build_project__solved'&gt;Problem 2: Passing a type failed to build project - solved!&lt;/h2&gt;

&lt;pre&gt;&lt;code&gt;Inherits=&amp;quot;System.Web.Mvc.ViewPage&amp;lt;MyType&amp;gt;&amp;quot;&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The second issue was with the above statement telling the user upon compile that &lt;code&gt;MyType&lt;/code&gt; doesn&amp;#8217;t exist.&lt;/p&gt;

&lt;p&gt;Unfortunately I&amp;#8217;ve left the exact details on another system but I used &lt;a href='http://www.nablasoft.com/alkampfer/index.php/2009/04/05/could-not-load-type-systemwebmvcviewpage/'&gt;this blog post&lt;/a&gt; to aid me in my quest. You simply have to add certain sections into your web.config in order to get it to work. The MVC project setup is quite strange. For me there are two web.config files, one of them has the things that are missing in them, the other does not. Perhaps I have my environment set up wrong. Simply put, I copied the missing contents from one web.config into the other web.config and hey presto, everything worked fine.&lt;/p&gt;

&lt;h2 id='conclusion'&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;These things take getting used to, especially when you&amp;#8217;re not used to working with a web environment which is really quite different from any other you&amp;#8217;ve worked with. Problem 1 seemed to me to be a bug with Visual Studio, what&amp;#8217;s the point in having a partial class that doesn&amp;#8217;t belong to the same namespace? It won&amp;#8217;t compile as the same class surely? Problem 2 also seemed silly because without those settings multiple shapes won&amp;#8217;t work in your project, these details should&amp;#8217;ve been in the web.config beforehand.&lt;/p&gt;

&lt;p&gt;Either way, it&amp;#8217;s not well documented and it takes forever to solve the problem. The good news is that I actually managed to get some data output to screen, despite not being very enthusiastic.&lt;/p&gt;</content>
  </entry>
  
  <entry>
    <id>http://kieransenior.co.uk/2009/06/multiple-shapes-in-asp-net-mvc</id>
    <link type="text/html" rel="alternate" href="http://kieransenior.co.uk/2009/06/multiple-shapes-in-asp-net-mvc/"/>
    <title>Multiple Shapes In ASP.NET MVC</title>
    <updated>2009-06-18T22:47:08+01:00</updated>
    <author>
      <name>Kieran Senior</name>
      <uri>http://kieransenior.com/</uri>
    </author>
    <content type="html">&lt;p&gt;Let&amp;#8217;s admit it, whilst Microsoft focussed on getting some &amp;#8220;oohs&amp;#8221; and &amp;#8220;aahs&amp;#8221; from the developer community by releasing technologies to make the developers life easier, they certainly ignored the more important areas, especially MVC technologies in web systems. The problem with this is that the majority of ASP.NET developers that I know today have absolutely no idea what the MVC architecture is, why it benefits any application, and why it&amp;#8217;s more prefered over traditional &amp;#8220;web forms&amp;#8221;. The real problem out of all of this is convincing developers who&amp;#8217;ve been using form-based technologies for 10 years to start using MVC as a method for developing their web applications. The benefits aren&amp;#8217;t clear, and to receive those benefits appears to take a lot of effort and is definitely a big learning curve - this much is understandable.&lt;/p&gt;

&lt;p&gt;This week I&amp;#8217;ve worked heavily on developing a technical presentation for a big system to show how it can benefit us in the long run. The funny thing about this is that I never got it to work despite knowing and understanding how to use what is available. If only it was user error, then the problem would at least be revealed to me. I re-created the project multiple times to confirm that it wasn&amp;#8217;t just my project settings causing conflicts that would ultimately lead to it not working. Okay, so I&amp;#8217;ll go through all the steps.&lt;/p&gt;

&lt;h2 id='step_1_create_the_mvc_project'&gt;Step 1: Create the MVC project&lt;/h2&gt;

&lt;p&gt;Visual Studio has a template project which provides all of the necessary components to get started straight away with an MVC project. This is okay, but it&amp;#8217;s not what I wanted because I need something called areas which &lt;a href='http://haacked.com/archive/2008/11/04/areas-in-aspnetmvc.aspx'&gt;Phil Haack kindly provided&lt;/a&gt;. This allows us to group controllers into &amp;#8220;areas&amp;#8221;. This is useful if your application is actually composed of multiple sub-applications. So I would set up the default project then implement the areas functionality and make sure at least one view and one controller worked. This worked fine without any hitches.&lt;/p&gt;

&lt;h2 id='step_2_hook_up_your_stored_procedure'&gt;Step 2: Hook up your stored procedure&lt;/h2&gt;

&lt;p&gt;Quite commonly we extract relational data from a database, for example users belonging to groups. You would output all of the groups, and all of the users with the associations also output. A user would have a GroupID for example and we can hook them up in the view. Now, here&amp;#8217;s where the problems really start. Microsoft provide the ability to create stored procedures in LINQ that return the interface ISingleResult, but it won&amp;#8217;t work for IMultipleResults by default, that part is custom. Now your LINQ file has a designer.cs file associated with it (if you remove the connection settings Visual Studio will delete the designer.cs file, which isn&amp;#8217;t good). There&amp;#8217;s two methods to developing the necessary function to get the output you require. Firstly you can create a partial class and completely define this function yourself. To do this, right click on the LINQ dbml file and hit &amp;#8220;View Code&amp;#8221; and it will generate the partial class for you. The other option is to drag and drop the stored procedure onto the diagram and it will auto-generate an &lt;em&gt;incorrect&lt;/em&gt; version of the stored procedure in the designer.cs file. But why? Well, if you find out, please tell me ;). The below code is an example only, this isn&amp;#8217;t real code before you attack me. Let&amp;#8217;s assume for a second that if you pass in a GroupID it instead retrieves all users for that particular group. By default the function instead have ISingleResult as opposed to IMultipleResults. The function body won&amp;#8217;t contain the same code either, but this is what you do with it.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;[Function(Name=&amp;quot;UserGroups&amp;quot;)]
[ResultType(typeof(Users))]
[ResultType(typeof(Groups))]
public IMultipleResults UsersGroups([Parameter(Name = &amp;quot;GroupID&amp;quot;, DbType = &amp;quot;Int&amp;quot;)] string groupID)
{
    ExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), groupID);
    return (IMultipleResults)result.ReturnValue;
}&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This won&amp;#8217;t do much yet because we haven&amp;#8217;t set up the rest of the data.&lt;/p&gt;

&lt;h2 id='step_3_the_view_model'&gt;Step 3: The View Model&lt;/h2&gt;

&lt;p&gt;We need a model to represent the multiple result sets we are returning. They&amp;#8217;re also referred to as multiple shapes in case you ever see that. This model allows us to contain all of the data we need to display in the view. There&amp;#8217;s various examples out there but I&amp;#8217;ll stick with the quick an easy one using some of C#&amp;#8217;s features.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;namespace MyProject.Areas.Users.ViewModels
{
    using Intranet.Areas.Users.Models;
    using System.Collections.Generic;

    public class UsersViewData
    {
        public IEnumerable&amp;lt;Users&amp;gt; Users { get; set; }
        public IEnumerable&amp;lt;Groups&amp;gt; Groups { get; set; }
    }
}&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This is quite straight-forward, it&amp;#8217;s a class to contain data only. Personally I placed this in a separate folder called ViewModels (at the same level as the Models directory, the namespace reveals all). So now we have this we can start using it, right? Not quite, there&amp;#8217;s a few fiddly bits yet.&lt;/p&gt;

&lt;h2 id='step_4_namespaces'&gt;Step 4: Namespaces&lt;/h2&gt;

&lt;p&gt;The page doesn&amp;#8217;t understand this yet despite being a part of the project so you can import the namespace in your web.config file like the following:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;lt;namespaces&amp;gt;
&amp;lt;add namespace=&amp;quot;MyProject.Areas.Users.ViewModels&amp;quot; /&amp;gt;
&amp;lt;add namespace=&amp;quot;System.Web.Mvc&amp;quot; /&amp;gt;
&amp;lt;add namespace=&amp;quot;System.Web.Mvc.Ajax&amp;quot; /&amp;gt;
&amp;lt;add namespace=&amp;quot;System.Web.Mvc.Html&amp;quot; /&amp;gt;
&amp;lt;add namespace=&amp;quot;System.Web.Routing&amp;quot; /&amp;gt;
&amp;lt;add namespace=&amp;quot;System.Linq&amp;quot; /&amp;gt;
&amp;lt;add namespace=&amp;quot;System.Collections.Generic&amp;quot; /&amp;gt;
&amp;lt;/namespaces&amp;gt;&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;There&amp;#8217;s a couple of ways of doing this, you can set it as a property at the top of your view, but it&amp;#8217;s better to do it here in my opinion as you can use it everywhere then. Talking of namespaces now being available in your project you have to do the following line in your inherits statement&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Inherits=&amp;quot;System.Web.Mvc.ViewPage&amp;lt;UsersViewData&amp;gt;&amp;quot;&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This allows you to access all the properties in the &lt;code&gt;ViewData.Models.*&lt;/code&gt; property in your page.&lt;/p&gt;

&lt;h2 id='step_5_getting_the_data'&gt;Step 5: Getting the data&lt;/h2&gt;

&lt;p&gt;Using the controllers functions, or actions as they&amp;#8217;re called we do all of the hard work to get it to the view. Let&amp;#8217;s pretend that a null value means that we want all data. Here&amp;#8217;s how we can do it.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;public ActionResult DataContracts()
{
    IEnumerable&amp;lt;Contract&amp;gt; users;

    using(UsersDataContext db = new UsersDataContext())
    {
        MultipleResults results = db.UsersGroups(null);
        users = results.GetResult&amp;lt;Users&amp;gt;();
    }

    return View(new UsersViewData {
        Users = users,
        Groups = groups
    });
}&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Then in your view you should be able to access all of the properties strongly-typed, which is excellent. Unfortunately this doesn&amp;#8217;t work for me, so now I&amp;#8217;m going to go over the problems I&amp;#8217;ve faced.&lt;/p&gt;

&lt;h3 id='problem_1_wheres_the_constructor_solved_here'&gt;Problem 1: Where&amp;#8217;s the constructor? (solved &lt;a href='http://www.kieransenior.co.uk/2009/06/22/multiple-shapes-in-asp-net-mvc-part-2/'&gt;here&lt;/a&gt;)&lt;/h3&gt;

&lt;p&gt;Here&amp;#8217;s an error I receive if I place the function in the dbml file into the partial class &lt;code&gt;&amp;#39;System.Data.Linq.DataContext&amp;#39; not contain a constructor that takes &amp;#39;0&amp;#39; arguments&lt;/code&gt; I get this every single time, no matter what project I do it in for a C# project (the VB one worked). I&amp;#8217;m not sure if this is a bug, but I&amp;#8217;d love to see it be reproduced. I don&amp;#8217;t want to put it on MS Connect until I can verify it happens for other people. The way I got around this was to instead modify the automatically created function for the stored procedure in the .designer.cs file. Once I do this, the project builds successfully, great! Or is it?&lt;/p&gt;

&lt;h3 id='problem_2_generics_solved_here'&gt;Problem 2: Generics (solved &lt;a href='http://www.kieransenior.co.uk/2009/06/22/multiple-shapes-in-asp-net-mvc-part-2/'&gt;here&lt;/a&gt;)&lt;/h3&gt;

&lt;p&gt;Using the type in the inherits statement of your view causes the ViewData property to vanish from intellisense, and the project will no longer build. That&amp;#8217;s all I know, I can&amp;#8217;t get around the problem therefore I can&amp;#8217;t get a working project. I&amp;#8217;ve tried on multiple projects, again, it worked under the non-areas VB version of the MVC project.&lt;/p&gt;

&lt;h2 id='conclusion'&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;Basically returning multiple result sets from LINQ in an MVC project is terrible. It takes a lot of time, patience and work to get a small set of results, but the real problem is that it&amp;#8217;s difficult to get around this. Bringing back multiple result sets isn&amp;#8217;t easy simply because returned shapes don&amp;#8217;t have to comply with schemas. Quite commonly in our business environment our stored procedures bring back a whole lot of custom data. Personally I created my own classes in the dbml file which are used to represent the data output.&lt;/p&gt;

&lt;p&gt;Whilst I think the Microsoft team have come a long way with these problems in mind it actually makes it impossible for me to proceed in making MVC the choice architecture in our application. Furthermore I really don&amp;#8217;t think the Microsoft team have addressed the issue of returning multiple result sets in enough detail yet, it appears to be a set of sporadic blog posts from various Microsoft team members. In fact, I don&amp;#8217;t even think the ASP.NET MVC tutorials have anything on this from what I remember.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note: If you take a look at the &lt;a href='http://www.kieransenior.co.uk/2009/06/22/multiple-shapes-in-asp-net-mvc-part-2/'&gt;next article&lt;/a&gt; you&amp;#8217;ll find the solutions to problem 1 &amp;amp; 2.&lt;/em&gt;&lt;/p&gt;</content>
  </entry>
  
  <entry>
    <id>http://kieransenior.co.uk/2009/05/working-with-aspnet-mvc</id>
    <link type="text/html" rel="alternate" href="http://kieransenior.co.uk/2009/05/working-with-aspnet-mvc/"/>
    <title>Working With ASP.NET MVC</title>
    <updated>2009-05-01T22:22:01+01:00</updated>
    <author>
      <name>Kieran Senior</name>
      <uri>http://kieransenior.com/</uri>
    </author>
    <content type="html">&lt;p&gt;Since the release of &lt;a href='http://www.asp.net/mvc/'&gt;ASP.NET MVC&lt;/a&gt; I think the whole world has suddenly realised that the Microsoft team are actually doing something good, despite taking years to catch up with other MVC frameworks such as the &lt;a href='http://framework.zend.com/'&gt;Zend Framework.&lt;/a&gt; The good thing is that I&amp;#8217;ve been keeping a close eye on what the team have been doing, and despite my knowledge not being great in the area I&amp;#8217;ve noticed that throughout Scott Gutherie&amp;#8217;s blog the decisions made do seem to be very good.&lt;/p&gt;

&lt;p&gt;When I first started with ASP.NET I thought it was a nightmare, the fact that you had &amp;#8220;web controls&amp;#8221; which required forms on the page with runat=&amp;#8221;server&amp;#8221; attributed on all HTML elements. I hated this. I started off in the company I currently work for wondering what on earth we were using, but the fact was that ASP.NET had evolved into &amp;#8220;web forms&amp;#8221;. There are many reasons I don&amp;#8217;t like it especially with the ViewState property being enabled by default on all controls meaning if you check the response from the server when a web page is generated you&amp;#8217;ll notice a load of encoded data sat near the header. On some of the pages we worked on the ViewState drowned out the actual HTML completely.&lt;/p&gt;

&lt;p&gt;ASP.NET MVC gets rid of all of this. No more ViewState, less use of forms et cetera. As lovely as it is though the majority of guides, articles or tutorials simply don&amp;#8217;t cover large-scale applications. Our applications are gigantic, some of them I&amp;#8217;ve never had to deal with and simply wouldn&amp;#8217;t be able to by myself because they&amp;#8217;re so large. Applications as large as this need testing which is one of the major points of MVC. So, here&amp;#8217;s some problems with ASP.NET MVC that I have.&lt;/p&gt;

&lt;h2 id='nested_controllers_views_and_models'&gt;Nested Controllers, Views and Models&lt;/h2&gt;

&lt;p&gt;So imagine your application is simply so large that you have roughly one hundred folders and some of which go to about five to six levels deep. This is done to separate out area of the application. The application is one major application made up of many smaller applications essentially. Should you create separate projects for each which are somehow controlled from a single web application, or combine the lot? Is we combine all of them, how do we deal with nested folders? ASP.NET MVC deals with controllers, views and models on a folder by folder basis. So our mapped routes looks like &lt;code&gt;{controller}/{action}/{id}&lt;/code&gt; but if we have folder structures such as myapp/mysubapp/adeeperfolder/thepageaction/theid then things start to get tricky, especially if this happens time and time again. &lt;a href='http://haacked.com/archive/2008/11/04/areas-in-aspnetmvc.aspx'&gt;Haacked covers area&lt;/a&gt; in MVC, but again, this may not cover all cases especially for those of a gigantic application. There are &lt;a href='http://www.asp.net/learn/mvc/tutorial-23-vb.aspx'&gt;custom routes available&lt;/a&gt; to work with, but how many would we need? Quite a lot to be honest.&lt;/p&gt;

&lt;p&gt;So what&amp;#8217;s the solution? Well, if we had a URL such as app/myapp/mysubapp/myaction/param then could we not take everything before myaction/param and map it automatically as the path to the controller? I believe this actually breaks the separation of MVC, but for us it seems the most logical approach. I do ponder on this.&lt;/p&gt;

&lt;h2 id='no_more_controls'&gt;No More Controls!&lt;/h2&gt;

&lt;p&gt;Okay, whilst beforehand I would&amp;#8217;ve cursed at controls they do aid in speedy development. So what now? We have to manually create reports in the view. I&amp;#8217;m not saying I have a problem with this, but as my boss said, this moves back to the &amp;#8220;Active Server Pages&amp;#8221; days. We&amp;#8217;re so used to saying &amp;#8220;yes we can provide this report, and it&amp;#8217;ll only take us two minutes to do&amp;#8221;. It may not be the right way, but it produces a result which someone may need &lt;em&gt;right now&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;The idea is that every view represents just that, a different view of something. If you&amp;#8217;re editing results returned into a table then the &amp;#8220;edit&amp;#8221; button would take you to a different view. Are you supposed to be able to edit within the table i.e. turn the row into a row filled with textboxes that you can edit, then have an update button the same row? I&amp;#8217;m guessing now. But this does mean that the amount of views and associated controllers increases substantially. If you have thousands upon thousands of pages already, surely they will multiply?&lt;/p&gt;

&lt;h2 id='no_going_back'&gt;No Going Back&lt;/h2&gt;

&lt;p&gt;The other major concern is that it&amp;#8217;s simply such a big step that it&amp;#8217;s a case of &amp;#8220;out with the old and in with the new&amp;#8221;. You can&amp;#8217;t mix and match, and you couldn&amp;#8217;t move back again. It&amp;#8217;s just too big of a job, and required too many man hours. The amount of time already that I&amp;#8217;ve spent in investigating, gathering requirements, and solving problems is already too great to be throwing the idea out altogether.&lt;/p&gt;

&lt;h2 id='xslt'&gt;XSLT?&lt;/h2&gt;

&lt;p&gt;Seeing as though we no longer have controls what happens with things that we commonly use such as XSLT for generating complex pages? Has that died a horrible death altogether? Again, I&amp;#8217;d love to know.&lt;/p&gt;

&lt;h2 id='data_access'&gt;Data Access&lt;/h2&gt;

&lt;p&gt;The major issue I&amp;#8217;m really having is accessing data correctly. Seeing as though I have no prior experience I&amp;#8217;ve realised it&amp;#8217;s extremely important to have a data access layer, but there are many tools available such as LINQ. LINQ won&amp;#8217;t do what we want because it&amp;#8217;s slower than other technologies and we&amp;#8217;d simply only use it for stored procedures. Simply, strongly-typed stored procedures are required. Also the ability to insert/update/delete based on exposed functions through objects. Again, with such a complex schema this isn&amp;#8217;t a simple task.&lt;/p&gt;

&lt;p&gt;I&amp;#8217;m not sure what everyone else&amp;#8217;s opinion is on the use of ASP.NET MVC but those are just a few of the issues I&amp;#8217;ve run into so far.&lt;/p&gt;</content>
  </entry>
  
  <entry>
    <id>http://kieransenior.co.uk/2008/12/union-all-versus-sub-queried-join-in-ms-sql-2008</id>
    <link type="text/html" rel="alternate" href="http://kieransenior.co.uk/2008/12/union-all-versus-sub-queried-join-in-ms-sql-2008/"/>
    <title>UNION ALL Versus Sub-Queried JOIN In MS SQL 2008</title>
    <updated>2008-12-21T22:41:11+00:00</updated>
    <author>
      <name>Kieran Senior</name>
      <uri>http://kieransenior.com/</uri>
    </author>
    <content type="html">&lt;p&gt;A recent to shift from MS SQL 2000 to MS SQL 2008 was required, and assuming everything would go swimmingly, with greater speed increases, and improved development with the integration of Intellisense to the SQL management tools I thought all would be well. That is until users starting hitting a page which ran a stored procedure. Upon further investigation it was found that the queries within the stored procedure were causing the server to max out for at least five minutes at a time, hindering from all usage of any web pages. Odd, seeing as these stored procedures were run on a daily basis on the old server, and a little fore-sight was taken into account for the compile-time of each stored procedure as they were migrated over to the new server. Unfortunately this wasn&amp;#8217;t the case. Whatever happened in the development of SQL in this eight-year period changed the way queries work. Consider an example where a join encompasses a nested select, cumbersome sure, but capable, even with a table composed of over half a million entries. Unfortunately this will take a long, long time. Once run once the query will run just time again, perhaps because the data is placed higher in the SQL stack.&lt;/p&gt;

&lt;p&gt;Moving forwards, this was tested over and over again only to find the same results. Using CTE&amp;#8217;s, views, or temporary tables had no effect on the query either. Colleagues then attempted alternative approaches to the same query where eventually we reached the use of union. To our surprise the query worked perfectly, and executed in quite literally 5 seconds, compared to the 5 minutes in previous attempts.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;SELECT
    Column1,
    Column2
FROM
    MyTable
WHERE
    Column2 LIKE &amp;#39;%exp%&amp;#39; OR
    Column1 IN (SELECT Column1 FROM MyOtherTable)&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Compared with:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;SELECT
    Column1,
    Column2
FROM
    MyTable
WHERE
    Column2 LIKE &amp;#39;%exp%&amp;#39;
UNION ALL
SELECT
    Column1,
    Column2
FROM
    MyTable
WHERE
    Column1 IN (SELECT Column1 FROM MyOtherTable)&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The latter example will run much, much faster. Logically they are the same, and produce the same results, but in fact the difference in performance is substantial. The only problem is that the better performing query is a much disliked one also.&lt;/p&gt;</content>
  </entry>
  
  <entry>
    <id>http://kieransenior.co.uk/2008/12/mootools-non-flickering-slide-inout-with-initial-closed-state</id>
    <link type="text/html" rel="alternate" href="http://kieransenior.co.uk/2008/12/mootools-non-flickering-slide-inout-with-initial-closed-state/"/>
    <title>MooTools Non-Flickering Slide In/Out With Initial Closed State</title>
    <updated>2008-12-01T20:22:10+00:00</updated>
    <author>
      <name>Kieran Senior</name>
      <uri>http://kieransenior.com/</uri>
    </author>
    <content type="html">&lt;p&gt;Well that&amp;#8217;s quite a mouthful, but it&amp;#8217;s as descriptive and as concise as I can be. I&amp;#8217;ve been using mootools JavaScript library for various things and wanted a slider to slide out information about certain things I&amp;#8217;ve been doing on various projects. The only problem is that there&amp;#8217;s no default &amp;#8220;closed&amp;#8221; or &amp;#8220;in&amp;#8221; state. The various solutions I&amp;#8217;ve seen are really no good, because when the page loads you will initially see the box that you want to hide, then it will suddenly vanish. To fix this issue just do the following:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;lt;script language=&amp;quot;javascript&amp;quot;&amp;gt;
	window.onload = function() {
  		var slider = new Fx.Slide(&amp;#39;help_slide&amp;#39;);
		slider.hide();
	}

	window.addEvent(&amp;#39;domready&amp;#39;, function() {
		var status = {
  			&amp;#39;true&amp;#39;: &amp;#39;Hide Help&amp;#39;,
			&amp;#39;false&amp;#39;: &amp;#39;Show Help&amp;#39;
		};

		var helpSlide = new Fx.Slide(&amp;#39;help_slide&amp;#39;);

		$(&amp;#39;help_toggle&amp;#39;).addEvent(&amp;#39;click&amp;#39;, function(e) {
   			e.stop();
  			helpSlide.toggle();
			});

			helpSlide.hide();

			helpSlide.addEvent(&amp;#39;complete&amp;#39;, function() {
   				$(&amp;#39;help_toggle&amp;#39;).set(&amp;#39;html&amp;#39;, status[helpSlide.open]);
			});
		});
	});
&amp;lt;/script&amp;gt;&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;It&amp;#8217;s a hack really, but it does the trick perfectly for me. Other solutions require using some CSS to set the initial set to hidden then changing the style using the JavaScript which has a few bugs. It&amp;#8217;s a shame the library doesn&amp;#8217;t support initial states though, perhaps something for future versions.&lt;/p&gt;</content>
  </entry>
  
  <entry>
    <id>http://kieransenior.co.uk/2008/11/mac-os-x-leopard-java-swing-menu-bar-title</id>
    <link type="text/html" rel="alternate" href="http://kieransenior.co.uk/2008/11/mac-os-x-leopard-java-swing-menu-bar-title/"/>
    <title>Mac OS X Leopard - Java Swing Menu Bar Title</title>
    <updated>2008-11-23T15:15:08+00:00</updated>
    <author>
      <name>Kieran Senior</name>
      <uri>http://kieransenior.com/</uri>
    </author>
    <content type="html">&lt;p&gt;I&amp;#8217;m working in Eclipse Ganymede at the moment and just couldn&amp;#8217;t get the title for the menu bar to work correctly. Getting the menu bar in the correct place wasn&amp;#8217;t a problem whatsoever, but instead of my application setting the application name for the context-sensitive menu bar to whatever I wanted, it instead used the package name of the application. This is majorly frustrating, especially when you exhaust everything you think may work.&lt;/p&gt;

&lt;p&gt;I&amp;#8217;ll go over what&amp;#8217;s now wrong under Leopard, or what may have even been wrong beforehand. There&amp;#8217;s two things you need to do as follows:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;System.setProperty(&amp;quot;apple.laf.useScreenMenuBar&amp;quot;, &amp;quot;true&amp;quot;);
System.setProperty(&amp;quot;com.apple.mrj.application.apple.menu.about.name&amp;quot;, &amp;quot;MyApplication&amp;quot;);&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The first line will place the menu bar on the screen menu bar, as opposed to the application&amp;#8217;s typical menu bar (much like windows). The second line will change the name of the application to whatever it is you want. If you&amp;#8217;re calling this code from the same place as your GUI is being created, it won&amp;#8217;t work. Why? I wish I knew. Perhaps the call to set the system property within the same thread fails to make a change. What needs to be done is to move your main method to another class. My original class which was to create the entire GUI is called RootGUI. It was recommended to me that a new class called RootGUILauncher and place main in there with the correct calls to the system properties. My eventual code ended up looking like this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;package org.reformsoft.macchat.gui;

import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

public class RootGUILauncher {
	public static void main(String[] args) {
		try {
			System.setProperty(&amp;quot;apple.laf.useScreenMenuBar&amp;quot;, &amp;quot;true&amp;quot;);
			System.setProperty(&amp;quot;com.apple.mrj.application.apple.menu.about.name&amp;quot;, &amp;quot;MyApplication&amp;quot;);
			UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
		}
		catch(ClassNotFoundException e) {
			System.out.println(&amp;quot;ClassNotFoundException: &amp;quot; + e.getMessage());
		}
		catch(InstantiationException e) {
			System.out.println(&amp;quot;InstantiationException: &amp;quot; + e.getMessage());
		}
		catch(IllegalAccessException e) {
			System.out.println(&amp;quot;IllegalAccessException: &amp;quot; + e.getMessage());
		}
		catch(UnsupportedLookAndFeelException e) {
			System.out.println(&amp;quot;UnsupportedLookAndFeelException: &amp;quot; + e.getMessage());
		}

		javax.swing.SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				new RootGUI();
			}
		});
	}
}&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;I didn&amp;#8217;t expect this to work at all, but much to my surprise it did. It actually contradicts a lot of what I&amp;#8217;ve seen on the web, and it&amp;#8217;s very rarely mentioned. Alternative solutions are mentioned in &lt;a href='http://developer.apple.com/documentation/Java/Conceptual/Java14Development/07-NativePlatformIntegration/NativePlatformIntegration.html#//apple_ref/doc/uid/TP40001909-SW1'&gt;developer connection&lt;/a&gt;. They seem a bit more long-winded, although they&amp;#8217;re more robust solutions.&lt;/p&gt;</content>
  </entry>
  
  <entry>
    <id>http://kieransenior.co.uk/2008/02/dynamically-generating-menu-items-in-java</id>
    <link type="text/html" rel="alternate" href="http://kieransenior.co.uk/2008/02/dynamically-generating-menu-items-in-java/"/>
    <title>Dynamically Generating Menu Items In Java</title>
    <updated>2008-02-15T09:09:43+00:00</updated>
    <author>
      <name>Kieran Senior</name>
      <uri>http://kieransenior.com/</uri>
    </author>
    <content type="html">&lt;p&gt;There&amp;#8217;s a hoard of tutorials on the Internet showing you how to make menus in Java, and they&amp;#8217;re just fine, however I always wonder to myself whether they&amp;#8217;re the best solution to the common problem of having hundreds of lines of code just to create a menu, so I decided to try out some alternative approaches.&lt;/p&gt;

&lt;p&gt;In this tutorial I&amp;#8217;ll show you an example from my own project generating menu items dynamically, from any format you wish.&lt;/p&gt;

&lt;h2 id='representing_the_data'&gt;Representing The Data&lt;/h2&gt;

&lt;p&gt;First of all you need a format to represent the menu items. For this example I&amp;#8217;m using dots by themselves to represent separators, and I&amp;#8217;m ending items with a colon to represent them as a menu. All of these items are contained in one String array, and each element represents an entire menu. Thus, the format will look like:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;{&amp;quot;File: New . Menu-Item Another-Menu-Item . Other-Items&amp;quot;, &amp;quot;Tools: Draw . Fill . Editing-Tools&amp;quot;}&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This example is extremely basic and there are far better ways of doing it, but for the purpose of this tutorial I&amp;#8217;ll keep it simple by not using multi-dimensional arrays, or extracting values from files etc.&lt;/p&gt;

&lt;h2 id='pulling_the_data_out'&gt;Pulling The Data Out&lt;/h2&gt;

&lt;p&gt;Next we will need to iterate over the list of elements and choose what goes where. You&amp;#8217;ll also need to use a small regular expression to split the data by whatever format you choose. Spaces separate elements in my data representation therefore I use s+.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;for(String menuElement : menuItems)
{
    String[] splitMenuItems = menuElement.split(&amp;quot;s+&amp;quot;);

    menu = new JMenu(splitMenuItems[0].substring(0, splitMenuItems[0].length() - 1));
    menu.addActionListener(this);
    menuBar.add(menu);
		
    for(String menuItemElement : splitMenuItems)
    {
        if(!menuItemElement.endsWith(&amp;quot;:&amp;quot;) &amp;amp;&amp;amp; !menuItemElement.equals(&amp;quot;.&amp;quot;))
        {
            menuItem = new JMenuItem(menuItemElement.replace(&amp;#39;-&amp;#39;, &amp;#39; &amp;#39;));
            menuItem.setActionCommand(menuItemElement);
            menuItem.addActionListener(this);
            menu.add(menuItem);
        }
        else if(menuItemElement.equals(&amp;quot;.&amp;quot;))
        {
            menu.addSeparator();
        }
    }
}&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Here I use a nested for loop to first iterate over each element in the String array, and each time I do I then split the String into its individual elements and place them into a String array of their own. A root menu is represented by a proceeding &amp;#8221;:&amp;#8221; character, so &lt;code&gt;splitMenuItems[0].substring(0, splitMenuItems[0].length() - 1)&lt;/code&gt; takes out the colon at the end of &amp;#8220;File:&amp;#8221;.&lt;/p&gt;

&lt;p&gt;In the next nested for loop I ignore elements ending with the &amp;#8221;:&amp;#8221; character because due to the String split, it naturally includes the first element which is &amp;#8220;File:&amp;#8221; - you can choose to remove this element if you wish, whatever suits you really. I also ignore the &amp;#8221;.&amp;#8221; character and if that character does occur the statement will then go over to the else if statement where it will add a separator for every dot found.&lt;/p&gt;

&lt;p&gt;Because the menu items are delimited by spaces I needed to handle menu item text with spaces in it. To do so I merely used &amp;#8220;-&amp;#8221; characters to represent spaces. Underscores may have been better as you may actually use hyphens in your menu items. When one is found I just simply replace it with a space character.&lt;/p&gt;

&lt;h2 id='but_what_about_key_mnemonics'&gt;But What About Key Mnemonics?&lt;/h2&gt;

&lt;p&gt;Key mnemonics allow you to hit a key on your keyboard and that menu item open up. You may think that this option isn&amp;#8217;t as customisable, but it just means there&amp;#8217;s a little more work to do. Obviously we can represent the data in any form we want, and thus to enable key mnemonics simple change the format of the data. For example, &lt;code&gt;{&amp;quot;File:_69 New . Close . Exit&amp;quot;}&lt;/code&gt; - here we can use an underscore to separate mnemonics and then give the integer value of the VK constant which you can then add to &lt;code&gt;setMnemonic(int)&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Simple, huh?&lt;/p&gt;</content>
  </entry>
  
 
</feed>
