Monday, August 16, 2010

New Gig

Today officially marks my first day at SB Stone. I thought a post was warranted to talk about what we are trying to do and how open source, .net, mobile, all the fancy buzzwords are part of it.

I am the first full time dev in what the company is calling our "interactive" division. SB as a whole really has 4 main markets, staff augmentation, IT services, support and this new interactive group.

So what does interactive mean? Well... really all it means is we want to build a "studio" style dev wing where we do both project work for third party clients, as well as build our own products to market and resell. We're hoping the project works supports the dev time needed for our own things until those become profitable. Also as with anything some will hit and some will miss.

So why did I come over here? Mainly because the new group wants to build a new brand and image for the company, a large part of which will be participating and contributing to the dev and tech community. That means participating at and speaking at conferences, sharing knowledge through blog posts / twitter / user groups, all of it.

From a tech standpoint our group is looking at a mix of .NET and Open Source tools, specifically Ruby on Rails (although we have PHP resources as well.) We're also training up on mobile including iOS and eventually Android so a whole lot of different tools. My role from a marketing perspective is mostly going to be focused on the Rails side though. So hopefully in the near future I'll be going to more ruby conferences and events to talk to people about what we're doing and how Rails is playing in the marketplace.

The thing i'm most excited about though is building out a proper agile dev team. Earlier today we committed to following Kanban via Agile Zen for my first project, and hopefully many more going forward. We're adhering to test driven development, continuous integration and emergent design as well. The only "hot" agile practice we aren't going quite yet is pairing, and only for lack of collocated people (and remote pairing, in my opinion, sucks.)

So that's what I'm up to. If your an independent or even a full timer looking to help us out let me know. We're always looking for contractors to keep available and we'll hopefully be building up more of an in house team in the coming months. Even more importantly if you know of any small businesses looking for rails / php / .net help LET ME KNOW :-)

Wednesday, August 11, 2010

So You Want To Be A .NET Dev

Before I open the flamegates please note this post is a tongue in cheek reply to Kevin Gisi's excellent "So You Want To Be A Ruby Dev". I personally work in both platforms and they each have their pluses and minuses. Kevin's post is both scathingly hilarious and sadly true I hope this rings the same way.

So You Want To Be A .NET Dev

Fantastic, welcome aboard! The .NET community is a somewhat fractured but enormous place to be. Some of us follow test-driven development (and a library or two might have tests if your lucky), configuration over convention and the Alt.NET guys have heard of agile methodologies. We have documentation tools like... comments.... and xml comments... which means that if the devs who wrote the library your working on have read Code Complete it might not be a bunch of spaghetti code. So leave your hippy language and development stack, and come join the corporate monolith - maintaining job security by using only the best tools from Microsoft (tm).

So, let's get you started! You'll want to grab a copy of the .NET Framework. Which Framework? Well seeing as how your probably going to be building new apps and maintaining apps from 2001 you should probably just install all of them. 1.1, 2.0, 3.5 and 4.0 are all available to download on microsoft.com There's also 1.0 but we don't speak of that, and mono but no one uses that. What's the difference? Well mostly features, we have a LOT of people to support after all so each new version shoehorns more and more stuff in until we can be everything for everyone. We wouldn't want to have to rely on the community to add new things... who would support it? Don't worry you can install all of them at the same time, they play nice, but I hope you have a nice big hard drive on your PC.

Oh, you're running OSX? Hmm... well, you could try install Windows? No.. well how about VMWare or Parallels. You know those virtualization products that make your computer work like Windows. IDE? Well that one's easy you're going to need Visual Studio, but which one? Well you could install Visual Studio 2010. With that you'll be able to maintain all those .NET 2.0 - 4.0 applications, but you're also going to need Visual Studio 2003 for those old pesky 1.1 "legacy" apps. That said you better hope your whole team is on 2010 otherwise your project files will get hosed and no one will be able to open your solution. What's a project or solution? Well let's talk about that later OK? Oh and you're going to want to buy Resharper, seriously all the best .NET people use it. It adds all the stuff to Visual Studio 2010 that Microsoft will "borrow" and add for 2012. None of us really use Macs...

Ready to get started? Alrighty, well which framework do you want to use? The two big web ones are Webforms and MVC. Webforms is typically used in huge applications for massive corporations that don't know any better. It has a great designer and you can build your entire high maintenance app without writing a single line of code, isn't that awesome? MVC is our newest pet project that all the big wigs in the "community" swear by. Its a distinctly Microsoft invention, you see they broke apart data access, application logic and view rendering and introduced unit testing. It's revolutionary, we didn't borrow the concept or project layout from anyone especially not those ruby on rails blokes. For windows client dev you can use WPF or Winforms but you should really use WPF. Sure it still feels like beta software after two major revisions, but its new and shiny and we promise not to depreciate it in a week in favor of something new. Speaking of something new there's also silverlight which is kinda like webforms and kinda like wpf and kinda like flash.

