<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-3131758074439086314</id><updated>2012-02-16T02:31:15.629-08:00</updated><title type='text'>Cannibal Code</title><subtitle type='html'>I am an Agile coder but will feed on the flesh of any species. I'm fairly new to Agile practices but I have several very good mentors.  I am most fortunate for this fact.  In return I have decided to a) blog what small bits of wisdom I can retain and b) remain somewhat incognito to protect said mentors from my inevitable disgrace.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://cannibalcode.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3131758074439086314/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://cannibalcode.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Cannibal Coder</name><uri>http://www.blogger.com/profile/11951487273106045492</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_PmJPwpgzQW8/SXAMr3BDMDI/AAAAAAAAAAM/OsZvZDbWiBI/S220/blackeye+003.JPG'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>21</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-3131758074439086314.post-99038482322748169</id><published>2011-12-15T06:55:00.001-08:00</published><updated>2011-12-15T06:55:55.407-08:00</updated><title type='text'>A Better Ajax throbber</title><content type='html'>&lt;p&gt;I’ve been messing with setting up an ajax throbber ( the little waiting icon or animated gif.&amp;#160; That’s what they call it.&amp;#160; It ain’t me. ). &lt;/p&gt;  &lt;p&gt;Most examples show that you should put the show() logic right before you make your ajax call and then the hide() in the $.ajax.complete() event.&amp;#160; This has a number of problems.&amp;#160; &lt;/p&gt;  &lt;p&gt;1) Unless you have just one single repository through which all ajax calls go ( and I do ) you end up putting the start throbber logic all over the place, wherever you make a call&lt;/p&gt;  &lt;p&gt;2) unless you use a setTimeout function the throbber will always show even if just for a flash.&amp;#160; It’s much better to have a pause and if the ajax call is quick enough then you don’t see the throbber at all.&lt;/p&gt;  &lt;p&gt;Number two has a major problem though.&amp;#160; And this is the meat of the post.&amp;#160; If you set your time out for 1000 ( one second ) and the ajax call comes back in 500 then the ajax complete will fire before your setTimeout has fired.&amp;#160; Then the setTImeout will fire and the throbber will never disappear.&lt;/p&gt;  &lt;p&gt;Two ways to deal with this are to put the hide() logic in the repository call back method which unless you have a single repository as mentioned above with a single OnComplete callback that then calls your real callback you end up with code everywhere again.&lt;/p&gt;  &lt;p&gt;So what I decided to do is to have global ( or scoped to your module global ) variable called showThrobber, and set it to false.&amp;#160; Then in the $.ajaxSetup.before send I put my timeout with a check for showThrobber. in the $.ajaxSetup.complete is set showThorb to false and hide the throbber.&amp;#160; so it looks like this&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;$.ajaxSetup({     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; complete:function(){dci.showThrob = false;&amp;#160; $(&amp;quot;#ajaxLoading&amp;quot;).hide();},      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; beforeSend:function(){setTimeout(function() {if(dci.showThrob) $(&amp;quot;#ajaxLoading&amp;quot;).show(); }, 500)}&lt;/p&gt;    &lt;p&gt; });&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;In my ajax get ( or post ) I turn on the showThrob&lt;/p&gt;  &lt;p&gt;ajaxGet:function(url, data, callback){   &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; dci.showThrob=true;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // showLoader = setTimeout(function() {if(dci.showThrob) $(&amp;quot;#ajaxLoading&amp;quot;).show(); }, 1000);    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; $.get(url,data,function(result){repositoryCallback(result,callback);    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; });    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt;  &lt;p&gt;sorry about the formatting.&lt;/p&gt;  &lt;p&gt;This is I believe called a latch mechanism. &lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3131758074439086314-99038482322748169?l=cannibalcode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cannibalcode.blogspot.com/feeds/99038482322748169/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3131758074439086314&amp;postID=99038482322748169' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3131758074439086314/posts/default/99038482322748169'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3131758074439086314/posts/default/99038482322748169'/><link rel='alternate' type='text/html' href='http://cannibalcode.blogspot.com/2011/12/better-ajax-throbber.html' title='A Better Ajax throbber'/><author><name>Cannibal Coder</name><uri>http://www.blogger.com/profile/09578777459530774168</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_asa4XGVfcto/SW1rpDmvK8I/AAAAAAAAAHs/0Dy4B3bhsVo/S220/blackeye+003.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3131758074439086314.post-2480467331880014319</id><published>2011-11-21T14:03:00.001-08:00</published><updated>2011-11-21T14:03:32.059-08:00</updated><title type='text'>How I use Backbone.js Views as modules</title><content type='html'>&lt;p&gt;In my previous post I explained how I use views as a basic class structure. Here I will go a bit deeper into how I use them.&lt;/p&gt;  &lt;p&gt;At the base there is the traditional Backbone.js view.&amp;#160; Used as one would normally use it, to set up the container, hook up the events, and structure your code.&amp;#160; This is a nice way of compartmentalizing functionality.&amp;#160; But let’s say that you have two views, or pieces of functionality, say a popup functionality and an ajax form functionality.&amp;#160; You&amp;#160; could initialize the two views separately and then hook them together using a controller ( more on that later ) but if you do this a lot, and this is the sort of thing one would do a lot if they are using popups, then this get’s terribly tedious.&amp;#160; &lt;/p&gt;  &lt;p&gt;So I employ what I call a module.&amp;#160; It’s an extended view that has a views collection ( object ) a modules collection and a destroy function();&amp;#160; Then I inherit this module, and in it I instantiate the ajax form view, the the popup view put the form in the popup and render. I put both views in the modules view collection.&amp;#160; The destroy method loops through the modules and the views that belong to the module and calls destroy and remove on them respectively.&amp;#160; Now I can call new AjaxPopupModule() pass in an el ( a root element ) and a url and possibly other stuff and I’m all set.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3131758074439086314-2480467331880014319?l=cannibalcode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cannibalcode.blogspot.com/feeds/2480467331880014319/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3131758074439086314&amp;postID=2480467331880014319' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3131758074439086314/posts/default/2480467331880014319'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3131758074439086314/posts/default/2480467331880014319'/><link rel='alternate' type='text/html' href='http://cannibalcode.blogspot.com/2011/11/in-my-previous-post-i-explained-how-i.html' title='How I use Backbone.js Views as modules'/><author><name>Cannibal Coder</name><uri>http://www.blogger.com/profile/09578777459530774168</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_asa4XGVfcto/SW1rpDmvK8I/AAAAAAAAAHs/0Dy4B3bhsVo/S220/blackeye+003.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3131758074439086314.post-5535167745710976293</id><published>2011-11-21T13:47:00.001-08:00</published><updated>2011-11-21T13:47:44.369-08:00</updated><title type='text'>Using Backbone.js views as a class structure</title><content type='html'>&lt;p&gt;So what I’ve ended up doing is using Backbone.js Views basically as a class structure.&amp;#160; I used to use immediate functions or static objects or whatever you want to call them, basically &lt;/p&gt;  &lt;p&gt;var x= (function(){&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;return {&lt;/p&gt;    &lt;p&gt;}&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;}())&lt;/p&gt;  &lt;p&gt;for everything.&amp;#160; And I always had an init function to set it up.&amp;#160; The limitation was that I could not inherit from those classes so I eneded up duplicating code a lot.&lt;/p&gt;  &lt;p&gt;So, as I was saying, I’ve adopted backbone.js views as my class structure.&amp;#160; I can inherit these classes, they are constructor functions so I can put set up code in the function and they offer a few bonus features as well, such as if I have straight up events I can use the views event declaration infrastructure.&amp;#160; But overall what I like the most about it is that I can create base classes that have the functionality that I use a lot on them.&amp;#160; Now I know I could write my own class structure and implement all these features as well as a couple I’m about to mention that I don’t like, myself, but a) I’m kind of scared of constructer functions with prototypal inheritance and b) I believe ( hope ) that the structure will be familiar to people who use backbone.js ( such as my team ) and they will understand what is going on more easily.&lt;/p&gt;  &lt;p&gt;The one thing I don’t like about using backbone.js views as my base class structure, is that it doesn’t implement any override functionality.&amp;#160; You can overwrite but not override and call base().&amp;#160; This would be great for such things as having a function on a base class called registerSubscriptions() that lays out the common subscription.&amp;#160; Then in my inhertied classes I could override it add page specific subscriptions then call base(). &lt;/p&gt;  &lt;p&gt;The way I get around that now ( and there are I guess a couple of similarly distateful ways ) is that I have my base registerSubscriptions() call registerAdditionalSubscriptions() as it’s last step.&amp;#160; in the base class I stub out the method so it won’t crash and in my sub classes I overwrite the method if necessary.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3131758074439086314-5535167745710976293?l=cannibalcode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cannibalcode.blogspot.com/feeds/5535167745710976293/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3131758074439086314&amp;postID=5535167745710976293' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3131758074439086314/posts/default/5535167745710976293'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3131758074439086314/posts/default/5535167745710976293'/><link rel='alternate' type='text/html' href='http://cannibalcode.blogspot.com/2011/11/so-what-ive-ended-up-doing-is-using.html' title='Using Backbone.js views as a class structure'/><author><name>Cannibal Coder</name><uri>http://www.blogger.com/profile/09578777459530774168</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_asa4XGVfcto/SW1rpDmvK8I/AAAAAAAAAHs/0Dy4B3bhsVo/S220/blackeye+003.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3131758074439086314.post-7318280912151609137</id><published>2011-10-14T15:43:00.001-07:00</published><updated>2011-10-14T15:43:33.930-07:00</updated><title type='text'>My javascript stack</title><content type='html'>&lt;p&gt;Ok so here’s how I’m building my single page business app.&lt;/p&gt;  &lt;p&gt;Backend is asp.mvc using fubu html helpers.&amp;#160; &lt;/p&gt;  &lt;p&gt;front end.&amp;#160; Here are the plug ins I’m using. jquery ( of course ), backbone.js, a little pub sub class, $.address, knockout.js and my own system of controllers.&lt;/p&gt;  &lt;p&gt;A lot of people talk about not using any controller, just straight backbone.js or knockout.js.&amp;#160; I can’t seem to figure this out.&amp;#160; My shit has lots of stuff going on that has no place in a view or a model but I don’t want it just hanging around willy nilly.&amp;#160; I need a freakin controller to manage all the different parts.&amp;#160; &lt;/p&gt;  &lt;p&gt;For instance, when you click on a row in the grid, it must hide the grid and show a form.&amp;#160; When the form submitted or canceled it should remove the form and show the grid again.&lt;/p&gt;  &lt;p&gt;First I hide the grid so that I don’t have to re load that section.&amp;#160; If the form is updated rather then canceled I update the grid but I don’t have to get the whole def and re render everything.&amp;#160; The form however, I retrieve via ajax.&amp;#160; This is because there could be different forms based on what exactly is clicked on the page/grid and loading a form for every possible outcome is crazy.&lt;/p&gt;  &lt;p&gt;Even so that might not seem like it’s that crazy that I just absolutely need a controller, but here’s a real example of the basic page in out app.&amp;#160; We a) load a grid. click on the grid and you get b) ajax call for form. On the form there is the ability to associate a document with this particular instance of the entity.&amp;#160; If you haven’t any you can upload a new one.&amp;#160; But you can’t just upload a document you much attach some meta data to the document so we need a c) new ajax form and a d) new popup to house it.&amp;#160; then you save the doc and meta data and you see it in a list of selected documents for this item.&amp;#160; If you want to edit/view one of these docs you can click on the name and up comes the popup with the form and data.&amp;#160; This is the basic page and shit just gets more complex from there.&amp;#160; &lt;/p&gt;  &lt;p&gt;So in my next post I’ll explain my controller and how it keeps me sane.&amp;#160; But it’s friday 6:00 and I still got shit to do so I’m out.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3131758074439086314-7318280912151609137?l=cannibalcode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cannibalcode.blogspot.com/feeds/7318280912151609137/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3131758074439086314&amp;postID=7318280912151609137' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3131758074439086314/posts/default/7318280912151609137'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3131758074439086314/posts/default/7318280912151609137'/><link rel='alternate' type='text/html' href='http://cannibalcode.blogspot.com/2011/10/my-javascript-stack.html' title='My javascript stack'/><author><name>Cannibal Coder</name><uri>http://www.blogger.com/profile/09578777459530774168</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_asa4XGVfcto/SW1rpDmvK8I/AAAAAAAAAHs/0Dy4B3bhsVo/S220/blackeye+003.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3131758074439086314.post-5380260054441111409</id><published>2011-10-14T15:28:00.001-07:00</published><updated>2011-10-14T15:28:41.877-07:00</updated><title type='text'>Catch up and more Javascript</title><content type='html'>&lt;p&gt;well it’s been forever since I’ve posted but don’t worry I haven’t learned a thing.&amp;#160; I will dispense with the backlog and jump straight into what I’m doing now.&lt;/p&gt;  &lt;p&gt;Javascript&lt;/p&gt;  &lt;p&gt;I am working on a single page app with basic business app functionality eg lists ( grid ( jqgrid )) forms, menus, popups etc.&amp;#160; I of course quickly found my javascript btfu ( getting ugly and out of control ).&amp;#160; So I started writing my own collection of classes to organize and componentize the functionality.&amp;#160; After a few iterations I had something pretty workable but I’m using Douglas Crockford’s objects with private variables.&amp;#160; These are nice and clean and organized but they don’t allow for much extension or inheritance.&lt;/p&gt;  &lt;p&gt;I’m still using these but I have integrated backbone.js and am about to integrated knockout.js in there to.&amp;#160; I will write an other post explaining this stuff so people don’t have to read this bullshit if they don’t' want&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3131758074439086314-5380260054441111409?l=cannibalcode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cannibalcode.blogspot.com/feeds/5380260054441111409/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3131758074439086314&amp;postID=5380260054441111409' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3131758074439086314/posts/default/5380260054441111409'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3131758074439086314/posts/default/5380260054441111409'/><link rel='alternate' type='text/html' href='http://cannibalcode.blogspot.com/2011/10/catch-up-and-more-javascript.html' title='Catch up and more Javascript'/><author><name>Cannibal Coder</name><uri>http://www.blogger.com/profile/09578777459530774168</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_asa4XGVfcto/SW1rpDmvK8I/AAAAAAAAAHs/0Dy4B3bhsVo/S220/blackeye+003.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3131758074439086314.post-5026408606190256372</id><published>2010-03-23T13:10:00.001-07:00</published><updated>2010-03-23T13:10:08.828-07:00</updated><title type='text'>Using FubuMVC.UI in asp.net MVC : Getting started</title><content type='html'>&lt;p&gt;If you are not fortunate enough to be able to use FubuMVC but are fortunate enough to be using asp.net MVC, you may find yourself unendingly vexed by the suckyness of the ui helpers in asp.net mvc ( heretofor referred to as mvc ).&amp;#160; mvccontrib has some good stuff with the uibuilders, but I find the FubuMVC.UI more to my taste.&amp;#160; In this post or series of posts I will show how I am using the FubuMVC.UI in my MVC app.&amp;#160; I am using Structuremap as my DI container so there may be a few differences if you are not.&amp;#160; And to that not, I got a big leg up from RyanOhs post &lt;a href="http://geekswithblogs.net/ryanohs/archive/2010/02/24/using-fubumvcrsquos-html-conventions-in-microsoft-mvc.aspx"&gt;Using FubuMVC’s Html Conventions in Microsoft MVC&lt;/a&gt; which seems to be dead now but may someday return so I linked to it anyway.&amp;#160; He’s using Windsor as his DI container.&amp;#160; Now on to the meat.&lt;/p&gt;  &lt;p&gt;One of the central ideas in the FubuMVC.UI is that there are three kinds of elements were interested in.&amp;#160; Inputs, Labels, and Displays.&amp;#160; Inputs being any kind of element that allows you submit information, Labels being, well, labes and Displays being elements that display information.&amp;#160; Readonly information.&amp;#160; Labels are the easiest.&amp;#160; Once you know how you like to display your labels you can specify that concvention and largely be done with it.&amp;#160; Displays too can be pretty easy too but can get more complicated depending on what you want to display.&amp;#160; Inputs are the proverbial money shot.&amp;#160; That is where most of the cool stuff happens. &lt;/p&gt;  &lt;p&gt;One of the first things you’ll need to do is create a set of conventions.&amp;#160; The idea is that you say ok whenever I specify a label ( e.g. Html.LabelFor(x=&amp;gt;x.FirstName) ) render it like this.&amp;#160; So for my convention I have &lt;/p&gt;  &lt;p&gt;Labels.Always.BuildBy(req =&amp;gt; new HtmlTag(&amp;quot;label&amp;quot;).Attr(&amp;quot;for&amp;quot;, req.Accessor.Name).Text(req.Accessor.FieldName.ToSeperateWordsFromPascalCase()));&lt;/p&gt;  &lt;p&gt;So for labels always build using a “label” tag, set an attribute “for” equal to the name of the property and set the text of the label to the Property name and ( using a little extension method I build ) separate the words of the Property.&amp;#160; So my property was FIrstName.&amp;#160; it will render &amp;lt;label for=”FirstName” &amp;gt;First Name&amp;lt;/label&amp;gt; .&amp;#160; &lt;/p&gt;  &lt;p&gt;Similarly I do something for the display.&lt;/p&gt;  &lt;p&gt;The fun happens with the InputFor.&amp;#160; To keep this simple I will show the very least that you will need for Input.&amp;#160; &lt;/p&gt;  &lt;p&gt;Editors.IfPropertyIs&amp;lt;bool&amp;gt;().BuildBy(TagActionExpression.BuildCheckbox);&lt;/p&gt;  &lt;p&gt;Editors.Always.BuildBy(TagActionExpression.BuildTextbox);&lt;/p&gt;  &lt;p&gt;Here if you do something like this Html.InputFor(x=&amp;gt;x.IsReallyCool) you will get a checkbox since IsReallyCool is a bool.&amp;#160; and if you do basically anything else you will get a textbox.&lt;/p&gt;  &lt;p&gt;So the final very bare minimum HtmlConvention file would like this&lt;/p&gt;  &lt;p&gt;public class FlywheelHtmlConventions : HtmlConventionRegistry   &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public FlywheelHtmlConventions()    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Editors.IfPropertyIs&amp;lt;bool&amp;gt;().BuildBy(TagActionExpression.BuildCheckbox);    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Editors.Always.BuildBy(TagActionExpression.BuildTextbox);    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Displays.Always.BuildBy(req =&amp;gt; new HtmlTag(&amp;quot;span&amp;quot;).Text(req.StringValue()));    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Labels.Always.BuildBy(req =&amp;gt; new HtmlTag(&amp;quot;label&amp;quot;).Attr(&amp;quot;for&amp;quot;, req.Accessor.Name).Text(req.Accessor.FieldName.ToSeperateWordsFromPascalCase()));    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt;  &lt;p&gt;This is won’t take you very far but we can go over some more interesting conventions later.&lt;/p&gt;  &lt;p&gt;Next&lt;/p&gt;  &lt;p&gt;You will also need some extension methods that you will access the FubuMVC.UI with from the view.&amp;#160; Now here I chose to write the extension methods off the HtmlHelper despite the fact that it’s a big bloated pos.&amp;#160; I did this for a very important reason.&amp;#160; If you use partials you will need to be able to get information off the model from the view that called the partial from with in the partial.&amp;#160; So inside the partial your calling InputFor(blah).&amp;#160; You will know that blah is on the BlahViewModel, but you wont know that the BlahBlahBlahViewModel called that partial unless you dig around in the HtmlHelper.&amp;#160; More on this later. probably.&lt;/p&gt;  &lt;p&gt;So here are the three extension methods you will need and a little helper method.&lt;/p&gt;  &lt;p&gt;public static class FubuUIHtmlExtensions   &lt;br /&gt;&amp;#160;&amp;#160; {    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; private static ITagGenerator&amp;lt;T&amp;gt; GetGenerator&amp;lt;T&amp;gt;(HtmlHelper&amp;lt;T&amp;gt; helper, Expression&amp;lt;Func&amp;lt;T, object&amp;gt;&amp;gt; expression) where T : class    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; TagGenerator&amp;lt;T&amp;gt; generator = ServiceLocator.Current.GetInstance&amp;lt;ITagGenerator&amp;lt;T&amp;gt;&amp;gt;() as TagGenerator&amp;lt;T&amp;gt;;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; generator.Model = helper.ViewData.Model;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return generator;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; } &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public static HtmlTag InputFor&amp;lt;T&amp;gt;(this HtmlHelper&amp;lt;T&amp;gt; helper, Expression&amp;lt;Func&amp;lt;T, object&amp;gt;&amp;gt; expression) where T : class   &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ITagGenerator&amp;lt;T&amp;gt; generator = GetGenerator&amp;lt;T&amp;gt;(helper, expression);    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return generator.InputFor(expression);    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public static HtmlTag LabelFor&amp;lt;T&amp;gt;(this HtmlHelper&amp;lt;T&amp;gt; helper, Expression&amp;lt;Func&amp;lt;T, object&amp;gt;&amp;gt; expression) where T : class    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ITagGenerator&amp;lt;T&amp;gt; generator = GetGenerator&amp;lt;T&amp;gt;(helper, expression);    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; HtmlTag tag = generator.LabelFor(expression);    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return tag;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; } &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public static HtmlTag DisplayFor&amp;lt;T&amp;gt;(this HtmlHelper&amp;lt;T&amp;gt; helper, Expression&amp;lt;Func&amp;lt;T, object&amp;gt;&amp;gt; expression) where T : class   &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ITagGenerator&amp;lt;T&amp;gt; generator = GetGenerator&amp;lt;T&amp;gt;(helper, expression);    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return generator.DisplayFor(expression);    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt;  &lt;p&gt;}&lt;/p&gt;  &lt;p&gt;basically each of these is getting a TagGenerator and calling either input,label, or display on it.&lt;/p&gt;  &lt;p&gt;The Generator method gets a TagGenator from the servicelocator( container ).&amp;#160; You then pass the instance of the viewmodel into the TagGenerator. Essentially the TagGenerator will read you conventions decide what to render and do so using the data in the Model.&lt;/p&gt;  &lt;p&gt;The last step is to register some stuff with your container.&amp;#160; &lt;/p&gt;  &lt;p&gt;First in your ContainerRegistry you should do as follows ( for structure map.&amp;#160; of windsor check out ryanohs post ) &lt;/p&gt;  &lt;p&gt;For&amp;lt;HtmlConventionRegistry&amp;gt;().Add&amp;lt;MYHtmlConventions&amp;gt;();   &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; For&amp;lt;IServiceLocator&amp;gt;().Singleton().Use(new StructureMapServiceLocator());    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; For(typeof(ITagGenerator&amp;lt;&amp;gt;)).Use(typeof(TagGenerator&amp;lt;&amp;gt;));    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; For&amp;lt;TagProfileLibrary&amp;gt;().Singleton();&lt;/p&gt;  &lt;p&gt;Then after you call bootstrapper for Structuremap in the application.start you should call&lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ServiceLocator.SetLocatorProvider(() =&amp;gt; new StructureMapServiceLocator()); &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; var library = ObjectFactory.Container.GetInstance&amp;lt;TagProfileLibrary&amp;gt;();   &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; var conventions = ObjectFactory.Container.GetAllInstances&amp;lt;HtmlConventionRegistry&amp;gt;();    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; conventions.Each(library.ImportRegistry);&lt;/p&gt;  &lt;p&gt;Here we set up the ServiceLocatorProvider. then we get an instance of the TagProfilerLiberary and an instance of our HtmlConventions and call Library.ImportRegistry on each of the conventions.&lt;/p&gt;  &lt;p&gt;Now in our view we can do &amp;lt;%= Html.LabelFor(x=&amp;gt;x.FirstName) %&amp;gt;&amp;#160; &amp;lt;%= Html.InputFor(x=&amp;gt;x.FirstName) %&amp;gt; and get&lt;/p&gt;  &lt;p&gt;&amp;lt;label for=”FirstName”&amp;gt;First Name&amp;lt;/label&amp;gt;&amp;lt;input type=”text” name=”FirstName” value=”Cannibal” &amp;gt;&amp;lt;/input&amp;gt;&lt;/p&gt;  &lt;p&gt;There.&amp;#160; I made it through.&amp;#160; This looks like total ass in my editor and I may need to figure out how to display code better and redo this post.&amp;#160; But in any case in future posts I will go over more useful conventions and some advanced stuff.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3131758074439086314-5026408606190256372?l=cannibalcode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cannibalcode.blogspot.com/feeds/5026408606190256372/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3131758074439086314&amp;postID=5026408606190256372' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3131758074439086314/posts/default/5026408606190256372'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3131758074439086314/posts/default/5026408606190256372'/><link rel='alternate' type='text/html' href='http://cannibalcode.blogspot.com/2010/03/using-fubumvcui-in-aspnet-mvc-getting.html' title='Using FubuMVC.UI in asp.net MVC : Getting started'/><author><name>Cannibal Coder</name><uri>http://www.blogger.com/profile/09578777459530774168</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_asa4XGVfcto/SW1rpDmvK8I/AAAAAAAAAHs/0Dy4B3bhsVo/S220/blackeye+003.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3131758074439086314.post-1573090661694487940</id><published>2010-01-29T09:56:00.001-08:00</published><updated>2010-01-29T09:56:09.236-08:00</updated><title type='text'>Post Classifications</title><content type='html'>&lt;h2&gt;&lt;/h2&gt;  &lt;h2&gt;&lt;/h2&gt;  &lt;h2&gt;Congealed Thoughts&lt;/h2&gt;  &lt;p&gt;I enjoy a&amp;#160; sort of steam of consciousness style post as it helps me gel my thoughts.&amp;#160; However, I can only imagine that it’s pretty annoying to read.&amp;#160; So I am going to start sub heading my posts with a classification.&amp;#160; So Stream of Consciousness for that type.&amp;#160; Perhaps Congealed Thoughts for my opinions and thoughts that have are more ready for the masses :).&amp;#160; and a third for explanatory posts, explaining certain technologies and such. I’ll have to come up with the heading for that when I actually write one.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3131758074439086314-1573090661694487940?l=cannibalcode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cannibalcode.blogspot.com/feeds/1573090661694487940/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3131758074439086314&amp;postID=1573090661694487940' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3131758074439086314/posts/default/1573090661694487940'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3131758074439086314/posts/default/1573090661694487940'/><link rel='alternate' type='text/html' href='http://cannibalcode.blogspot.com/2010/01/post-classifications.html' title='Post Classifications'/><author><name>Cannibal Coder</name><uri>http://www.blogger.com/profile/09578777459530774168</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_asa4XGVfcto/SW1rpDmvK8I/AAAAAAAAAHs/0Dy4B3bhsVo/S220/blackeye+003.JPG'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3131758074439086314.post-4775532625120309098</id><published>2010-01-27T08:51:00.005-08:00</published><updated>2010-01-27T08:51:24.323-08:00</updated><title type='text'>My venture into OOP Javascript pt3: us an M? I think so.</title><content type='html'>&lt;p&gt;The next issue that I’m struggling with is the idea of a model.&amp;#160; Do I want to break away from the dom completely.&amp;#160; An event is issued from the dom to the controller.&amp;#160; the controller could then query the dom for all the data it might need to process the call put it in a little viewmodel and pass that around to all the services that will eventually need to deal with this data to validate and persist etc.&lt;/p&gt;  &lt;p&gt;Yes I do like this idea.&amp;#160; A clean break from dom for some clean javascript programming.&amp;#160; Fuck another massive re write.&amp;#160; I’m never gonna finish this shit.&amp;#160;&amp;#160; Anyway,&amp;#160; there’s a certain voice in the back of my head wondering if there will be inefficiencies the further I get from what I’ve always though of as javascript programming and the more I impose my server side code patterns onto my client side programming.&amp;#160; But I guess I’ll blow that up later.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3131758074439086314-4775532625120309098?l=cannibalcode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cannibalcode.blogspot.com/feeds/4775532625120309098/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3131758074439086314&amp;postID=4775532625120309098' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3131758074439086314/posts/default/4775532625120309098'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3131758074439086314/posts/default/4775532625120309098'/><link rel='alternate' type='text/html' href='http://cannibalcode.blogspot.com/2010/01/my-venture-into-oop-javascript-pt3-us-m.html' title='My venture into OOP Javascript pt3: us an M? I think so.'/><author><name>Cannibal Coder</name><uri>http://www.blogger.com/profile/09578777459530774168</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_asa4XGVfcto/SW1rpDmvK8I/AAAAAAAAAHs/0Dy4B3bhsVo/S220/blackeye+003.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3131758074439086314.post-8279189208619452906</id><published>2010-01-27T08:51:00.003-08:00</published><updated>2010-01-27T08:51:14.614-08:00</updated><title type='text'>My venture into OOP Javascript pt2: MVC?</title><content type='html'>&lt;p&gt;At this point I’ve tried to break out the code into classes that loosely mimic my MVC classes.&amp;#160; A view that deals with setting up the calendar onload with the proper dropdowns and so on, a controller that deals with the events or “actions” that come from the calendar, and various services.&amp;#160; &lt;/p&gt;  &lt;p&gt;One immediate issue that comes up is that&amp;#160; while the calendar is the starting point, once you click on it you get a dialog box which is not unlike an entire new and mostly unrelated module that has all manner of view setup, events or “actions”, data, rules and services.&amp;#160; It’s almost like whenever an event or a time is clicked it the calendar controller should call a calendarEventController with it’s seperate view and data.&amp;#160; But then I wonder if every dialog box should have it’s own controller.&amp;#160; There could be several stages to creating an Event.&amp;#160; If the event is in the past you have to justify it.&amp;#160; That’s one dialogbox, then you get the regulare add/edit dialog, if it’s edit and recurring you have a new dialog asking if you want to change all future events or just this one. and so on.&amp;#160; &lt;/p&gt;  &lt;p&gt;Ok so upon writing this it’s starting to make me think about fubumvc’s &lt;a href="http://www.lostechies.com/blogs/joshuaflanagan/archive/2010/01/18/fubumvc-define-your-actions-your-way.aspx"&gt;“controller-less actions”&lt;/a&gt;.&amp;#160; basically it does away with the idea of a proper controller and makes each action it’s own class.&amp;#160; This class references the view it wants to write to and the model it’ll use.&amp;#160; However, I’m not sure I want to use this pattern in Fubu, much less in my javascript code.&amp;#160; I mean views generally have several calls that are all related and if each call requires it’s own class/controller then things can get kind of dispersed.&amp;#160; Hmmm.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3131758074439086314-8279189208619452906?l=cannibalcode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cannibalcode.blogspot.com/feeds/8279189208619452906/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3131758074439086314&amp;postID=8279189208619452906' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3131758074439086314/posts/default/8279189208619452906'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3131758074439086314/posts/default/8279189208619452906'/><link rel='alternate' type='text/html' href='http://cannibalcode.blogspot.com/2010/01/my-venture-into-oop-javascript-pt2-mvc.html' title='My venture into OOP Javascript pt2: MVC?'/><author><name>Cannibal Coder</name><uri>http://www.blogger.com/profile/09578777459530774168</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_asa4XGVfcto/SW1rpDmvK8I/AAAAAAAAAHs/0Dy4B3bhsVo/S220/blackeye+003.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3131758074439086314.post-8731049404757414296</id><published>2010-01-27T08:51:00.001-08:00</published><updated>2010-01-27T08:51:07.899-08:00</updated><title type='text'>My venture into OOP Javascript pt1</title><content type='html'>&lt;p&gt;So I’m trying to wrap my head around javascript programming.&amp;#160; Not so much jquery this or modify that, so much as full on client side functionality.&amp;#160; &lt;/p&gt;  &lt;p&gt;I’m building a scheduling calendar using jquery.jqweek or something like that.&amp;#160; Basically looks like a google calendar.&amp;#160; But there is a great deal of functionality that I have to add in order for it to display correctly ( with the information I want displayed that is ) and for the adding and editing appointments.&amp;#160; A LOT of functionality.&amp;#160; So I’ve been struggling with the best way to organized my code and as it gets more organized I start seeing patterns that are familiar to my C# code, as well as patterns that are completely different.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3131758074439086314-8731049404757414296?l=cannibalcode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cannibalcode.blogspot.com/feeds/8731049404757414296/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3131758074439086314&amp;postID=8731049404757414296' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3131758074439086314/posts/default/8731049404757414296'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3131758074439086314/posts/default/8731049404757414296'/><link rel='alternate' type='text/html' href='http://cannibalcode.blogspot.com/2010/01/my-venture-into-oop-javascript-pt1.html' title='My venture into OOP Javascript pt1'/><author><name>Cannibal Coder</name><uri>http://www.blogger.com/profile/09578777459530774168</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_asa4XGVfcto/SW1rpDmvK8I/AAAAAAAAAHs/0Dy4B3bhsVo/S220/blackeye+003.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3131758074439086314.post-5364856166109889006</id><published>2010-01-27T08:50:00.001-08:00</published><updated>2010-01-27T08:50:52.457-08:00</updated><title type='text'>My venture into OOP Javascript pt4 : Linear vs cyclical</title><content type='html'>&lt;p&gt;Yet another issue that comes up is that ultimately you end up wanting to persist data and or retrieve data.&amp;#160; In server side code this is done synchronously.&amp;#160; You query the db and wait for the return.&amp;#160; In client side code, this is generally done via ajax.&amp;#160; which is, as per the a, asynchronously.&lt;/p&gt;  &lt;p&gt;This completely disrupts the flow of the app.&amp;#160; Instead of a method calling for some data, receiving it, and then processing it, you have to create a method for processing the data, then pass that method into the call for the data ( to be used as the call back from the ajax call ).&amp;#160; This is kind of topsy turvy and makes things more linear.&amp;#160; Less circular.&amp;#160; Instead of having method calls nested in other method calls walking down a chain then back up the chain and ultimately returning home to the original caller, I do a little of that but ultimately do off on a branch never to return.&amp;#160; &lt;/p&gt;  &lt;p&gt;I would very much like to find a way around that since it is completely counter to what I am used to, but more likely then not I will just have to create/find some patterns for understanding it and using it more efficiently.&lt;/p&gt;  &lt;p&gt;See if I could bring it all home to the controller then I could have the controller be the only point of contact with the dom.&amp;#160;&amp;#160; However if there are end points all over hell then the will each have to have contact with the dom . Or perhaps I could have a “dom touching service” where I keep all my end point code.&amp;#160; Hmmmm. again.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3131758074439086314-5364856166109889006?l=cannibalcode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cannibalcode.blogspot.com/feeds/5364856166109889006/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3131758074439086314&amp;postID=5364856166109889006' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3131758074439086314/posts/default/5364856166109889006'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3131758074439086314/posts/default/5364856166109889006'/><link rel='alternate' type='text/html' href='http://cannibalcode.blogspot.com/2010/01/my-venture-into-oop-javascript-pt4.html' title='My venture into OOP Javascript pt4 : Linear vs cyclical'/><author><name>Cannibal Coder</name><uri>http://www.blogger.com/profile/09578777459530774168</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_asa4XGVfcto/SW1rpDmvK8I/AAAAAAAAAHs/0Dy4B3bhsVo/S220/blackeye+003.JPG'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3131758074439086314.post-5433129019943094306</id><published>2010-01-21T09:26:00.001-08:00</published><updated>2010-01-21T09:26:20.116-08:00</updated><title type='text'>RubyMine Rocks</title><content type='html'>&lt;p&gt;RubyMine is the shit.&amp;#160; I don’t develop in ruby.&amp;#160; But I do do a lot of javascript.&lt;/p&gt;  &lt;p&gt;As we all know Visual Studio is completely untenable for javascript. I know that you can down load this and install that and eventually it wont be a piece of shit, it’ll merely suck but I’ve tried and failed and couldn’t give a shit to try to man handler That app into doing it’s job.&lt;/p&gt;  &lt;p&gt;In comes Jet Brains RubyMine.&amp;#160; Or at least into my life, It’s been around for a while.&amp;#160; Anyway, this app just further proves the point that Visual Studio is merely a shell for running Resharper.&amp;#160; I use RubyMine for my javascript and I get most if not all the wonderfulness that is Resharper.&amp;#160; I can click on function calls and be taken to the definition and vise versa, rename, refactor the whole nine yards.&amp;#160; It’s just awesome.&amp;#160; It even has great intellisense.&amp;#160; No longer do I feel like I’m developing in the dark.&amp;#160; Or worse that I have to use my brain to keep track of everything.&amp;#160;&amp;#160; I don’t know about you but after the ‘70’s I need all that’s left of my brain for the important stuff. Logic and porn.&amp;#160; &lt;/p&gt;  &lt;p&gt;One caveat is that RubyMine takes a little tweaking.&amp;#160; However, I have used several other javascript editors all of which required a ton of tweaking just to be usable and all in all seemed like big heavy unweildy messes.&amp;#160; RubyMine feels a lot cleaner, lighter and easier to manange, and once you get all your settings tweaked it’s just like writing C#. … Except for all the differences, but you know what I mean.&lt;/p&gt;  &lt;p&gt;I am currently refining my settings daily and will post them here if anyone is interested.&amp;#160; &lt;/p&gt;  &lt;p&gt;Also it costs $100.&amp;#160; So that kinda sucks but so does resharper and would you even consider developing with out that?   &lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3131758074439086314-5433129019943094306?l=cannibalcode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cannibalcode.blogspot.com/feeds/5433129019943094306/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3131758074439086314&amp;postID=5433129019943094306' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3131758074439086314/posts/default/5433129019943094306'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3131758074439086314/posts/default/5433129019943094306'/><link rel='alternate' type='text/html' href='http://cannibalcode.blogspot.com/2010/01/rubymine-rocks.html' title='RubyMine Rocks'/><author><name>Cannibal Coder</name><uri>http://www.blogger.com/profile/09578777459530774168</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_asa4XGVfcto/SW1rpDmvK8I/AAAAAAAAAHs/0Dy4B3bhsVo/S220/blackeye+003.JPG'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3131758074439086314.post-6630600948550721674</id><published>2009-11-24T08:38:00.001-08:00</published><updated>2009-11-24T10:23:58.800-08:00</updated><title type='text'>Find next specific day of week</title><content type='html'>&lt;p&gt;It’s not cutting edge but it’s something I forget about every 6 months and have to look up or figure out again.&amp;#160; So here it is.&amp;#160; Also I’m not convinced that it is the best way so if anyone knows a better one feel free to let me know.&lt;/p&gt;  &lt;p&gt;ok I have written a battery of tests changing both days around and this is the real deal.&lt;/p&gt;  &lt;p&gt;public DateTime getNextSpecificDay(DateTime d1, DayOfWeek day)   &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; var diff = day - d1.DayOfWeek;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; if(diff &amp;lt;= 0)    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; diff = diff + 7;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return d1.AddDays(diff);    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;this will find the next sunday.&amp;#160; if you pass in a sunday it will find the next one not the current one.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3131758074439086314-6630600948550721674?l=cannibalcode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cannibalcode.blogspot.com/feeds/6630600948550721674/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3131758074439086314&amp;postID=6630600948550721674' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3131758074439086314/posts/default/6630600948550721674'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3131758074439086314/posts/default/6630600948550721674'/><link rel='alternate' type='text/html' href='http://cannibalcode.blogspot.com/2009/11/find-next-specific-day-of-week.html' title='Find next specific day of week'/><author><name>Cannibal Coder</name><uri>http://www.blogger.com/profile/09578777459530774168</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_asa4XGVfcto/SW1rpDmvK8I/AAAAAAAAAHs/0Dy4B3bhsVo/S220/blackeye+003.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3131758074439086314.post-2123869676964762159</id><published>2009-09-09T11:39:00.001-07:00</published><updated>2009-09-09T11:39:44.783-07:00</updated><title type='text'>FluentNHibernate 'urn:nhibernate-mapping-2.2' has invalid child element</title><content type='html'>&lt;p&gt;Just a quick post for anyone who may be suffering with this error.&amp;#160; If you get an error that looks like this, &lt;/p&gt;  &lt;h4&gt;&lt;i&gt;NHibernate.MappingException: (XmlDocument)(3,6): XML validation error: The element 'class' in namespace 'urn:nhibernate-mapping-2.2' has invalid child element 'property' in namespace 'urn:nhibernate-mapping-2.2'. List of possible elements expected: 'meta, subselect, cache, synchronize, comment, tuplizer, id, composite-id' in namespace 'urn:nhibernate-mapping-2.2'. ---&amp;gt;&lt;/i&gt;&lt;/h4&gt;  &lt;p&gt;then there could be two causes for this depending on how you are configuring FNH.&lt;/p&gt;  &lt;p&gt;If you are using FluentMapping which is to say you are explicitly mapping each class then you must map the ID Column differently then the rest of them.&amp;#160; I just upgraded from NH 1. something and it’s concurrent version of FNH and I had the following in my origional mapping&amp;#160; UseIdentityForKey(x=&amp;gt;x.Id, “id”). After upgrading I saw that the UseIdentityForKey no longer existed and having read that there is a convention for discovering the Id column I figured that I’d just map it the same as the other Map(x=&amp;gt;x.Id).&amp;#160; Well that was kind of silly and produced the above error.&amp;#160; So I changed it Id(x=&amp;gt;x.Id) and all was good.&lt;/p&gt;  &lt;p&gt;The second case may be a bit more insidious.&amp;#160; If you are using Automapping, FNH will indeed discover your id columns for you.&amp;#160; Yay!&amp;#160; However, only if you have named then Id.&amp;#160; That’s capital I lower case d. If you have it all caps ( or for some reason all lower ) like ID then you will get the above error.&lt;/p&gt;  &lt;p&gt;I posted this cuz I didn’t find any other posts on this error.&amp;#160; Which could mean that I’m sooo brilliant that no one has even thought of making the mistakes that I make.&amp;#160; There’s another interpretation which I’m sure you’ve already come up will so I will leave it un uttered.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3131758074439086314-2123869676964762159?l=cannibalcode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cannibalcode.blogspot.com/feeds/2123869676964762159/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3131758074439086314&amp;postID=2123869676964762159' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3131758074439086314/posts/default/2123869676964762159'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3131758074439086314/posts/default/2123869676964762159'/><link rel='alternate' type='text/html' href='http://cannibalcode.blogspot.com/2009/09/fluentnhibernate-has-invalid-child.html' title='FluentNHibernate &amp;#39;urn:nhibernate-mapping-2.2&amp;#39; has invalid child element'/><author><name>Cannibal Coder</name><uri>http://www.blogger.com/profile/09578777459530774168</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_asa4XGVfcto/SW1rpDmvK8I/AAAAAAAAAHs/0Dy4B3bhsVo/S220/blackeye+003.JPG'/></author><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3131758074439086314.post-5710506346636374873</id><published>2009-05-11T18:40:00.001-07:00</published><updated>2009-05-11T18:40:42.691-07:00</updated><title type='text'>Poor man’s MVC</title><content type='html'>&lt;p&gt;Hi, I’m considering using a what I call a poor man’s MVC for a project at work.&amp;#160; Actually the more I think about it, the more I think I’m going to use &lt;a href="http://code.google.com/p/fubumvc/"&gt;Fubu&lt;/a&gt;, so I figured I’d blog this out before I forgot about it.&lt;/p&gt;  &lt;p&gt;The idea is that if you are in a medieval torture chamber and are being forced to use WebForms to write an app you could do the following.&lt;/p&gt;  &lt;p&gt;Let’s say you have a page with the following event’s on it.&amp;#160; &lt;/p&gt;  &lt;p&gt;Load()&lt;/p&gt;  &lt;p&gt;ApplyThumbscrew()&lt;/p&gt;  &lt;p&gt;ListenToScreams()&lt;/p&gt;  &lt;p&gt;the Load you surely recognize as one of the god awful page life cycle events. ApplyThumScrew() and ListenToScreams() are obviously ways that a user can enjoy ones self.&amp;#160; They click a button and said event happens.&lt;/p&gt;  &lt;p&gt;For each page you will have a corresponding controller ( or presenter if you will.&amp;#160; I’d rather not. ).&amp;#160; The Controller will have corresponding methods to the Page.&amp;#160; It will also have a specific input and output.&amp;#160; The sig will look something like this.&lt;/p&gt;  &lt;p&gt;public ApplyThumbscrewOutputModel ApplyThumbscrew(ApplyThumbscrewInputModel input) { }&lt;/p&gt;  &lt;p&gt;the input and output models are just &lt;a href="http://en.wikipedia.org/wiki/Data_Transfer_Object"&gt;DTOs&lt;/a&gt;. The input model has everything form the page that you need to do you stuff.&amp;#160; the output model has everything that the page needs from the server to do it’s stuff.&lt;/p&gt;  &lt;p&gt;so the ApplyThumbScrew() event would look like this&lt;/p&gt;  &lt;p&gt;but wait first let me tell you that you should be using &lt;a href="http://en.wikipedia.org/wiki/Dependency_injection"&gt;Dependency Injection&lt;/a&gt; for the controller ( and later the torture object ) and a proper &lt;a href="http://structuremap.sourceforge.net/Default.htm"&gt;IOC Container&lt;/a&gt;.&amp;#160; But that is beyond the scope of this blog and would require that I write more code in this horrible editor.&lt;/p&gt;  &lt;p&gt;protected void ApplyThumbscrew(blah blah blah)&lt;/p&gt;  &lt;p&gt;{&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;var input new ApplyThumbScrew{&lt;/p&gt;    &lt;p&gt;SizeOfThumb = txtSizeOfThumb.Text,&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/p&gt;    &lt;p&gt;HowBadIsPerson = txtHowBad.Text,&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt; HowSickAreYou = txtHowSick.Text,&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/p&gt;    &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; };&lt;/p&gt;    &lt;p&gt;var controller = new TortureController();&lt;/p&gt;    &lt;p&gt;var output = controller.ApplyThumbScrew(input);&lt;/p&gt;    &lt;p&gt;// then do something with return. my imagination is waning &lt;/p&gt;    &lt;p&gt;txtPersonsThumb.text = output.PainExpression;&lt;/p&gt;    &lt;p&gt;txtUsersEnjoyment.text = output.Enjoyment;&lt;/p&gt;    &lt;p&gt;}&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Then the corresponding Controller action would look like so&lt;/p&gt;  &lt;p&gt;public ApplyThumbscrewOutputModel ApplyThumbscrew(ApplyThumbscrewInputModel input) &lt;/p&gt;  &lt;p&gt;{&lt;/p&gt;  &lt;p&gt;var torture = new InterigationTechnique();&lt;/p&gt;  &lt;p&gt;var fun = torture.DoTheScrew(input.SizeOfThumb,input.HowBadIsPerson,input.HowSickAreYou);&lt;/p&gt;  &lt;p&gt;return new ApplyThumbscrewOutputModel{&lt;/p&gt;  &lt;p&gt;PainExpression=fun.Pain;&lt;/p&gt;  &lt;p&gt;Enjoyment = fun.Enjoyment;&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; };&lt;/p&gt;    &lt;p&gt;}&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;So you get the idea.&amp;#160; coding like this sucks and the formatting is all fubar so no more code.&lt;/p&gt;    &lt;p&gt;But the idea is that now you have the “codebehind” doing nothing but view related stuff.&amp;#160; I harvests information gives it to a more responsible agent then receives some goo to spread back on the view.&amp;#160; In so doing you have completely severed the nasty httpcontext and Request object and all that untestable shite from the business logic.&amp;#160; Rendering the business code, yep you guessed it, TESTABLE!&amp;#160; yay.&amp;#160; furthermore, if you ever are released from the dungeon, you will have code that you can then hook into any view mechanism you want.&amp;#160; Fubu, Asp.Net, some other shite.&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;I don’t understand what is going on with the formatting.&amp;#160; this is bullocks.&amp;#160; Anyway, sorry that this is kind of superficial but really you should be using a proper MVC framework anyway, not this webforms crap.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3131758074439086314-5710506346636374873?l=cannibalcode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cannibalcode.blogspot.com/feeds/5710506346636374873/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3131758074439086314&amp;postID=5710506346636374873' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3131758074439086314/posts/default/5710506346636374873'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3131758074439086314/posts/default/5710506346636374873'/><link rel='alternate' type='text/html' href='http://cannibalcode.blogspot.com/2009/05/poor-mans-mvc.html' title='Poor man’s MVC'/><author><name>Cannibal Coder</name><uri>http://www.blogger.com/profile/09578777459530774168</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_asa4XGVfcto/SW1rpDmvK8I/AAAAAAAAAHs/0Dy4B3bhsVo/S220/blackeye+003.JPG'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3131758074439086314.post-5855492083705173033</id><published>2009-05-11T15:02:00.001-07:00</published><updated>2009-05-11T15:04:23.610-07:00</updated><title type='text'>“I am not a crook!” Impersonation</title><content type='html'>&lt;p&gt;I was recently tasked with creating little web page that monitors the backup files on our servers.&amp;#160; Obviously I’m going to need to use particular credentials since the server hard drives are locked down.&lt;/p&gt;  &lt;p&gt;So I set about creating a little impersonation object.&amp;#160; I read a number of blogs and they all seemed to be showing similar systems and then I came across a tutorial from Microsoft.&amp;#160; Now normally I back page as quick as possible when I end up on one of there documentation pages because they are invariably Byzantine, but this time I figured I’d give it a shot.&amp;#160; Well they were saying oh you don’t have to do it this ways ( the way most blogs were showing it ) if you do this and that. So I said aha!&amp;#160; A short cut.&amp;#160; Well after many errors and exceptions it occurred to me to search the code repository on my machine and see if there was anything already there.&amp;#160; Brilliance! Low and behold!&amp;#160; log4net needs to access your file system in order to write it’s logs.&amp;#160; And guess what?&amp;#160; They are doing it the same way everyone else ( except microsoft ) is doing it.&amp;#160; So I kinda stripped out some of the stuff they had that was specific to their use and came up with the following.&lt;/p&gt;  &lt;p&gt;public class Impersonator    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; private readonly string _userName;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; private readonly string _domainName;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; private readonly string _password;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; private IntPtr _tokenHandle;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; private WindowsIdentity _identity;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; [DllImport(&amp;amp;quot;advapi32.dll&amp;amp;quot;, SetLastError = true)]     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; private static extern bool LogonUser(String lpszUsername, String lpszDomain, String lpszPassword, int dwLogonType, int dwLogonProvider, ref IntPtr phToken); &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; [DllImport(&amp;amp;quot;kernel32.dll&amp;amp;quot;, CharSet = CharSet.Auto)]    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; private extern static bool CloseHandle(IntPtr handle); &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; [DllImport(&amp;amp;quot;advapi32.dll&amp;amp;quot;, CharSet = CharSet.Auto, SetLastError = true)]    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; private extern static bool DuplicateToken(IntPtr ExistingTokenHandle, int SECURITY_IMPERSONATION_LEVEL, ref IntPtr DuplicateTokenHandle); &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public Impersonator(string userName, string password, string domainName)    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; _userName = userName;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; _domainName = domainName;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; _password = password;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; LogonUser();     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; } &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; private void LogonUser()    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; const int LOGON32_PROVIDER_DEFAULT = 0;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; //This parameter causes LogonUser to create a primary token.     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; const int LOGON32_LOGON_INTERACTIVE = 2; &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // Call LogonUser to obtain a handle to an access token.    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; _tokenHandle = IntPtr.Zero;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; if (!LogonUser(_userName, _domainName, _password, LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, ref _tokenHandle))     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; //log4net error handler.&amp;#160; I'm using log4net so I figured I'd take advantage     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; //NativeError error = NativeError.GetLastError();     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; throw new Exception(&amp;amp;quot;Failed to LogonUser [&amp;amp;quot; + _userName + &amp;amp;quot;] in Domain [&amp;amp;quot; + _domainName + &amp;amp;quot;].&amp;amp;quot;); // Error: &amp;amp;quot; + error.ToString());     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; } &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; const int SecurityImpersonation = 2;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; IntPtr dupeTokenHandle = IntPtr.Zero;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; if (!DuplicateToken(_tokenHandle, SecurityImpersonation, ref dupeTokenHandle))     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; //log4net error handler.&amp;#160; I'm using log4net so I figured I'd take advantage     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; //NativeError error = NativeError.GetLastError();     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; if (_tokenHandle != IntPtr.Zero)     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; CloseHandle(_tokenHandle);     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; throw new Exception(&amp;amp;quot;Failed to DuplicateToken after LogonUser.&amp;amp;quot;); // Error: &amp;amp;quot; + error.ToString());     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; } &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; _identity = new WindowsIdentity(dupeTokenHandle); &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // Free the tokens.    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; if (dupeTokenHandle != IntPtr.Zero)     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; CloseHandle(dupeTokenHandle);     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; if (_tokenHandle != IntPtr.Zero)     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; CloseHandle(_tokenHandle);     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; } &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public IDisposable Impersonate()    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return _identity != null ? new DisposableImpersonationContext(_identity.Impersonate()) : null;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; } &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; private sealed class DisposableImpersonationContext : IDisposable    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; private readonly WindowsImpersonationContext m_impersonationContext;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public DisposableImpersonationContext(WindowsImpersonationContext impersonationContext)     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; m_impersonationContext = impersonationContext;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public void Dispose()     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; m_impersonationContext.Undo();     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }     &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;One would then use it like so&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&amp;#160; var impersonator = new Impersonator(LoginName, Password, Domain);    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; using(impersonator.Impersonate())     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; if (!Directory.Exists(DirectoryPath)) return;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; var dir = new DirectoryInfo(DirectoryPath);     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; } &lt;/p&gt;  &lt;p&gt; Sorry about the code formatting I have to learn how to do this.&lt;/p&gt;  &lt;p&gt;After calling the impersonator.Impersonate() method( provided your credentials are proper ) you will be operating under those credentials.&amp;#160; In example I’m accessing a directory on a server that I specified in code else where.&lt;/p&gt;  &lt;p&gt;So this is the quick and dirty plus some of my bitching.&amp;#160; Here is a nice post by &lt;a href="http://www.west-wind.com/WebLog/posts/1572.aspx" target="_blank"&gt;Rick Strahl&lt;/a&gt; who goes into more detail.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3131758074439086314-5855492083705173033?l=cannibalcode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cannibalcode.blogspot.com/feeds/5855492083705173033/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3131758074439086314&amp;postID=5855492083705173033' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3131758074439086314/posts/default/5855492083705173033'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3131758074439086314/posts/default/5855492083705173033'/><link rel='alternate' type='text/html' href='http://cannibalcode.blogspot.com/2009/05/i-am-not-crook-impersonation.html' title='“I am not a crook!” Impersonation'/><author><name>Cannibal Coder</name><uri>http://www.blogger.com/profile/09578777459530774168</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_asa4XGVfcto/SW1rpDmvK8I/AAAAAAAAAHs/0Dy4B3bhsVo/S220/blackeye+003.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3131758074439086314.post-1906866376643491318</id><published>2009-05-09T07:31:00.001-07:00</published><updated>2009-05-09T07:31:27.995-07:00</updated><title type='text'>My Current Project</title><content type='html'>&lt;p&gt;So I’ve been tasked with re writing the booking engine ( basically the check out process for reserving a room at a bed and breakfast ) at work.&amp;#160; The current system was written five years ago and with what seems like a conscious effort towards obscurity, bloat, and inextricability.&amp;#160; The current system was some time after it’s creation cloned and the clone was used to access product listed on a listed on a winforms product.&amp;#160; It’s a little complicated.&amp;#160;&amp;#160; &lt;/p&gt;  &lt;p&gt;The two use different databases: SqlServer and Oracle, and have diverged considerably over time. There is, as one might imagine, an awful lot of logic in the code behind, the middle tier is composed of almost all static methods and the data layer is a combination of a number of messy home rolled ado wrappers using in line sql.&lt;/p&gt;  &lt;p&gt;I’m to combine the two processes into one as well as add considerable new functionality and checkout logic.&amp;#160; I will create a seam where the property ( a bed and breakfast ) has been chosen and the book it button is clicked, and replace everything through where the reservation conformation screen shows.&amp;#160; Sadly I will most likely have to interface with some legacy objects such as the credit card processing object and who knows what else.&amp;#160; And of course I will be using the legacy database schema.&lt;/p&gt;  &lt;p&gt;This promises to be a rather exciting project for me.&amp;#160; At the very least I will be able to create a proper business process, in a middle tier, using nice clean SOLID principles.&amp;#160; I will also be able to interface with webforms in my chosen manner ( see next post, if I ever write it ) and hopefully I will be ale to use NHibernate for data access, at least for some of it.&amp;#160; I will be slipping structuremap into the project.&amp;#160; If they don’t like it I can always back it out and use a poor mans dependency injection, but the hope is that they will think DI and StructureMap in particular are very cool.&amp;#160; I believe and or hope that this will sow the seeds of future patterns ( i.e. using NHibernate, SOLID, StructureMap etc ) for future projects.&amp;#160; Hopefully it wont also cost me my job.&amp;#160; You know how people love change. &lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3131758074439086314-1906866376643491318?l=cannibalcode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cannibalcode.blogspot.com/feeds/1906866376643491318/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3131758074439086314&amp;postID=1906866376643491318' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3131758074439086314/posts/default/1906866376643491318'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3131758074439086314/posts/default/1906866376643491318'/><link rel='alternate' type='text/html' href='http://cannibalcode.blogspot.com/2009/05/my-current-project.html' title='My Current Project'/><author><name>Cannibal Coder</name><uri>http://www.blogger.com/profile/09578777459530774168</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_asa4XGVfcto/SW1rpDmvK8I/AAAAAAAAAHs/0Dy4B3bhsVo/S220/blackeye+003.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3131758074439086314.post-4741524783311912082</id><published>2009-02-01T07:59:00.000-08:00</published><updated>2009-02-01T08:29:05.669-08:00</updated><title type='text'>T4 Templates, T4 Toolbox, and VisualSVN</title><content type='html'>Hello, I spent some time messing with T4 this week.  It seemed that T4 could be pretty powerful once you put in the considerable time and effort necessary to figure out how it works.  Having said that It's not very intuitive.  I guess that the basic template is pretty easy to do.  It ends up looking like an old asp page,  alot of the code that should be rendered then blocks of escaped code for some c# that can creates the dynamic info you need.  This will then create a file as a subfile of your template every time the template is saved.  So if your template is called MyStupidTempate.tt then when you save it you will see in solution explorer a plus sign next to the file.  When expanded you will see MyStupidTempate.cs or .sql or .wtfe.&lt;br /&gt;In short order you realize that you'll need T4 toolbox to do anything much more advanced than that.  &lt;a href="http://www.codeplex.com/t4toolbox"&gt;T4 Toolbox&lt;/a&gt; is an open source set of tools that allows you to do things such as create multiple output files for a template, use multiple templates to create the output and several other nifty things.&lt;br /&gt;Here's the bitch. T4 Toolbox has an incompatability with VisualSVN.  It's one or the other.  In my office it's VisualSVN because it is an intragal part of our productivity.  I did conciderable due dilligence on the subject and found that &lt;a href="http://codebetter.com/blogs/kyle.baley/default.aspx"&gt;Kyle Baley&lt;/a&gt; had been down the same road before.  I email Kyle and was informed that the issue hadn't been resolved, that is was on the T4 Toolbox side and in fact seems not to really even be acknowledged by the T4 Template guys.  This, for the time being has landed T4 and it's nifty Toolbox in the crapper for me.  I subsquently just wrote some C# code which did my codegen for me for this particular job and went on my merry way.&lt;br /&gt;All told I have to say that my experience with &lt;a href="http://www.codesmithtools.com/"&gt;CodeSmith&lt;/a&gt; in the past was much more fruitful.  Pretty inutitve stuff and a very helpful IDE with intellisence and other perks.  It's not free which is a drawback I guess but it's not very expensive either.&lt;br /&gt;I don't do a whole lot of codegen so this isn't too big a deal for me but if I did or when I do I will definitly look back into CodeSmith and see if it has the capabilities I would need to integrate it into our application, build process, etc.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3131758074439086314-4741524783311912082?l=cannibalcode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cannibalcode.blogspot.com/feeds/4741524783311912082/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3131758074439086314&amp;postID=4741524783311912082' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3131758074439086314/posts/default/4741524783311912082'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3131758074439086314/posts/default/4741524783311912082'/><link rel='alternate' type='text/html' href='http://cannibalcode.blogspot.com/2009/02/t4-templates-t4-toolbox-and-visualsvn.html' title='T4 Templates, T4 Toolbox, and VisualSVN'/><author><name>Cannibal Coder</name><uri>http://www.blogger.com/profile/11951487273106045492</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_PmJPwpgzQW8/SXAMr3BDMDI/AAAAAAAAAAM/OsZvZDbWiBI/S220/blackeye+003.JPG'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3131758074439086314.post-2609442161953305716</id><published>2009-01-22T19:50:00.000-08:00</published><updated>2009-01-22T19:52:24.791-08:00</updated><title type='text'>I'm a little lizard trapped in a man's skin</title><content type='html'>Hello.&lt;br /&gt;Today is truly a glorious day.  Yes today, some several weeks of struggle and strife have come to an end.  After terrific hardship suffered at the hands of a terrible depot I can now say that I xxx xxxx have persevered.  My computer is now in a state not unlike it was in at the beginning of these troubled times.  I may be older.  But I am also definitely wiser.  Having had to rub bellies with the darkest of vermin I have learned much about thier habbits and idiosycracies. Today friends and loved ones, today my computer works again!&lt;br /&gt;&lt;br /&gt;I will give detail about my trial and tribulations when I have recovered from the effort of perseverance.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3131758074439086314-2609442161953305716?l=cannibalcode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cannibalcode.blogspot.com/feeds/2609442161953305716/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3131758074439086314&amp;postID=2609442161953305716' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3131758074439086314/posts/default/2609442161953305716'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3131758074439086314/posts/default/2609442161953305716'/><link rel='alternate' type='text/html' href='http://cannibalcode.blogspot.com/2009/01/im-little-lizard-trapped-in-mans-skin.html' title='I&apos;m a little lizard trapped in a man&apos;s skin'/><author><name>Cannibal Coder</name><uri>http://www.blogger.com/profile/11951487273106045492</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_PmJPwpgzQW8/SXAMr3BDMDI/AAAAAAAAAAM/OsZvZDbWiBI/S220/blackeye+003.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3131758074439086314.post-463593966195328750</id><published>2009-01-13T19:53:00.000-08:00</published><updated>2009-01-13T20:15:00.106-08:00</updated><title type='text'>Freakin IIS Start Website</title><content type='html'>Ok, so here we go a real post!  &lt;br /&gt;I've been using the visual studio development server to run an app that I'm building using FubuMVC.  For some reason I was getting some rather strange behavior and I remember that Chad had said that the vs dev server is a FPOS and that I should use IIS so I switched over only to receive this retarded message.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style:italic;"&gt;Unable to start debugging on the web server. The server does not support debugging of ASP.NET or ATL Server applications. Click Help for more information on how to enable debugging.  You may also want to refer to the ASP.NET and ATL Server debugging&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;well after searching high and low and trying all sorts of BS I started digging in IIS (7) and found that the Default Web Site was not started and in fact bloody well wouldn't start. So back to the freakin google and I find that perhaps my port 80 is being used and that if go to a command prompt and type NETSTAT -ano I could see a list of all the ports being used.  Sure enough port 80 is being used by a PID 1928. To see if that is truly the problem, I change the bindings in IIS7 (hyperlink on the right side of then now extremly cluttered iis screen) from port 80 to port 8080 and indeed that works. &lt;br /&gt; &lt;br /&gt;So what the hell is PID 1928 well I don't know so I go to Task Manager and on the process tab I select view -&gt; select columns and check PID.  That ought to do it I think, but pid 1928 doesn't show up.  Well it's back to the interweb for some more of the google and I find out about a program called &lt;a href="http://technet.microsoft.com/en-us/sysinternals/bb896653.aspx"&gt;Process Explorer&lt;/a&gt; This is essentially Task Manager on steroids and, well, frankly I like steroids.  This thing is pretty cool and has way more colors that TM and it actually shows me my blasted PID.  It turns out that I have Apache server running for some freakin reason.  I kill the process and pow the Default Website starts right up!  &lt;br /&gt;&lt;br /&gt;So there you have it I have posted on something that might be helpful to someone if they can get through all the prose to the meat.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3131758074439086314-463593966195328750?l=cannibalcode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cannibalcode.blogspot.com/feeds/463593966195328750/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3131758074439086314&amp;postID=463593966195328750' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3131758074439086314/posts/default/463593966195328750'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3131758074439086314/posts/default/463593966195328750'/><link rel='alternate' type='text/html' href='http://cannibalcode.blogspot.com/2009/01/freakin-iis-start-website.html' title='Freakin IIS Start Website'/><author><name>Cannibal Coder</name><uri>http://www.blogger.com/profile/09578777459530774168</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_asa4XGVfcto/SW1rpDmvK8I/AAAAAAAAAHs/0Dy4B3bhsVo/S220/blackeye+003.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3131758074439086314.post-2148464716551524138</id><published>2008-10-06T11:38:00.001-07:00</published><updated>2008-10-06T11:41:07.395-07:00</updated><title type='text'>You must eat your SOLIDs!</title><content type='html'>Having just attended the Day of the Donkey, aka Los Techies Pablo’s Day of TDD aka something a little more blue which will leave to your imagination, I think I will violate my blogs virginity with a post about TDD. &lt;br /&gt;The venerable folks behind Pablo’s conference chose to use a bare bones approach to TDD.  That is to say they wanted to focus primarily on just the T the D and the D and not all the important but ancillary parts.  I’m speaking of mocking frameworks, IoC containers,  the solid ideas of SOLID.  The idea clearly, being that TDD can be quite daunting to new comers and when presented with all the other even more complex aspects it would be a total overload, both of the presentations and the consumers.  &lt;br /&gt;This was definitely a good plan given the amount of time available.  I even hear some quite complaints that it covered too much.  However It really made clear to me just how important these things are. Having to type up a class called FakeRepository was kind of painful on principle.  Ultimately we did touch on Rhino Mocks and programming to interfaces as it was almost impossible to avoid.   &lt;br /&gt;One could probably live without IoC containers and even mock objects but I really don’t think there’s much point in learning about TDD if you aren’t already familiar with SOLID.  It really seems to be a pre-requisite.  As long as you’re using huge classes with multiple responsibilities and no interfaces you’re going to find TDD to be very painful.&lt;br /&gt; At the end of Pablo’s TDD we broke into groups to discuss different topics solid being one of them and I’m sure that was helpful l.  I think if Pablo decides to do another similar conference I would suggest more emphasis on SOLID from the get go.   Maybe even do  a Pablo’s Day of SOLIDS Digestion! &lt;br /&gt;Anyway, here is a great post about SOLID with a bunch of great links&lt;br /&gt;&lt;a href="http://mmiika.wordpress.com/oo-design-principles/" target="_blank" &gt; SOLID Principles &lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3131758074439086314-2148464716551524138?l=cannibalcode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cannibalcode.blogspot.com/feeds/2148464716551524138/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3131758074439086314&amp;postID=2148464716551524138' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3131758074439086314/posts/default/2148464716551524138'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3131758074439086314/posts/default/2148464716551524138'/><link rel='alternate' type='text/html' href='http://cannibalcode.blogspot.com/2008/10/having-just-attended-day-of-donkey-aka.html' title='You must eat your SOLIDs!'/><author><name>Cannibal Coder</name><uri>http://www.blogger.com/profile/09578777459530774168</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://3.bp.blogspot.com/_asa4XGVfcto/SW1rpDmvK8I/AAAAAAAAAHs/0Dy4B3bhsVo/S220/blackeye+003.JPG'/></author><thr:total>0</thr:total></entry></feed>
