Do Things Debt

January 19, 2008

Do Things Debt: The debt to yourself and those around you accumulate from having things to do (take out the bins, do the washing, build an extension on the house with floating floors, wall mounts for TV and sweet looking down lights you saw one day at Bunnings).

Do things debt builds just like normal monetary debt as you gain things to do – doing these things is much like making a payment off your monetary debt.

Do things debt has many similes with normal monetary debt:

  • As you gain more debts they become harder to manage.
  • The larger the debt the harder it is to pay.
  • The larger the debt the more worry and stress it can cause.
  • You lie awake at night worrying about how to pay the debt.
  • Debts can be shared between people (joint do things debt account).
  • Debts can be repaid to others.
  • Some debts must be paid by the final date or they will incur serious consequences.
  • Most debtors operate an early payment reward scheme – especially if payment is made as soon as the debt is incurred.
  • Non payment will result in debtors talking to each other. You may get a name if you don’t pay them ontime and it may be difficult to gain credit.
  • You can loan from others and create a debt.
  • Recurring debts – keep coming back even if you pay them off. Non payments accumulate as other debts.
  • Paying off certain debts may have a chain reaction and pay off related debts – this is negotiable with the debtor(s). Non payment of debts can have this effect in reverse – non payment may lead to creation of additional debts.
  • Personal debts and business debts.
  • The longer you leave a debt the more interest it accumulates. The original debt may increase at the whim of the debtor. It’s best to pay early to aviod this situation.
  • Debts may be exchanged with others for debts of similar value.
  • Some debts you may be unable to pay on your own, so be smart and have somebody help you pay, or evnt pay them for you – be careful though – you may gain another debt which is harder to pay than the original debt!
  • Some people are better at managing debt than others.
  • People of the opposite sex seem to create more debts than those of the same sex.
  • Taking on debts for others without asking for any credit in return is rewarding. There are organisations (government, not for profit etc) which handle this very thing!
  • People who don’t pay debts regularly on time are colloquially known as procrastinators.

Tips for dealing with Do Things Debt

  • Allocate time each day to think about your debts and strategise how to pay them.
  • Ensure you don’t spend too much time thinking about your debts – don’t let them rule your life!
  • Don’t have unpaid debts for too long – and never leave them long enough to get a “Final Reminder” – especially in the domestic environment. Leaving debts for too long may incur a penalty debt.
  • Don’t take on debts you cannot pay!
  • Don’t forget about debts – especially in a domestic environment. All you debts are stored in a secure vault and cannot be erased. Your outstanding debts will be remembered for *years* to come.
  • You cannot run and hide from your debts (pub, shopping, sleep etc). You will be contacted by any available means with reminder notices.
  • Debtors don’t care what you are doing when they call on their debts, you may be expected to pay immediately. You may be able to negotiate an extension at the expense of additional debt.
  • Make a time on weekends or after work to pay a few of your debts in one hit! I may seem like a lot of payment at the time, but you will be thankful later.
  • Seek advice from others who have paid similar debts or talk to specialists for professional advice (e.g go to Bunnings for information on how to pay a domestic enhancement debt). Remember you are not alone.
  • Keep an open dialogue with your debtors – don’t leave it until the final reminder to action. Negotiating new payment schedules is possible, and your debtors should be open to suggestions.
  • There are special software programs available with specialised formulas to assist with debt management – Google “To Do List” to find these packages. If you are old fashioned there are methods for managing debts using pen and paper. A highly technical system some revolutionaries are using involves a whiteboard which sticks to the fridge using magnets!
  • Get the kids to help you pay your debts – the best part is you will not incur any additional debt in return! This is a loophole which should be exploited as much as possible. Be careful however, as this method may invoke monetary problems around Christmas and birthday time.

And remember – keeping on top of your things to do debts is the key to a happy and successful life!


ASP.NET MVC Test

January 4, 2008

UPDATE: This article is rather old now – MVC Preview 3 is out and I suggest looking at the new testing stuff in that :) http://weblogs.asp.net/scottgu/archive/2008/05/27/asp-net-mvc-preview-3-release.aspx

I’ve been playing with MVC for a couple of days now as part of my professional development at Readify – and this afternoon it was time to attack a bit of testing.

So I cracked open Scott’s post on MVC and zoomed in on the unit testing code he posted.

Now, because ASP.NET MVC is quite new (its CTP, not beta, not anything, just a preview – so its *real new*) the dev community is still poking around trying out this and that and in the case of testing, not having a real smooth ride.

In Scott’s post he uses a class called TestViewEngine, which allows him to instantiate and test the views defined in the test web app project, running asserts etc on the output. But this class doesn’t exist in the MVC stuff yet – that I can see anyway (or my Googling).

So I set out on a Google fest to try to get this test code to run… and it turns out it was just a little more difficult than just creating a TestViewEngine class. The final result make use of the excellent Rhino mocking framework and my own TestViewEngine implementation.

I got the mocking code from here: http://haacked.com/archive/2007/12/09/writing-unit-tests-for-controller-actions.aspx a great article on the initial state of MVC testing. I then combine this code with Scott’s and some of my own for the final result. You can download Rhino Mocks from here: http://www.ayende.com/projects/rhino-mocks/downloads.aspx.

There are also some great posts here http://www.persistall.com/ which may help you out a bit.