OK next up is our package management app. Hahahaha just kidding we don't have one. First off why would you ever want to use a tool not made by Microsoft? If you MUST there's lots of excellent control libraries our partners like DevExpress and Telerik have built, their sales staff would be happy to help you configure them. Sometimes different versions even play nice together. We have a really nice Word doc for you to read that explains all the dependencies you need to install, by next week you should be up and running.

Oh, by the way a lot of those third party libraries are now designed for .NET 4, but don't worry you can still use the old versions, if you can find them.

As far as database persistence goes well you'll be using SQL Server for sure. Best get that checkbook back out. Oh you mean code wise, well there's Datasets, Linq to SQL (but we already cancelled that), EF1 (but its universally panned) and EF4 CTP (but even our own MVPs admit that's 3 years behind what other communities have.) You could also use NHibernate but that's not built by Microsoft so good luck getting it by your CIO or MVP Architect.

Hmmm authentication? Well you'll probably want to use the built in authentication provider, and its actually pretty good it even supports security roles. Unfortunately if you're in MVC it doesn't really follow database conventions but it'll work.

Last thing, we'll have to set you up in our TFS system. TFS is this great version control tool Microsoft gave us that's light years ahead of their old tool SourceSafe, it only screws up a merge or loses information occasionally. You need to work offline? Well.. you CAN but you'll be prompted a few times to reconnect and sometimes your code won't merge back in to the server right. It's 2010 when would you not have an internet connection? Also just to limit those pesky merges we've turned on locking checkouts, we wouldn't want people working on the same file, that would be chaos.

Anyway welcome to the team, I'll swing by in a week and see if you've gotten anything done.

Tuesday, July 20, 2010

GiveCamp 2010

This past weekend I had the opportunity to be part of something the likes of which I had not yet seen in the Cleveland area. From Friday until Sunday the folks at Lean Dog Software in collaboration with a handful of organizers and sponsors hosted Cleveland's first GiveCamp.

GiveCamp is a national program that pairs up talented software developers, designers and other technical specialists with local non-profit organizations to complete technical projects that the non-profits would otherwise be unable to afford. This past weekend was the first time Cleveland has hosted one of these events and I think we did our geek brethren in other, much larger, cities proud. When it was all said and done over 20 charities were helped by over 100 volunteer making GiveCamp Cleveland the largest first GiveCamp ever. it wasn't quite the largest of all time, but maybe we'll take that record next year.

For those curious the weekend runs like this.

Friday night we were paired up with our charities and sat down with a sponsor from the charity to talk about their needs and what our goals for the weekend were. In most cases the plan for the weekend was mapped out in advance by a business analyst that was pre-assigned to each team. However, in the case of my charity, The League of Women Voters of the Cleveland Area, we came it knowing virtually nothing. You see the organizers had anticipated having enough people to help roughly 15 charities, but come the week of the event they had enough to add 7 more. The LWV Cleveland was one of the late additions so we had to scope and plan the project on day one instead of in advance.

Our sponsor Sherece was amazing. She understood our limited time frame and was willing to compromise when needed but also did a great job of explaining the purpose of her organization so we could build out the best site for her that the time and resources allowed.

From Friday night through all day Saturday the teams went to work, in most cases this meant building out and customizing a Wordpress installation for each charity. Something like 15 of the teams used Wordpress which is really a testament to the product and how flexible it is.

Throughout the weekend stand-ups were held to make sure the teams were on track. Also breakfast lunch and dinner were provided both Saturday and Sunday.

Sunday evening we trained out charities, presented the final projects and handed over the keys so to speak. The charities all seemed quite grateful for the work that was done, but in reality it was the volunteers who seemed most upbeat. I think I speak for all of us when I say we had an absolute blast using our abilities and skills in a way that we very rarely get to. I told some friends in advance of this weekend that I don't know how to build a house, but I know how to build a website, so getting a chance to do that for a great organization like the LWV was not only fun but an honor.

Just in case anyone is curious the site we built can be found at http://www.lwvdev.com. We had some issues connecting with their hosting provider so itll be switched over to their main site, lwvcef.org in the next week or so.

Some thanks to hand out. First off to all of the organizers especially Mark Schumann who acted as MC and leader of the organizers, Andrew Craze who served as the developer lead and Jon Stahl who's company Lean Dog hosted the event on their amazing workspace (the old Hornblowers boat on lake erie.) Also thanks to the IEEE for acting as a non-profit sponsor of the event and Burke Lakefront Airport for offering up the entire terminal to be used by the campers when the number of volunteers overflowed the boat.

On a personal note I moved to Cleveland Ohio 5 years ago because of a job offer after college. When you think of Cleveland you don't really expect to find a vibrant and exciting community of software developers and tech enthusiasts. This isn't Silicon Valley or Boston or Austin. Let me just say, if you believe that like I did you couldn't be more wrong. Over 100 people showed up this weekend from dozens of companies all over Northeast Ohio. There was a range of expertise that ranged from SQL to .NET and Ruby, Coldfusion, PHP you name it and it was represented. This is a great city to live in, with great people and one hell of a technical community, and that friends is why I'm #happyincle.

Anyway Thanks again to all those involved and I can't wait to do it all again next year.

Friday, June 18, 2010

RCov w/ RSpec-2

So I've spend the last couple weeks updating an old Rails application to Rails 3 and RSpec 2, both of which are currently still in beta.

Early on I noticed that the new rspec doesn't quite support rake spec:rcov yet. The new core framework has the rcov flag but there's no default rake task. RSpec-rails also removed the spec.rake task from your rails project and centralized it into your gem install, which confused me to no end. So in case anyone else wants to run rcov on your code I thought I might post what I did to make rake spec:rcov work again.

First a couple prereqs. I'm using an RVM install of all of this with ruby 1.8.7 (only because 1.9.1 gave me problems w/ rails 3) so in the steps below replace the paths I give with the path to your gem installation folder and you should be good.

1) Open ~/.rvm/rubies//lib/ruby/gems//gems/rspec-rails-2.XXXXX/lib/rspec/rails/tasks/rspec.task in your favorite editor.

