Archive for the '.net' Category


An Idea: Scripted C# for ASP.NET Development 0

I work as a .NET consultant in New York, most often with ASP.NET and SharePoint so the frustration expressed here comes directly from experience. Outside of work I like to dabble with lots of other neat tools an one thing I’ve really gotten used to in web development is NOT having to compile when I make simple changes to my app. PHP, Python, and Ruby all make this very easy. And if your project is pretty small, using ASP.NET doesn’t add too much over head. But that doesn’t last for long

The problem is when the project gets large or you group a lot of classes/code into a single DLL and THEN have to compile them to see your changes. Even failing to mention the need to get IIS to clear its cache before anyone can see a change from the code, there’s a wait time of 30 seconds to a minute depending on the size of the dll.

I hear you say, “30 seconds isn’t that big of a deal”, but doing a little math shows you that 30 seconds compounded maybe a hundred times (conservative) a day over the course of a week or two and you end up with hours wasted. All that time spent just waiting, doing nothing. What’s worse is that you lose your focus on what you’re testing. You’re continuity of thought is crushed under the weight of compiling your 1 liner alteration.

So, lots of whining without many suggestions. Well here it is: http://tirania.org/blog/archive/2008/Sep-29.html. That’s the mono project’s leader Miguel De Icaza’s blog and he talks about the csharp interactive shell that came out of the mono project recently.

What I would like to see is a development mode for IIS that deals with C# in a script like fashion, using something like the aforementioned link so that we can stop compiling things while were working on them, and still get the nice quick execution we’ve come to expect from compiled/cached .NET assemblies in production. Faster iterations means more efficiency and less brain breaks when developing web applications.

Right, the page might load slower when you fire up your server, but I’m tired of recompiling some huge thick dll every time I make an extremely small change.

PostSharp: filters for C# 0

Aspect oriented programming is a relatively new paradigm but it’s existence in the the .NET world was brand new to me when one of my clients/bosses Kris Kniaz stopped by my desk and told me about it. He pointed me at their site and at first it was a little vague what the software was trying to accomplish but about 2 minutes into reading it over I realized I was looking at C# filtering!

So what do I mean by c# filtering? In Rails, when you want to run a specific method before, after, around another method you use a filter. This makes for some very DRY code when you throw in the ability to white list and black list methods from the filters.

The obvious and oft-cited example in Rails is authentication:

For the destroy method in SomeController, before its executed, authenticate will run, which might makes sense! Note that the :only option can be replaced with :except option to black list or it can be left off all together.

So in the case of PostSharp you would end up with something like this:

Its not quite as DRY as The Rails Way, but its a pretty awesome tool to have in your kit!

Obviously this has some draw backs, in the same way it does with Rails. If your programmers aren’t smart they are going to overlooking a lot of possible code executing when they see those attributes. In general it can just lead to a lot of unintended branch logic, but good documentation/communication among your team, and using this powerful tool in the right scenario could result in some really clean solutions.

I encourage you to take a look at the PostSharp demo video, and comment if you’ve used it before!

ASP.NET on Rails 1

A friend at work alerted me to the new MVC framework that’s in beta for .NET and I was really excited to see what they had come up with. He showed me some code samples and I immediately recognized some very Rails-ish stuff in there. So lets take a look and see what they have going on because so far its looking pretty awesome.

Disclaimer: Obviously Rails isn’t the worlds first MVC implementation, its just a really nice one and I think MS has definitely taken a few cues here.

Directory Structure (courtesy of Scott Guthrie’s blog):

A logical directory structure for an MVC app to be sure. I would kill to have this on some of my current projects where locating things you are looking for is a nightmare. It may not be Rails’s “Convention Over Configuration” but its a nice step in the right direction from my perspective.

Routing:

Routes! Routes! I loves me some Routes! Making your web apps RESTful has many advantages (see here, and here for some examples) and in any case the flexibility that custom routes provides is enormous. Think of how much nicer SharePoint url’s could be :), and, as ScottGu mentions, it helps in optimizing SEO.

Backward Compatibility:

If you were a good little software architect/engineer and built decoupled user controls and master pages there’s no reason why you can’t re-use that code again on your new shiny MVC pages!

Plug and Play:

Again from Scott’s blog, “… it’s highly extensible and pluggable…”, which is music to my ears. One of the great things about Rails, and one of the reasons I really believe in it as a long term technology is that while it is opinionated software, you can swap out its main pieces like ActiveRecord < => Datamapper . This means that if you think Datamapper will serve your project better then you’re free to use it, and anyone with a better idea for an ORM can jump right in and write one. If ASP.NET MVC can live up to this not only will it be a better framework for it, but I wouldn’t be surprised to see a bunch of custom pieces from hackers who want something better or just different.