Basically the code is as on haacked for the most part:

 [TestMethod]
        public void AllForUser()
        {

            RouteTable.Routes.Add(new Route
            {
                Url = "Snippet/Detail/[id]",
                RouteHandler = typeof(MvcRouteHandler)
            });

            SnippetController controller = new SnippetController();

            MockRepository mocks = new MockRepository();
            IHttpContext httpContextMock = mocks.DynamicMock<IHttpContext>();
            IHttpRequest requestMock = mocks.DynamicMock<IHttpRequest>();
            IHttpResponse responseMock = mocks.DynamicMock<IHttpResponse>();
            SetupResult.For(httpContextMock.Request).Return(requestMock);
            SetupResult.For(httpContextMock.Response).Return(responseMock);
            SetupResult.For(requestMock.ApplicationPath).Return("/");

            responseMock.Redirect("/Snippet/Detail/1");

            RouteData routeData = new RouteData();
            routeData.Values.Add("Action", "SnippetDetail");
            routeData.Values.Add("Controller", "Snippet");

            ControllerContext contextMock = new
              ControllerContext(httpContextMock, routeData, controller);
            mocks.ReplayAll();

            controller.GetType().GetProperty("TempData").SetValue(controller, new TempDataDictionary(httpContextMock), null);

            controller.ControllerContext = contextMock;

            TestViewEngine tve = new TestViewEngine();

            controller.ViewFactory = tve;

            controller.SnippetDetail(1);

            Assert.AreEqual(typeof(Snippet), tve.View.ViewData.GetType(), "Snippet object passed to view");
            Assert.AreEqual(1, tve.View.GetViewData<Snippet>().SnippetId, "Correct Snippet ID Processed");
            Assert.AreEqual("SnippetDetail", tve.View.ViewName, "Correct view rendered");
        }

    }

The only thing I had to add here was the following line:

</pre>
<pre>controller.GetType().GetProperty("TempData").SetValue(controller, new TempDataDictionary(httpContextMock), null);

The problem was that the RenderView call in my ControllerAction was throwing a null argument exception because TempData on the object was null and is not allowed to be – thanks to a comment by Alexey on haacked for this!

Then I created my own little TestViewEngine class to keep in line with what Scott was doing in his post:


 public class TestViewEngine : IViewFactory
    {

        TestView _view;

        #region IView Members

        #endregion

        #region IViewFactory Members

        public IView CreateView(ControllerContext controllerContext, string viewName, string masterName, object viewData)
        {
            _view = new TestView(controllerContext, viewName, masterName, viewData);
            return _view;
        }

        public TestView View
        {
            get
            {
                return _view;
            }
        }

        #endregion
    }

    public class TestView : IView, IViewDataContainer
    {
        ControllerContext _controllerContext;
        string _viewName;
        string _masterName;
        object _viewData;

        public TestView(ControllerContext controllerContext, string viewName, string masterName, object viewData)
        {
            _controllerContext = controllerContext;
            _viewName = viewName;
            _masterName = masterName;
            _viewData = viewData;
        }

        public T GetViewData<T>()
        {
            return (T)_viewData;
        }

        public string ViewName
        {
            get
            {
                return _viewName;
            }
        }

        #region IView Members

        public void RenderView(ViewContext viewContext)
        {
            //throw new NotImplementedException();
        }

        #endregion

        #region IViewDataContainer Members

        public object ViewData
        {
            get
            {
                return _viewData;
            }
        }

        #endregion
    }

With this code in place you should be able to correctly run the asserts as in Scott’s article.

From what I have read there are going to be a lot of additions in the coming versions that will assist with testing – hopefully this includes things to assist with mocking the View requests etc. For now at least we can run some testing code to get us through.


CodeJAK Designs

January 3, 2008

As part of my MVC PD this week I’m creating a real website that does real things.

This website is called CodeJAK and I hope to have it go live soon.

Here is the initial design “CodeJAK design by Alex Knight” – its cool as!

So here is the low-down:

CodeJAK is a site that allows you to store code snippets – don’t let me lose you there, it’s got some cool features (okay, it *will* have some cool features).

First and foremost my plans for CodeJAK are to create a Visual Studio plugin that manages your snippets. All snippets you store in CodeJAK are stored on-line – so when you install CodeJAK on another machine and log in, all your snippets will be synched between your machines automatically.

The next feature is that you can publish your snippets if you like, i.e. share them. Then others can search for published snippets (in VS, or on the accompanying website).

Other features include community features like tagging snippets, comments on snippets, RSS feeds (subs to a feed based on user or tags or some other search query) – you get the idea (don’t steal it! – if you think its good then leave a comment and help me out!)

P.S. If you have heard of this idea before (which I havn’t) then please let me know (let me down gently).


MVC Server Control Code Behind Problem

January 3, 2008

This week I am doing a few days PD on the new ASP.NET MVC Framework.

I came across a problem when using server controls with MVC based ViewPage (which is inherited from System.Web.UI.Page) class.

Basically you create a page, add some controls and the controls are not accessible in code behind.

After a bit of hunting I discovered a simple workaround – every time you create a ViewPage based ASPX file, right click on the project and click “Convert to Web Application”.

Convert to Web Application

What this does is update the *.aspx.designer.cs/vb files that let you properly use codebehind.

This has been identified as a bug (here, but I can’t find the source of the bug identification, comments please!).