2) Add this rake task

desc "Run all specs with rcov"
RSpec::Core::RakeTask.new(:rcov => spec_prereq) do |t|
t.rcov = true
end

That's it. Pretty simple.

A caveat. Right now this runs ALL of your specs in both your rvm ruby folder and your project. I haven't a clue why, hopefully someone smarter than I will comment. That means rcov take a while and when its done its cludgy. If someone does help me out I'll post an update, in the meantime this works.

Wednesday, March 31, 2010

Unit Testing Role Based Security w/ ASP.Net MVC

I recently started working on a little project management demo project in ASP.Net MVC. As part of that I wanted to make sure I unit tested as much as possible so that it could act as a good example of how to do things for other people in the future.

I ran into a bit of a snag when trying to verify that the right security roles are required on my actions. I found out from a few blog posts that ASP.Net follows the .Net 2.0 membership and role provider model, and that you can simple decorate a controller or action with [Authorized] attributes to restrict access. Pretty cool and really simple unfortunately not very testable. When you unit test actions in MVC you call the method directly from the test, bypassing the routing engine where these authorization checks are made.

Fortunately I found Paul Brown's excellent post on how to test that you have applied the right roles. I liked what he did but it was a bit to case specific for me so I made it a bit more generic. Here's what I came up with:

I took Paul's code and turned it into a series of three controller extension methods which verify if the entire controller requires authorization, a particular method requires authorization or if a particular method requires a given role (i have not yet written the obvious 4th case - an entire controller requires a given role but it should be trivial.)
public static class ControllerExtensions 
{
     public static bool RequiresAuthorization(this Controller controller)
     {
           MemberInfo memberInfo = controller.GetType();
           var attributes = memberInfo.GetCustomAttributes(typeof(AuthorizeAttribute), true);              
           return attributes != null && attributes.Length == 1;
     }
     
     public static bool ActionRequiresAuthorization<T>(this Controller controller, Expression<Action<T>> expression)
     {
           var member = expression.Body as MethodCallExpression;
           if (member != null)
           {
                 var methodInfo = member.Method;
                 if (methodInfo != null)
                 {
                       var attributes = methodInfo.GetCustomAttributes(typeof(AuthorizeAttribute), true);
                       return attributes != null && attributes.Length == 1;
                 }
           }
           return false;
      }
 
      public static bool ActionRequiresRole<T>(this Controller controller, Expression<Action<T>> expression, string role)
      {
            var member = expression.Body as MethodCallExpression;
            if (member != null)
            {
                 var methodInfo = member.Method;
                 if (methodInfo != null)
                 {
                       var attributes = methodInfo.GetCustomAttributes(typeof(AuthorizeAttribute), true);
                       var authorizeAttribute = (AuthorizeAttribute)attributes[0];
                       return authorizeAttribute.Roles.Contains(role);
                 }
            }
            return false;
       }
}


