Professional Programmer Notes

or just call this my soapbox

Code Camp Report

with 2 comments

Name: Chicago Code Camp 2010
Where: Illinois Institute of Technology, Chicago, IL
When: May 1, 2010

My Talk

 

I had an opportunity to present at the Chicago Code Camp. My talk was titled, “Seven Habits of Highly Effective ASP.NET MVC Developers.” It is a long title derived from Stephen Covey’s best selling business book, “Seven Habits of Highly Effective People.”

Similarly, the content of my presentation was derived from the habits and principles that Stephen Covey introduces in his book. The difference is the technical spin that I apply to make these principles relate to the job of developing web applications using Microsoft’s ASP.NET MVC framework. I presented habits that we as developers should adopt in order to effectively begin and maintain our web applications over their respective lifecycle.

Surprisingly, this topic was very popular at the Chicago Code Camp. Initially, I was expected to present in a room that seated about thirty people. However, the room quickly exceeded capacity and I was asked to present in a larger room. The seats in the larger room were quickly taken, and some attendees sat along a window sill in the back of the room.

At the conclusion of the talk, I had some great discussions with a few people with questions ranging from organizational concerns to technical implementation. I was able to answer many of the questions or offer relevant suggestions.

Overall, I felt like the presentation was well received. The initial feedback available on Twitter gave me the feeling that the experience was a pleasant one. Here are some example tweets that I read shortly after the talk:

“Learned a lot from your MVC talk. Hopefully you can go to CVNUG code camp some day”@cksanjose

“Highly Effective Habits of MVC Developers by Curtis Mitchell. This guy is crazy awesome”@jonathanbaltz

“Liking the MVC presentation. The speaker is really up beat. Keeps you interested.”@itsff

Talks I attended

 

Ioke ( by Ola Bini )

Ioke is an experimental language written by the presenter of this talk. It runs atop the Java Virtual Machine and it is inspired by many of the features in languages like Ruby and Lisp. It is a very impressive programming language. However, it is not intended for use in production applications. Ola Bini did mention he is working on a newer programming language. I am hoping the new language implements many of the features in Ioke, and become a viable language to use in production scenarios.

Limelight ( by Micah Martin )

Limelight is a framework written and actively maintained by Micah Martin’s company, 8th Light Incorporated. The framework allows developers to create desktop applications in the popular Ruby scripting language. In addition, the development experience is simple yet powerful. Limelight employs a web development-like paradigm. And, it makes deployment of these applications over the web very easy.

Micah also explained that Limelight applications should be considered rich internet applications (RIA) as well. He demonstrated Limelight links – a hyperlink that can be used to download and launch Limelight applications from a server. This eases versioning and maintenance of desktop applications because the deployed software is hosted on a server like a web application. And, users automatically get the most recent version when they launch the application from a web-enabled computer.

Making the web “F#”unctional w/BistroMVC ( by Scott Parker )

This talk focused on two things of interest to me: Microsoft’s newest .NET language, F#, and an alternative Model-View-Controller web framework, BistroMVC. The presenter was entertaining and very comfortable throughout the talk. He did a good job at targeting the “F# newbies” like myself and many others in attendance. The talk included a good introduction to F#. Unfortunately, due to time constraints, we weren’t able to get a good introduction to BistroMVC.

However, I learned enough to pique my interest in both technologies. I am going to definitely learn more about F# and do some more investigation into BistroMVC.

Web Testing with Visual Studio 2010 ( by Richard Campbell )

Microsoft released Visual Studio 2010 on April 12th of this year. They have put a lot of work into improving the features related to testing. Richard Campbell gave a very entertaining and educated talk on how to leverage a small portion of these new features to stress test our web applications.

Personally, I have been looking into some of the web testing capabilities of VS2010 from an automated integration test perspective. It was great to learn about and see the stress-testing features.

Richard is the founder of and Product Evangelist of StrangeLoop Networks. His company specializes in optimizing web applications. He demonstrated his expertise in the subject matter and delivered a great presentation on how to use VS2010 to make sure your web application can perform.

Conclusion

 

