Build, Train and Listen

This afternoon I conducted a training for a number of teachers that will be using my new website CMS to perform website updates.I know alot of developers groan at the thought of talking to the users of their software. People truly are stupid in numbers. Even I don’t like it all that much. That being said, I still force myself to do these trainings from time to time.

Normally we have three other people that actually perform the trainings, but when a number of new features come out for the first time, or we are trying something new I setup a new presentation and talk before all the people. You would be suprised how beneficial this can really be to the health of the project. Now, there is definately alot of extra chatter going on in the form of complaining, or a user that can’t figure out whether to right click or left click, but as a whole you can instantly see trends arise in what people are trying to do that they can’t do.

Amazingly, the more of these I go to you consistently see the average person do the same set of things to the software. This helps so much in jotting down notes on how to make this easier or make that easier. I can get quality feedback in 90 minutes that would take me much longer to retrieve from Reviewers. Unfortunately you do have to filter out a lot of extra suggestions that is irrelevant, like the one user that wants it to everything for them just outside the realm of reality.

Being in a school district and making software for internal use only definately has it’s benefits so this probably doesn’t apply to all situations but it should still be considered. Maybe along the lines of telling a user of the system to user a piece of software like normal and you watch them go about their normal work. The desire here, at least for me is to eliminate the pain they have to deal with when I am not present. My aim is to make it as easy as possible for that user to utilize my software so that they will recommend to management that we should continue working because of this or that, or they should renew my contract etc…

Throughout the whole month of September I will be doing at least one training a week if not twice at two school per week. By the end of the month we should have the majority of the schools out of the way. Hopefully then the teachers will stop pestering me =)

It is quite a task to attempt to bring about 1500 teachers up to speed with a new piece of software in a little over 2 months and also continue on with my normal duties. I think in the end the trainees will also train the trainer. Both parties are receiving. Cheers!

Advertisements

Ajax and MonoRail

This is a repost of an example I created for using.castleproject.orgI just used some Ajax functionality on another project and I figured I would post some code of what I found out after struggling with a couple of pieces for awhile.MonoRail utilizes the Prototype Javascript Framework to perform Ajax calls, so worst case scenario, you can write javascript code directly against the prototype library. All you need to do on your MonoRail view is include the javascript declaration by placing the following at the top of your view:

$AjaxHelper.GetJavascriptFunctions()

First, You’ll need to look at the Castle Project AjaxHelper documentation. You don’t need to memorize the whole thing, but pay close attention to LinkToRemote and ButtonToRemote. There is ALOT of stuff in there, so try not to feel overwhelmed. I know I did at first =)For my project, I had to input some price information, add the price to a collection on the controller, and then display it on the view before continuing. The easiest way to do this is to serialize the form and pass it when performing the Ajax call, Ajax then invokes an Action on your controller, and you respond by either rendering some text, or rendering another view into the “update” div. Here is my code for my ButtonToRemote: 

$AjaxHelper.ButtonToRemote("Add Price", "addprice.rails", $DictHelper.CreateDict("update=prices","with=Form.serialize($('itemform'))"))


 Let’s step through the parameters one by one.

  • “Add Price”
    • This is the text that will be shown on the button. pretty basic
  • “addprice.rails”
    • This is the action to call on the controller
  • $DictHelper.CreateDict(“update=prices”,“with=Form.serialize($(‘itemform’))”))
    • The dictionary values to pass is where it is a little tricky. “update=prices” is the id of the div that Ajax will update upon sending a response. So if you render text, or another view it will appear within this div id. The second dictionary parameter is for values that you want to pass to your action, hence the with= parameter. You can pass the entire form as I have, or single values such as an id

Note, that I am using $(‘itemform’) instead of ‘this’ when telling the AjaxHelper to serialize the form. This refers to the id value of the form tag. I tried it both ways and it didn’t seem to want to work the other way. Perhaps someone else has a different experience with this. Next, setup your action to do whatever processing you need and then Render a view like so:

public void AddPrice([DataBind("price")] Price price)
{
// Do some work with price object
RenderView("priceList");
CancelLayout();
}

