Archive for the 'Software Development' Category

22
Jan

The Current State of the Web: Why It’s Pointless to Debate Which Language, Framework or Architecture is the Best

I’d like to make it clear beforehand that the following novel is fully my opinion and not that of my employer.

Whenever I hear a developer address themselves as a “C# developer” or a “Ruby developer” or an “[Insert programming language here] developer” I really can’t help but cringe. Why? Because as an industry, we should be long past the days where you align yourself to a specific programming language. Now, I’m certainly not saying you shouldn’t pick favorites (that’s just human nature), or even lean towards one most of the time (I currently do ~90% C# development), but at the end of the day, being a great developer means learning core fundamentals which can be applied to any language. If you have a solid grasp of object-orientation, functional programming tenets, the benefits of dynamic programming, and so on, you could seamlessly pick up a new programming language that fit one of those paradigms. Most of the time, languages share ideas between each other, so keeping a keen eye to the languages landscape can also help promote fresh concepts regardless which one you’re currently using.

A better question to ask could be: which language paradigm do you prefer? Many developers are very passionate about dynamic programming languages, and so having to use a statically-typed language might feel constraining to them. But, even that debate is getting blurry with languages offering strong type-inference (e.g. F# or Scala) that can get a statically-typed language pretty close to providing a “dynamic” experience. The addition of LINQ into .NET 3.5 also proved that languages that aren’t functional in nature (e.g. C# and VB) can have a strong functional offering. Things like this lead us to believe that the best question to ask here would be: which language paradigms (note the plurality) do you prefer? Single-paradigm languages are a thing of the past, and developers have an even better opportunity to be productive by using a language that amalgamates the paradigms they prefer in a way that is as close to their preference as possible (no language is without its problems).

That said, I’m also not promoting “polyglot programming” here (which I think is mostly a load of crap). What I am saying is that it’s a waste of time to get caught up into a single programming language or even a single paradigm, when that would only be doing yourself a disservice. This is why I also don’t think that a Java vs. Clojure vs. Scala vs. F# vs. Whatever makes any sense either. Sure, each language is going to have tangible benefits and reasons you could argue that it’s better than another, but “better” becomes largely subjective based on your individual scenario and perspective.

For instance, I personally love Clojure and think it’s JVM interop is just beautiful, but would I recommend it to someone who is familiar with Java and is looking for a functional language? No, because the learning curve is too drastic (unless they’re already a Lisp nerd). Scala is just as powerful and provides a substantially lower barrier of entry for someone coming from Java. And it’s type-inference provides plenty of powerful scenarios that make up for it being a statically-typed language. But even that decision is based on my own perspective. Point being: I believe in being prescriptive, but unfortunately you need to do your own research and make your own decision because ultimately the only deciding factor is your own personal situation/preference.

Languages –> Web Frameworks

What does any of that have to do with the current state of the web? Everything. Just like programming languages, there was a time where it was common for developers to align themselves to a specific web framework. If you address yourself as an “Rails developer” or an “ASP.NET developer” or an “[Insert web framework here] developer” you’re doing yourself a disservice. Why? For the exact same reasons mentioned above. I consider myself a developer first and a web developer second. I like to think that I’m a student of all the cross-cutting concepts that make up what it means to develop for the web. Those skills can then easily translate to any framework (and language) you pick.

The real questions to ask isn’t which framework is better but which attributes of a web framework you prefer and make you more productive. Do you like component-driven development (e.g. WebForms, Wicket)? Are you more efficient using an MVC architecture (e.g. Rails, ASP.NET MVC)? Do you fancy a more “light-weight” HTTP framework (e.g. Sinatra, Compojure)? Going further, even those questions have additional sub-questions. There is no “one-size fits all” approach to MVC frameworks for instance, and in some cases the expressiveness of a framework is dependent on a specific language, so you need to pick the one that ultimately suits you best.

Just like languages, some web platforms allow you to be multi-paradigm. For instance, with ASP.NET, you can easily intermingle MVC and WebForms together into a single application. That may or may not be the right option for you, but it’s an option nonetheless. This further drives the point home that arguing WebForms vs. MVC just doesn’t make any sense. Neither Microsoft nor anyone in the community can or should make that decision for you. Why? Because both are equally as good choices, and can ultimately only be chosen based on what makes you and your team more productive.  Point being: I believe in being prescriptive, but unfortunately you need to do your own research and make your own decision because ultimately the only deciding factor is your own personal situation/preference (does anyone else hear an echo?).

If you’d like someone else to make your decisions for you, that is fine as well. Just be clear that that is what you’re doing if you ask an open ended question like WebForms vs. MVC or Ajax vs. Silverlight, etc.

Web Frameworks –> Architectural Styles

So why does the title of this post claim that debates about which language and/or framework is the best is pointless? Frankly, because that debate isn’t interesting anymore, especially in the context of the web. The current state of the web is such that it is the compelling ideas that are interesting and how they affect the way we live our lives. If you want to become the next Twitter (who doesn’t?), you should be focusing your attention on how to add value to the overall social network of applications. From a technical perspective, what makes those types of applications possible isn’t a single language or framework but rather an architectural decision that can maximize on the potential for success. Out of those decisions, new languages and frameworks will be born, that will be founded on solving actual problems rather than just academic exercises.

Am I claiming that you shouldn’t discuss how to make a language or framework better? Of course not. Any given day of the year you will find me discussing everything from MongoDB to Grails to OData and so on. Discussion is absolutely necessary, and it is the continual engagement with the different communities that keep us sharp as developers. But, MongoDB as a product isn’t itself interesting. When it becomes interesting is when MongoDB proves to be a great option for enabling a compelling idea. Hence, talking and debating over whether MongoDB is better than CloudDB or SQL Server is pointless outside of the context of actually creating something meaningful.

When we raise the level of conversation from frameworks and languages to architectural styles, does the debate over which is best become any better? Not really. If we’re talking strictly about web applications, there any number of choices here. RIA (e.g. Silverlight, Flash, JavaFx) vs. Server-centric (e.g. ASP.NET WebForms, Struts 2) vs. “pure” Ajax vs. some hybrid approach vs. Whatever is just as boring a discussion to have as languages and frameworks. Why? Because there is no right answer. The point being is exactly the same for architectural decisions as I’ve already stated twice. The best thing we can do as developers is strive to stay as relevant as possible in all areas of our industry. Am I saying you should become a jack of all trades and a master of none? Certainly not, but there is a healthy balance between betting your career on a specific technology and positioning yourself to move forward with the industry as a whole. Let’s take a look at Twitter, and see how they’ve done this beautifully.

Twitter Case Study

If I was to ask you what makes Twitter so successful from a technical perspective, what would you say? Would you talk about its use of Scala for the backend or Rails for the front-end? What about its extensive use of memcached and their rather genius caching strategy? While all of that definitely peaks my nerdometer, it doesn’t have anything to do with why they’re successful. I’d argue that what makes them successful is also what makes the debate over what language, framework, or UI technology the best is pointless: their API.

Let me ask two other questions here:

  1. Is Twitter a web site? A web application? A web service?
  2. What is your favorite Twitter client? The website? Seesmic? Tweetdeck? Tweety 2?

Answering #1 would depend entirely on how you view Twitter. You could say that it is a web site, and yes www.twitter.com does exist, but I’d call that their “canonical UI”. What I mean by that is that the website is nothing more than the default client that anyone new to Twitter might use. It is the baseline experience that Twitter personally created to make sure that anyone could access their service. Ultimately though, Twitter’s value is wrapped up in their services and ultimately their data (including users and tweets).

The answer to #1 leads directly into #2. Because Twitter isn’t just a website, and because they’re not partial to who uses their data, that allows us to actually choose a favorite client. Even further, we might have a favorite client for different platforms (e.g. Windows Mobiles, iPhone, Android, Mac). Because of the way that Twitter positioned themselves, they’ve enabled every user on every platform to choose the experience they prefer. That’s a very powerful achievement, and is exactly why it no longer makes sense to argue over what UI or web framework is the best. If you want to achieve large success, it isn’t in the client business, it’s in the services and data business. Whoever has the data has the power.

This is also why it doesn’t make sense to ask whether it’s better to use Scala on the JVM for Android or jQuery and ASP.NET or Flash and ActionScript, etc. I don’t know about you but I’d rather come up with a great idea and then make my data portable so that any of those aforementioned experience would be possible. That’s when your reach and social relevance can be truly compelling. This is also the blueprint being employed by just about every startup worth anything (e.g. Foursquare, BlockChalk). Languages, frameworks, and architectural styles are nothing more than tools in our arsenal that can enable us to create our ideas. We’ll continue creating new ones, and there will continue to never be a right answer in any of the categories.

The discussion over services and data opens a whole other can of worms that I’m not going to go into in this post. Maybe another day :)