Here is an example test for Requires Authorization: (using NUnit)
[Test]
public void Should_require_authorized_user_for_all_actions()
{
     var controller = new ProjectController(null);             
     Assert.That(controller.RequiresAuthorization());
}


And a sample for ActionRequiresRole
[Test]
public void Should_require_admin_to_add_a_bug()
{
     var controller = new BugController(null);
     Assert.That(controller.ActionRequiresRole<BugController>(x=>x.Add(), "Admin"));       
}



EDIT: John suggested changing the extension methods into lambda actions so that they would be strongly typed. I agreed so this has been updated accordingly.

Friday, March 19, 2010

Forcing Visual Studio to run as an Administrator

This superuser post explains how you can force visual studio (or any application) run as an administrator. This is helpful for Windows Vista and Win7 users who have issues with IIS when running Visual Studio as a non-admin.

http://superuser.com/questions/23462/how-to-always-launch-vs-net-as-administrator

Just in case the link dies here's the answer:

To ensure visual studio and any file opened w/ visual studio (i.e. double clicking on a solution file) always opens VS as an admin (from Vdex):


Got to the actual deven.exe in "C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\", right click on devenv.exe, properties, compatibility and tick "run as administrator"


To set a particular shortcut to always open as an administrator (From Jared Harley):



  • Right-click on the shortcut (this works even in the Start Menu)

  • Select "Properties"

  • Select the "Compatibility" tab

  • Click the "Change settings for all users" button at the bottom

  • Enter the administrative username/password

  • In the new window, select "Run this program as an administrator"

  • Click OK

  • Click OK


Wednesday, March 10, 2010

Making the Switch: VMWare vs Parallels

A few years back when I first make the switch from Windows XP to OSX 10.4 (at the time) as my default platform of choice I knew there would be a few challenges. Mainly I knew that being a .NET developer there were a number of applications I really needed to run that didn't exist on the OSX side of the equation, specifically the Microsoft Development Stack.

At the time that Apple switched from the PowerPC platform to Intel a competition sprung up to see who could be the first person to get a copy of Windows running on Apple hardware. Eventually a bunch of hackers solved that problem. Shortly thereafter Apple released Boot Camp, it's semi-official (Beta) take on running windows on a Mac. Then Parallels threw their hat in the ring with a virtualization product that in no simple terms kicked ass. Finally a few months later veteran virtualization powerhouse VMWare brought out VMWare Fusion to compete with Parallels.

Today the offerings from VMWare and Parallels are very similar. They both offer Windows 7 support, a coherance / unity mode which breaks windows applications out of the windows desktop and several other bells and whistles you would expect from a fully featured product designed to help switchers.

One of the questions I get asked frequently by people looking to switch is which one do I recommend. The truth is I recommend both but I use VMWare Fusion.

Ultimately there were two reasons, at the time, that I chose Fusion:

1) At the time (and still now I believe) it managed RAM better than Parallels.

Specifically it didn't pre-allocate all of your allotted memory up front. What that means is when you set up a virtual machine you tell it how much system memory it can use. On my 4GB machine i allocate 2G to my VM.With Parallels when you allocated 2 gigs the virtual OS takes all 2 gigs up front and then the virtual OS manages it. Basically its like your running 2 machines and each has 2 gigs of ram.With VMWare if you allocate 2gigs it will give the virtual OS as much memory as it needs at any given point in time UP TO 2gb. After that it begins swapping to disc like any normal OS would. So if your not doing much in your VM OSX could retain 3gigs to use as it sees fit up until your VM needs that extra gig.

This comes in handy when your doing a simple windows task like testing an application in IE or opening word to work on a document. Usually windows wont need all of the memory you give over to it leaving iTunes and all your OSX apps free to eat up that space.

2) I work for a company who uses VMWare in our server infrastructure. We run VMWare ESX servers which means we have a number of VMWare formatted VMs. Fusion is able to open and run many of these VMs which makes life easier if I want to copy over an image of a particular server setup. Really this is the reason I broke out the credit card one day and bought Fusion. But if i were starting from scratch all over again I would go with Fusion from the get go because of number 1.

That's pretty much it, in every other way the two products are competitive and to be honest I'm not even sure if number 1 is relevant anymore (by all means if its not please leave a comment.)

It's worth noting there is a third option, Sun's VirtualBox, which I have not personally tried. I have heard good reviews but I've also head it lags behind the commercial products in feature set so if you can buy one of the commercial ones you should.