I am very happy I attended this event. There were approximately 550 registrants and slightly more than 300 attendees. The attendees, presenters, and organizers included notable leaders from the .NET community such as:

  • Scott Seely, co-author of "Effective REST Services via .NET: For .NET Framework 3.5", founder of Friseton, LLC
  • Micah Martin, founder of 8th Light Inc. and co-author of "Agile Principles, Patterns, and Practices in C#"
  • Robert “Uncle Bob” Martin, author of "Clean Code: A handbook of Agile Software Craftsmanship", co-aurthor of "Agile Principles, Patterns, and Practices in C#", and founder of Object Mentor
  • Rocky Lhotka, creator of the widely-used CSLA.NET framework
  • Carl Franklin, co-host of the popular .NET Rocks podcast
  • Richard Campbell, co-host of the popular .NET Rocks podcast

To name a few.

This code camp met my criteria of successful code camps. It was well-organized, supported by a great development community, consisted of diverse technological topics, and concluded with downright awesome giveaways. I hope I have an opportunity to attend future Chicago Code Camps.

Advertisement

Written by curtismitchell

May 3, 2010 at 2:40 pm

Posted in Uncategorized

Two ways to handle unauthorized requests to Ajax actions in ASP.NET MVC 2

leave a comment »

Problem:  I have created a view that posts to an action via Ajax with the expectation that the action will return the requested data or an empty string.  Even better, I would like it to be configurable to return whatever value I see fit.

The problem arises when I decorate the called action with the [Authorize] attribute.  If the request is not authorized and I have a loginUrl configured in my web.config, my ajax request will return the html output of my loginUrl view.  That is undesirable.

Solution #1:  I need to implement a custom ActionFilterAttribute that I can use on the ajax action to handle the request appropriately.  Here is the code for my ActionFilterAttribute:

    public class AjaxAuthorizeAttribute : ActionFilterAttribute
    {
        public string View { get; set; }
        private bool renderView;

        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            if (!filterContext.HttpContext.Request.IsAuthenticated && filterContext.HttpContext.Request.IsAjaxRequest())
            {
                renderView = true;
            }

            base.OnActionExecuting(filterContext);
        }

        public override void OnResultExecuting(ResultExecutingContext filterContext)
        {
            if (renderView)
            {
                filterContext.Result = new ViewResult { ViewName = View };
                filterContext.Result.ExecuteResult(filterContext.Controller.ControllerContext);
                return;
            }

            base.OnResultExecuting(filterContext);
        }
    }

And, here is how I would decorate my ajax action in my controller class:

	[AjaxAuthorize(View="AjaxAuthorizeError")]
public ActionResult AjaxRequest()
{
        return View();
}

That would handle the issue by checking whether the request is authenticated.  If it isn’t authenticated and the request is being submitted via ajax, a specified view will get called.  The content of that view determines what my ajax call will receive back when the request is not authenticated.

Note:  There is no default view page being rendered if one is not passed to the ActionFilterAttribute.  That’s room for improvement.

Solution #2:  I can extend the existing Authorize attribute by inheriting from the AuthorizeAttribute class.  Here is the code that extends the Authorize attribute:

    public class AjaxAuthorizeOverrideAttribute : AuthorizeAttribute
    {
        public string View { get; set; }

        protected override void HandleUnauthorizedRequest(AuthorizationContext filterContext)
        {
            if (!filterContext.HttpContext.Request.IsAjaxRequest())
            {
                base.HandleUnauthorizedRequest(filterContext);
                return;
            }

            filterContext.Result = new ViewResult { ViewName = View };
            filterContext.Result.ExecuteResult(filterContext.Controller.ControllerContext);
        }
    }

Here is the decorator for the ajax action in the controller class:

[AjaxAuthorizeOverride(View="AjaxAuthorizeError")]
public ActionResult AjaxRequest()
{
     return View();
}

Note:  Again, there is no default view page being rendered.

Written by curtismitchell

March 22, 2010 at 4:10 pm

Posted in Uncategorized

Changing the default Virtual Directory/[TARGETVDIR] name in a Visual Studio Setup Project

with 2 comments

While working on a Visual Studio Setup Project for an ASP.NET MVC application, I ran into an interesting dilemma. The installer automatically uses the Title of your setup project as the default virtual directory value. From a user experience standpoint, it can serve as a visual indicator that this "virtual directory" is specifically for the application that you (the user) are installing.