Have The Conversations

What can you do to contribute to the overall conversation of the web? Be open-minded and be solution-driven. If you need to ask a question about product comparisons, make sure to have some solution context to back it up, so that recommendations can be made based on merit and not pointless debates over which is “better”. Also, be willing to hear people out when they’re talking about some language, framework or style. Good ideas come from all directions, and you can guarantee that what you believe in today will be obsolete tomorrow (not literally, but it almost feels that way sometimes).

Cross-pollinated conferences like CodeMash and MIX are the perfect place for such conversations to occur. When the Ruby folk and Java peeps and .NET group and PHP clan (etc.) get together magic happens. If you see me at one such event, I’d love to chat about what cool stuff you’re doing. Otherwise, if you’re at a conference, talking about cool stuff, hopefully I’ll find you :)

10
Dec

ASP.NET 3.5 Extensions CTP

Tonight marks the long awaited arrival of the ASP.NET 3.5 Extensions CTP. The buzz around this release has been huge for weeks now and the time has finally come for the community to have a chance to play with the actual bits. All those demos you’ve seen, and all that sample code you’ve examined can be put to life at last!

So what all exactly is included in this package? I’m glad you asked:

  1. ASP.NET MVC
  2. ASP.NET Dynamic Data
  3. ASP.NET Silverlight Controls
  4. ASP.NET AJAX History
  5. ADO.NET Entity Framework
  6. ADO.NET Data Services