Looking forward:

If you are a web developer and you’re main expertise is with .NET then this is something to be very excited about. Not just as a tool for building websites but also because MS can recognize a better way to get things done for developer’s and they are willing to throw money at making our lives easier. Good stuff all around!

XMLViewer Silverlight Control 0

So instead of rolling happenings into a gem, I got bored and decided to hack together some Silverlight and see what it was like. I’ve often said that C# is awesome for development, but that ASP.NET is not the best. The event driven model makes me want to gouge my eyes out (Page_Load, After_Load, Post_Pre_After_Load), but that’s another blog post that I’ve been meaning to write.

Anyhow! I wanted to try Silverlight out because your basically building a GUI app, which .NET is great for, but deploying it with the browser. Cross Platform no less! So please try it out, post what you think, and I’ll get the code up on codeplex or something tomorrow if I can find the time.

XMLViewer Silverlight Control

[UPDATE] Source available at codeplex.

Microsoft and Devs: marriage counseling needed 2

Since I started posting on this blog again I have been thinking a lot about Windows 7 and how MS could make it developer friendly. A lot of these ideas have come from discussions with colleagues (I work for a Microsoft consulting firm) and also from articles I’ve read that I agree with.

There are two or three main problems with how Microsoft treats its development community that I take issue with. I’ll decide whether its two or three as this post continues but the point is: Good developer’s want access to the best tools (ide & api), good developer’s make good applications (elegant inside and out), and good applications make a good platform.

1. Cost of entry

This probably doesn’t need much explanation, but I doesn’t have to be an all or nothing proposition. I don’t think many weekend devs will care about the Business Analysis tools for Visual Studio, but I think the MS development community would explode if they would release the full version of Visual Studio for free. Something simple like, “free developer tools for use with free software.” It would give college students, kids, and virtually anyone who wants to tinker with software a reason to look at the Windows platform. As it is right now, the cost is prohibitive at 250 for Standard Edition and 690 for Professional Edition.

Good devs are born from the desire to program for fun, but if you make it so the only people with access to your tools are people working at large corporations, its no longer fun its work.

2. API/Widget availability

Windows 7 is seeing the release of the “Ribbon” to developers. Currently you have to license it from Microsoft, which I didn’t even know was possible until I saw a quick presentation from Knowledge Lake at the NY Sharepoint User’s Group about how they had to do just that.

This also goes back to an article I read on Arstechnica where Peter Bright points out that the UI widgets aren’t released/standardized for the Windows platform. Not only does this mean we don’t get to use the ribbon but it also means that Windows turns into a hodgepodge.

I’m not quite sure what drives this mentality but I would like access to everything that I can get my hands on to make my apps as nice as possible. Microsoft can only benefit from awesome third party applications.

3. The community

I run a SharePoint Developer’s user group. The people who show up are really great, and I’ve had some awesome talks with guys like Paul Galvin, Michael Lotter, and Bob Fox about community development and software development.

But the feeling around these groups is just not as enthusiastic as I’ve seen elsewhere and I think its based on the simple fact that NONE of the people who show up hack in their spare time. They come for their professional betterment, not for fun, and it shows. The broader view of .NET is worse still. With the exception of the folks who work on the unadulterated awesomeness that is The Mono Project, there are very few in the community that can match the enthusiasm of the people that work on something like Rails/Gnome/KDE/etc.

This is a much tougher issue to address since a lot of the problem may stem from Microsoft’s image and where they spend their time/money. Lord knows they have plenty of the last to hold hackfests, competitions, and other community events geared toward bringing people together who are excited about the technology. It needs to be about developing for fun, instead of developing for your boss.


The great hope

If MS started to work some of these angles I think we could start to see the same vibrant open source development community around .NET apps that you see now with OS X and Cocoa. Oh, and give me a real command line too :D.

I welcome comments, and I hope that bit about the community wasn’t too harsh, but .NET is pretty awesome and everyone could benefit from a few small changes.

SharePoint Site permissions STSADM extension 0

For the SharePoint developer’s group I run in NYC I created a quick STSADM extension that outputs all of site, subsite, list, and list item permissions for a given SharePoint site.

By piping this output into a file you can create a baseline to compare to at a later date with something like winmerge. Thus you have a simply way to verify your site permissions should you need to. The idea was to illustrate how easy it is to create extension for STSADM, but I ended up with a useful utility in the process.

Code here.

Also, if you look at the code you’ll see that there is in fact an interface that all of the “Permissionable” objects implement (ISecurableObject) and as a result the methods for retrieving their Roles and Rights can be generic. Contrary to my earlier post here.

If you have any questions or are interested in attending the next meeting of the New York SharePoint Developer’s Group send me an email at john.bender at hensongroup.com.

Enjoy!