The RenderView call will render the view called priceList.vm that is located in the same directory as the Controllers view. Then you have to call CancelLayout to cancel the layout processing which occurs last, otherwise the layout will also be rendered within the div. If you call RenderText it will simply output that text into the div.The reason I am rendering a view into the div is because it is displaying a collection of prices along with edit/delete links for each. In its basic form, the functionality here is the same as an Ajax DataGrid/GridView if we were in the WebForms world, except without the burden of Page lifecycle.On a project I was working on at my workplace, I needed to expand/collapse divs and upon expanding I make an Ajax call to the database to grab the detail view of the expanded div. When I created that, I found it was easier to create a custom javascript function in which I made a call via the prototype library using an Ajax.Request. There are many things you can leverage with using the Prototype framework through MonoRail and the sky is the limit. Check the Castle Project Forum for helpful information, or you can search through the Castle Project Users Newsgroup.Another good place to start is to read the PrototypeJS documentation. This is recommended because all MonoRail is doing is just wrapping the calls to ProtoType. Hopefully in the near future we might see a more rich ajax framework arise from MonoRail, but at the moment I think there is alot more areas that can be focused on within Castle rather than dump time into a custom built Ajax Framework. As they say, If it ain’t broken, then don’t fix it! Not at least until there is a large enough following.

Testing MonoRail Controllers from Castle’s Trunk

Note: This post was on my old blog, but it is linked to using.castleproject.org and I wanted to move it to my new blog for future reference.Originally, Hammett placed a AbstractMRTestCase in the same namespace to facilitate testing of controllers. This class simulated a browser by supplying the user with access to session, request, response etc… This class didn’t work too well and was clunky to use. The guys at Eleutian came up with their own solution awhile ago that you can read here. This worked by mocking out everything that the Controller class needed using Rhino Mocks. This worked much better, although it was a little tricky to pull down and use yourself.
Enter BaseControllerTest! This works off of Eleutian’s example and makes the whole deal much easier. Here is an example of how you would go about using it.
First, Your Test Fixture must derive from BaseControllerTest. In this example I am testing a SearchController I made for CMS software:

[TestFixture]
public class SearchControllerTestCases : BaseControllerTest{}

Next, You must instantiate your Controller class. I do this in the SetUp method, as I am using the Controller in more than one test and I don’t want to violate the DRY principle:

[SetUp]
public void SetUp()
{

_mocks = new MockRepository();

_searchService = _mocks.CreateMock();

_searchController = new SearchController(_searchService);
}

As you can see I am also passing in a mock of a Serivce that is provided by Windsor at runtime. Now we have created our controller and set everything up. Now we are ready to perform our first test. The following test Searches for a Teacher by their username. Note in the test that I make a call to PrepareController. This sets up the controller with the specified area, controller and action. Take a gander at the code for BaseControllerTest class here and it will give you a much better idea of what PrepareController is doing. All it does is setup the IRailsEngineContext by creating instances of mock classes that will respond to your test. Here is the code in my test to perform SearchForTeacher():

[Test]public void CanSearchForTeacher(){IList teachers = new List();PrepareController(_searchController, "", "Search", "FindTeacher");string teacherName = "username";using (_mocks.Unordered()){Expect.Call(_searchService.FindTeacher(teacherName)).Return(teachers);}_mocks.ReplayAll();_searchController.FindTeacher(teacherName);_mocks.VerifyAll();}


So the only mock expectation I need to setup here is for SearchService.FindTeacher that is called when FindTeacher() is called on the controller. If I had values that needed to be set such as PropertyBag values, or CurrentUser. All you need to do is just set them by using the Context variable available through BaseController test like so:

[SetUp]public void SetUp(){MockRepository _mocks = new MockRepository();_webSiteManageController = new WebSiteManageController();_user = _mocks.CreateMock();PrepareController(_webSiteManageController, "manage", "WebSite", "List");Context.CurrentUser = _user;}

Note where I am setting Context.CurrentUser as it is accessed through this Controller on the AuthorizationFilter I have setup on the WebSiteManageController class. This way, everytime the AuthroizationFilter is run, it will return true to allow access to the underlying controller.Hopefully that gives you a jump start on using Castle’s new Controller Test support! Have fun!

Beginning Agile Practices

Over the last couple of weeks I have started to embrace Agile practices on any new projects that we have coming up. I have found that being a sole developer, it is actually more difficult to follow agile.I don’t have anyone else to keep me inline and it takes a lot more discipline to make sure to do daily task checks and to ask myself what I am going to complete that day and what obstacles are standing in my way. Not that this is a bad thing, it will only make me more disciplined so if I ever do work with an agile team I will be ahead of the curve. A couple of things I have made note of after the first couple of weeks:

  1.  I do have a cork board setup with note cards. I have the columns of “Planned, In Progress, Review, Complete, Blocked”. The cork board only tracks the current iteration and is a visual tool for myself and anyone else involved in the project.
  2. I am using an online agile management tool called Acunote. This tool is very useful because it generates the burndown and backlog charts for me and has a really easy to use UI. I tried a couple of other tools but you had to input WAY too much information in order to input tasks and became cumbersome. A very neat tool that I did review was ThoughtWorks Mingle, at the time though it was still in beta.
  3. I found that once I started to use Agile methodologies, it seems like everyone else just fell in line. Once I explained how to iterations worked and backlog everyone realized that since the software was released in shorter cycles that they could see immediate results and forced them to think more about what is more vital and what they don’t necessarily need right away.