If all that wasn’t enough, the MVC toolkit is also now available for download. What is the MVC toolkit you ask? It is a collection of additional functionality that enhances the usability/ease-of-use of the MVC framework, including a massive slew of helper methods, and stronger support for marrying the Dynamic Data functionality with the MVC framework. The classes in the toolkit may eventually be merged into the main CTP bits, but for now they are delivered as a separate package.

There have also been new forums created on the ASP.NET forums for the individual features of the ASP.NET 3.5 Extensions. Make sure to post any feedback and/or issues you have when playing with the bits, it will be greatly appreciated.

Now that the public has access to the CTP, you can expect to see tons of articles popping up focusing on its contents. You can rest assured that I will be going crazy with it and posting lots of information. I will make sure to cover the importance and different user stories for each of the CTP’s features.

Also don’t forget about the MVC Contrib project. Now that the ASP.NET 3.5 Extensions CTP has been released you can expect to see lots of activity around the project.

Links:

  1. ASP.NET Extensions 3.5 CTP
  2. MVC Toolkit
  3. Quickstarts
  4. ASP.NET 3.5 Extensions Forum
  5. ASP.NET MVC Forum
  6. ASP.NET Dynamic Data Forum
  7. MVC Contrib

To simply aggregate the existing available material surrounding ASP.NET MVC, here is a list of articles that should get you started:

  1. ASP.NET MVC Part 1
  2. ASP.NET MVC Part 2: Routing
  3. ASP.NET MVC Part 3: ViewData
  4. ASP.NET MVC Part 4: Forms
  5. ASP.NET MVC UI Helpers
  6. ASP.NET MVC: TDD & DI

If you’re more of a visual learner, Scott Hanselman put together an awesome screencast introduction to ASP.NET MVC framework here.

Have fun! And please once again feel free to email me any questions: joncart at microsoft dot com.

Chad Myers just put together an awesome article showing the usage of the script.aculo.us JavaScript library to perform AJAX functionality along with ASP.NET MVC. This post is a perfect example of the flexibility that ASP.NET MVC has and the creativity I think it breeds in developers.

30
Nov

Give It A REST! A WCF Love Story

When WCF was first released we all wallowed in its magnificent glory. It was so chocked full of features it would make any modest girl blush (including yours truly). But despite its voluminous power, some couldn’t help but feel like it was missing something. Something simple but extremely powerful. WCF thought these naysayers were crazy and insisted that not only was he all that, but that he also had a bag of chips.

One evening WCF was lounging at the bar, as he did most nights, and a beautiful little something in the corner caught his eye. She was clean and pretty, and appeared to be very successful and likable. In fact she was surrounded by an entourage of dread lock toting individuals who appeared to worship her like it was some kind of religion. WCF was besides himself in jealously and decided he needed to be a part of this circle of friends. So he walked up to the lady and asked for her name. “I’m REST” she said, “and these are the RESTafarians“. One thing led to another, and long story short, WCF and REST ended up hooking up. Who’s the winner of this match made in heaven? We all are :)

So the question is, how exactly can a developer begin to create RESTful services, or even append this new found functionality to existing ones? Thankfully enough its ridiculously easy (even I can understand it). What I’m going to develop is a service that will report what the currently playing song is in iTunes, which other people could call (for whatever reason). Making it RESTful adds volumes to the ease of use, and leaves the windows of possibilities wide open.

First I’m going to make a simple service contract:

wcf1.JPG

Obviously nothing special is going on here. So how do we make this thing work in a RESTful fashion?

wcf2.JPG

Notice the difference? All we did was salt the GetCurrentTrack method with a new attribute called WebGet. This attribute simply marks a method as being callable via an HTTP GET operation, namely a REST call. There are more properties for the WebGet attribute, which we’ll examine later, but for now suffice it to say that our service contract is now configured for accepting REST requests.