However, it isn’t ideal. See, usually the title of an installer is human readable e.g. "My Application". However, I don’t think user would want their virtual directory to contain spaces since spaces typically get escaped to a hex value, making your site’s address http://someserver/My%20Application. Visual Studio Setup Projects do not offer a straight-forward way of editing this default value, except to edit your title to read "MyApplication".

There are a handful of solutions that have been conceived by various people that include passing command line arguments or using custom dialog windows that set the TARGETVDIR parameter explicitly – to name a couple.

For different reasons, none of the proposed solutions satisfied my dilemma.

So, here is what I did:

I opened the deployment project in notepad++ (a very handy text editor), found the line that says, "VirtualDirectory" = "My Application" and changed it to "VirtualDirectory" = "MyApplication". After saving the file, reloading it in Visual Studio, and building my installers, my dilemma was solved. I hope this is helpful to you as well.

Written by curtismitchell

February 19, 2010 at 12:14 pm

Posted in Uncategorized

Gestalt = Low-Lying Awesome

leave a comment »

Microsoft appears to be betting big on Silverlight.  When the Silverlight 1.0 bits were released in 2007, my initial thoughts were, “Yay, Flash for .NET developers.”  As Microsoft pushed forward with version 2, version 3, and now version 4 of Silverlight, those sarcastic thoughts have subsided to make way for more genuine curiosity.  How did that happen?

Well, for starters, Microsoft delivered real features.  Initially, Silverlight demos were all about media (music and video).  In addition, Microsoft touted the interopability between dynamic languages like vbx, c#, python, ruby, and javascript.  Then, that interopability was sidelined and Silverlight applications started to emerge.  Which was interesting.  In fact, Silverlight 2 had enough features to stir up debates in the enterprise over which RIA technology was best suited for enterprise applications: Flash 8 with Flex or Silverlight 2.   Then, Microsoft played their wildcard.  They made Silverlight play nicely with … ugh … Mac OSX.  Out-of-browser Silverlight applications made me raise my eyebrows for a technology that I had quickly written off as a “fad”.

That might still be the case.  I won’t make a claim either way.  But, Silverlight and RIA are spaces where Microsoft continue to innovate.  Gestalt is a very good example of that last statement.  Gestalt is built atop a foundation consisting of XAML, Silverlight, and dynamic languages.  It enables web developers to script their way to rich internet applications in a way that both Flash and Silverlight seemingly missed. 

With that said, it is difficult to pinpoint exactly what value Gestalt adds, but you feel it when you’re molding some python, ruby, or javascript hackery into a magical Silverlight-powered application that just works.

The technology appears to still be more of a proof-of-concept than a supported product.  But, it makes a strong case for embracing XAML and Silverlight. 

Checkout the website and the samples at http://visitmix.com/labs/gestalt/.

Written by curtismitchell

February 11, 2010 at 9:59 pm

Posted in .net, CSharp, Javascript, web

Tagged with , , , , ,

Should IronRuby be called NSignificant?

with 2 comments

Update:  You’re more than welcome to read my angry rant below.  However, I felt it would be more responsible if I summed up a few points right here at the very beginning:

  1. Dynamic languages are awesome for things like web development, scripting, and embedded customization engines for bigger applications.
  2. IMO, Ruby is more sought after for its web frameworks, scripting/automation (think Rake), and unit testing frameworks than its potential as an embedded language (unlike Python and Lua).
  3. John Lam’s open source Ruby extension, RubyCLR, enabled CRuby to use .NET types pretty effectively.  In other words, I can have a Rails application using .NET code on the server-side if necessary.  Or, I could use rspec to unit test my .NET libraries.  Both could be done while leveraging the existing Ruby implementation and .NET Framework.
  4. When John Lam started work on IronRuby, RubyCLR was left to a community that let it fall by the wayside.  In the meantime, IronRuby has not been nearly as impressive as IronPython.  There, I said it.

Now, feel free to read the original rant below.

 

Harsh, right?  I think so.  But, it is time I voice my concerns about the Microsoft’s adaption of the Ruby language.  My intent is to put it all out there, and see how the community feels.  At the end of the day, my opinion is my own.  However, the voice of the community could cause change – of my opinion or otherwise.

What’s beef?