In general,  Agile seems to work very well for me. I do want to purchase some more agile books. I have only read one up to this point in time and need to read another one to take the process further. I feel like I am only starting to scratch the surface in what agile can do. Cheers!

MonoRail CMS

There is a very good discussion going on the Castle Project Users group. It has to do with building a CMS with MonoRail and/or ActiveRecord.I have just recently completed building a CMS that I am working at the school district. You can see it at http://www.flaglerschools.com. The portal is pretty complex and is very strongly coupled to K-12 education. Basically it has some of the following features:

  •  ActiveDirectory Authentication/Authorization
  • Each Teacher in the district can create a website
  • Schools/Departments can also maintain their websites in the same manner as teachers
  • Role management system to allow multiple users to manage one School/Department website
  • Blogs/Podcasts support for teachers
  • District/School/Department News blogs for showing items relevant to that area of the website

The main goal of this CMS was to be able to focus the mass amounts of information into the district page. Being a school district also brings with it challenges as far as being able to showcase everything that is going on within the school district.In the mentioned thread, goodwill makes a good point that a good tool starts out to solve a problem and then is refactored back to a framework and I think that is the case here. The k-12 portal solves a problem and now with some refining, can be factored back to a higher level framework to be able to plugin to more scenarios easily. Whether it can be refactored to the point of a general CMS is another questions because when development was first started, it’s goal was to provide a CMS for a school district and not a general portal.

I believe this is where it becomes more difficult to be able to create a good CMS. Making a good framework for a CMS is difficult work. Take a look at Umbraco or Mambo. These are two examples of really well developed CMS’s. They have a large following and are open source. Also remember that they have been around for awhile, and as time has progressed they have become easier to use and setup. The only problem with these CMS’s is that once you start to drive down into details it becomes more difficult to tailor to requirements. You could always add the “modules” yourself and voila!

The tricky part is developing a CMS that can adapt well to that change. To be able to make a pluggable framework where you can add new modules the framework needs to be pretty flexible. I haven’t seen alot of CMS’s that have done this well. Maybe a MonoRail framework will be different.Bottom line is, it is time for MonoRail to join the CMS party. I hope that someone starts developing an Open Source one. I would gladly put some time in and contribute some code.

VMWare Fusion with OSX Leopard

Back in June I attended WWDC 2007 and received a copy of Leopard Developer Preview. I’ve been running it on my macbook since then and it is somewhat stable. There are a few problems with text rendering in FireFox and both Safari and Firefox crashing every now and then but not too bad. For the last week I have been testing out VMWare Fusion on Leopard.

Amazingly it is pretty stable. The only real gripe I have is Unity mode. This seems to be the most unstable point of VMWare Fusion on Leopard.

At the moment I am running in Fullscreen mode within VMWare Fusion and the new spaces feature works very well. I can hit F8 to zoom out to see all the spaces and it renders the VMWare desktop just fine. Here are the points in which I found VMWare Fusion most unstable

  • Running in Unity Mode

This seems to be the most unstable of all the modes. In case you don’t know, Fusion offers 3 different modes of running. Single window, Full screen and Unity. Basically what Unity does is make the virtual machine desktop transparent which makes it seem as if the Windows program is running natively within OSX.

  • Waking VMWare session from sleep mode

I’m not sure if this is a VMWare problem or a Leopard problem. Sometimes after putting the laptop in sleep mode and then waking it up, vmware seems to hang. Not every time, just every once in awhile. Out of five times I attempted to do this, it hung twice. Not too bad.

  • Running multiple Applications

This seems to be one of the more unstable areas of combining Leopard with VMWare. I think if I had more memory to throw at the problem this problem would go away and I suspect that before Leopard comes out both VMWare and Apple would have solved this issue.

That being said, I have been happy with Leopard and am eagerly awaiting the release coming in the next few months. I am ready to abandon windows completely and work exclusively within OSX. The one and only thing still holding me to Windows is Visual Studio, hence why I started to look at Fusion. Good Stuff!

Welcome!

Welcome to the new blog.Over the next couple of weeks I will continue to be doing informative posts about agile, ddd, castle project and other various development topics.I am expecting a new baby boy in the next couple of weeks. His name is Aidan Allen Chambers and his due date is October 11th. Mom can’t wait to be done with the pregnancy. She is nearly drained of life =)Check out the Flickr pics on the bottom right to see some sonogram photos of Aidan. Cheers!