Now let’s create our service implementation:

wcf3.JPG

Once again, nothing special is going on here. The service simply calls a class to retrieve the current iTunes track. I’m not going to go into how I actually determine the playing track in this article, but if you’re curious you can examine the source code.

So now that we’ve got our service completed all we need now is to create our host, which we’ll implement as a console application for this demonstration:

wcf4.JPG

Notice that I’m not creating a ServiceHost but rather a WebServiceHost. This is a new class added in .NET 3.5 that serves the purpose of hosting WCF services that make use of the new HTTP GET/REST functionality. It is basically a wrapper of the ServiceHost that sets some property values so that we don’t have to.

The last peice of this equation is the configuration file:

wcf5.JPG

The only point of interest here is the binding being used. WebHttpBinding is a new binding added in .NET 3.5 specifically for HTTP GET/REST services.

And that’s it. Pretty simple huh? Surprisingly, we’ve only introduced 3 new classes: WebGetAttribute, WebServiceHost, and WebHttpBinding. Everything else is just plain old WCF. So let’s see this thing work. I start up the host and then navigate to “http://localhost:8731/GetCurrentTrack” in my browser:

wcf6.JPG

As you can see I’m currently getting my chill on to some wonderful Joy Wants Eternity. I change tracks and refresh:

wcf7.JPG

So you can see the service works beautifully. A client could easily subscribe to this and parse the XML at will.

Now what if we wanted this service to be exposeable to our fellow JavaScript enthusiasts out there? All we have to do is tweak the service contract:

wcf8.JPG

All we’ve had to introduce is a single enumeration to our arsenal, but the power of this service just went up ten fold. Let’s run the host and hit the service:

wcf9.JPG

With one ridiculously trivial change to our contract we just got JSON serialization absolutely free. Now anyone could easily use their favorite JavaScript library, make a RESTful call to our service, and use the returned object.

The last thing I’ll show in this article is the ability to add a URI template to your RESTful service contract. If you wanted to modify the URL of the service method (to make it prettier for instance) you can easily achieve this using the UriTemplate property of the WebGet attribute:

wcf10.JPG

By doing this, instead of navigating to “http://localhost:8731/GetCurrentTrack”, we can now navigate to “http://localhost:8731/ThisIsSoCool/IKnowRight/GetTrack”. Being able to build flexible, clean URLs for your method can add a lot to your service when needed.

What if we wanted to pass parameters to our RESTful service?

wcf13.JPG

The UriTemplate let’s us easily map method parameters to values from the incoming URL, so I could now call the service at “http://localhost:8731/ThisIsSoCool/IKnowRight/GetTrack/Jonathan” and it would fire the GetCurrentTrack method passing it “Jonathan”. Could it get any sweeter than that? I think not!

So WCF and REST went on to live a life of prosperity and joy, infecting .NET developers around the world with their intuitive coding model and flexible interface. People couldn’t be happier, and it would seem that their union couldn’t have been more timely. Was it your everyday love story? Not quite. What is better than Moonstruck? I’d sure like to think so…

Download the source code for this sample here.

29
Nov

ReSharper Quick Start

One of the few tools a .NET developer absolutely shouldn’t live without is ReSharper (R#), a Visual Studio add-in created by the wonderful people at JetBrains. It surprises me how many people I meet or talk to who either aren’t familiar with it, or haven’t taken the time to try it out. Well for all those people needing a little motivation, tonight I stumbled upon an absolute goldmine in the form of an extensive tutorial that showcases the power of ReSharper and why it truly is so beneficial. Joe White created 31 individual tutorials for individual features that collectively teach the majority of its functionality in this post. Anyone not currently using ReSharper owes it to themselves to spend the 30 minutes (unless you’re a speed reader) it takes to read it. I wish I would have known about this post when it was first made (January of this year), it would have helped me out a lot :)

A 30-day trial of ReSharper can be downloaded here.

If you’re running Visual Studio 2008 you can download a version of ReSharper compatible with it here.

25
Nov

DDD? MDD? WTF?

I got an email earlier today asking me for clarification on the differences between Domain-Driven Design (DDD) and Model-Driven Design, which I was elated to receive since I think that is a great question.

As I was about to formulate an extremely convoluted response touting my DDD prowess (not really) I realized that I bet the founding father of DDD, Eric Evans, has already crossed this bridge, and I was right.

I’ve gotten quite a bit of reception from readers showing interest in DDD patterns as well as general design patterns so I think I’m going to be putting together some material in coming weeks on this.

If anyone has any specific questions around this space they’d like me to cover please feel free to contact me otherwise I’m going to just pick a card out of a hat :)




March 2010
S M T W T F S
« Feb    
 123456
78910111213
14151617181920
21222324252627
28293031  

Categories