Let me start by saying that I am a .NET developer.  I have specialized in Microsoft technologies over my eleven year career thus far.  In addition to being a member of our local .NET user group, TriNUG, I am also a member of the local Ruby user group Raleigh.rb.  I do not speak for these organizations, but I wanted to point out my involvement with both technical communities.

In addition, my background is web-heavy with a few years of desktop development in there as well.  That is to say that Rails was my introduction to the Ruby language.  From the perspective of a web developer that dug Javascript before Prototype, JQuery and MooTools, Rails whet my appetite for more Ruby-like development in my paying job.  I was amongst the early .NET developers that thought, “Wow, it would be great if we could use a language like Ruby with the CLR!”

In my excitement, I went out and learned about great projects like RubyCLR, John Lam’s old Ruby/CLR bridge, and Ruby.NET, the ruby compiler started by Queensland University of Technology. 

Both projects had great merit.  The former allows a developer to call .NET assemblies and use .NET types from Ruby (and vice-versa though painful), while the latter aimed to be a full implementation of the Ruby language atop the CLR.

I think those two projects could have adequately fulfilled my dream.  More on that later.

Back to my beef.  My beef is that Microsoft killed at least one of these projects.

First, they brilliantly (sans sarcasm) hired John Lam, the developer of RubyCLR.  That was an excellent decision on Microsoft’s behalf.  Initially, I hoped John Lam would continue his work on RubyCLR or a RubyCLR-like project with Microsoft’s resources.  Unfortunately, that was not in their plans.  Instead, IronRuby was started and RubyCLR died.

Secondly, the Ruby.NET project went seemingly inactive (though Open Source) after IronRuby started gaining steam.  It now seems to be stuck at version 0.9 which was working with Ruby 1.8.2.

My beef is that these are two projects the .NET community needs.  IronRuby will become more necessary as Microsoft convince us of such.  But, IronRuby is seemingly being developed at the expense of two very good projects.

Why RubyCLR and Ruby.NET over IronRuby?

Let’s talk web.  As a web developer, my opinion is that dynamic languages are better suited for the web than static languages.  In fact, I may be alone in this, I assert Classic ASP with ActiveScripting fits the web development paradigm better than ASP.NET (not including MVC).  My assertion is based on the ability to make a change and instantly review it by refreshing the page.  This rapid feedback cycle is key to making web development most productive.

Fans of ASP.NET and static languages could make a strong argument for performance.  Simply put, dynamic languages do not perform as well as static languages.  However, this point is less poignant when talking about the web.  Dynamic languages are “good enough” for web development.  In fact, bottlenecks in web applications are usually discovered at the point of disk i/o or data access. 

Wouldn’t it be great if we could optimize our disk i/o and data access code with a static language, but use a dynamic language like Ruby for the bulk of our web applications?  Well, RubyCLR enabled that!  If we focus on unidirectional communication be Ruby and .NET – that is Ruby code calling .NET assemblies, we’ll see that RubyCLR is the bees knees!  Imagine doing your web development in Rails while being able to call .NET assemblies for things like disk i/o (I can’t imagine replacing Ruby’s ActiveRecord with a .NET ORM).

On the flipside, Ruby.NET was in the process of enabling developers that know and love Ruby to use the .NET Framework and all its libraries in a statically typed manner.  This means, not only can I call .NET assemblies from Ruby, but I could write .NET assemblies in Ruby.  How awesome is that? (don’t answer)

I believe Microsoft’s most underestimated contribution to developing in Ruby will be easing Rails deployment on IIS.  That is the key piece to the puzzle and the metaphoric “milkshake that would bring all the boys to the yard.”

If you don’t have something nice to say…

I’ll end by saying a few good things about IronRuby and Microsoft.  As a developer that uses Microsoft’s technologies, I continue to believe that Microsoft will (a) make mistakes and adjust to correct them or (b) continue to be an agent of change that brings the rest of us into the light.

With that said, IronRuby, IronPython, and the DLR are bringing capabilities to .NET development that either didn’t exist before or were a pain in the neck to implement.  I haven’t really wrapped my head around doing web development with IronRuby, yet.  I hope the experience will be as pleasant as doing web development with Ruby.  But, the ability to add scripting to a desktop application utilizing IronPython or IronRuby is very nice.

Now, it’s your turn

I can go on and on about this topic.  Those that have had this conversation with me in-person can attest to that.  But, I’m really interested in how the community feels.  What’s up?

Written by curtismitchell

December 9, 2009 at 12:06 pm

Posted in .net, Ruby

Tagged with , , , , , ,

Seven Habits of Highly Effective ASP.NET MVC Developers

with one comment

This weekend I had the privilege of presenting two talks at the CMAP Code Camp in Central Maryland.  I gave a talk on the Spark View Engine and a new talk called “Seven Habits of Highly Effective ASP.NET MVC Developers.” 

Here are the slides for the latter talk:

Written by curtismitchell

November 9, 2009 at 11:31 pm

Posted in .net, CSharp

Tagged with , , , , ,

Richmond Code Camp 2009.2

with 2 comments

Wow! What an event!

This weekend, I joined ~400 others for the Richmond Code Camp and a good time was had. As others have noted, the hardest part of the day was choosing which talks to attend due to a schedule full of excellent topics and speakers.

I started off with Justin Etheredge’s talk on Linq Expressions. This was 75 minutes of great slides and polished demos of basic to advanced Linq concepts. I left that talk more educated and less scared of the power of Linq Expressions. Justin has an unbelievable understanding of how Linq works and an amazing ability to convey that to the layman with nothing more than a stock photo of a cat and a VM with Win 7 and VS 2010.

Second, I attended a talk that was missed from Raleigh’s Code Camp two weeks earlier. I went to John Feminella’s talk on Ruby for C# developers. John gave .NET developers a great introduction to the Ruby language using IronRuby (I thought that was brave at this point). To my surprise, John held up his end with great content and examples, and IronRuby held up its end with stability and support for most of the features of Matz Ruby (the original implementation of Ruby).

Next, I decided to checkout Open Spaces. The evening before, I jokingly suggested that the audience would convince Kevin Hazzard to present something on the DLR at Open Spaces since he was not officially presenting. Well, I guess they did! Kevin led a discussion on IronPython and the DLR that included some very nice demos. He also discussed C# 4.0’s new “Dynamic” type and how it actually works. I gained a lot of insight on when and where the DLR and Dynamic Languages on .NET are useful. And, while I love Ruby, IronPython is making the Python language very attractive to me.

Another talk that I was able to attend was by Chris Love. He talked about building quality ASP.NET applications faster. I know Chris to be a very experienced developer. He just completed an updated version of a book I found to be very practical when I was getting into more advanced ASP.NET concepts, ASP.NET 3.5 Website Programming: Problem – Design – Solution. His talk drew off of his experiences building applications and sites for his clients. He talked about architecture as well as development practices. I recommend his talk to anyone doing ASP.NET development that is looking for practical advice on how to manage it all from start to finish.

In the last time slot of the day, I presented Spark, an ASP.NET MVC View Engine, to a great audience. This was essentially the same talk that I gave a couple of weeks earlier at Raleigh’s Code Camp, but I made some modifications for the Richmond crowd. Here are the slides from that talk:

Enjoy!

Written by curtismitchell

October 5, 2009 at 3:04 pm

Posted in .net, CSharp

Tagged with , , , , ,

Slides from Raleigh Code Camp 2009

leave a comment »

This weekend, I had the pleasure of presenting a talk on Spark View Engine at Raleigh Code Camp (#rducc).  It was a well organized event with a schedule full of great topics and presenters.  The Triangle .NET User Group (TriNUG) did a wonderful job at organizing and running the event.  Thanks, TriNUG!

As promised, I am posting the slides that I used in the Spark talk.  Although the true context of the talk is not present on the slides, I hope these are helpful to someone using the Spark View Engine or considering it.

Stay tuned, or subscribe to the rss. I am planning to post a series of short to-the-point screencasts that demonstrate how to practically use Spark in your ASP.NET MVC application.

In the meantime, checkout http://www.dimecasts.net for some great videos on Spark.

Written by curtismitchell

September 21, 2009 at 10:01 am

Rails-like ASP.NET Development Assets

with 2 comments

Written by curtismitchell

May 31, 2009 at 11:12 am

Hello world!

with one comment

Welcome to WordPress.com. This is your first post. Edit or delete it and start blogging!

Written by curtismitchell

May 16, 2009 at 5:37 pm

Posted in Uncategorized