Great article on the principles of K-I-S-S. Keep it simple, stupid!!
As an architect, I’ve learned a lot by doing things the hard way. It’s within our nature to be a purist. We love to dot our I’s and cross our T’s. We try to build the pie in the sky “This system is scalable, I can build anything on it!” Is that ever true. I doubt it.
If you are working on a new project, KISS is the way to go. Keep it simple, quick to market, and release often. We try to build systems and guess what we need, but in reality we don’t know, and building a large system for a unknown audience/market, is a big bet. A bet companies are not willing to pay.
When working in a Service Oriented Architecture there are two main problems I get asked a lot about.
Problem
To put some context around these two main questions. Traditionally services are discovered by either searching the source tree or by word of month. Neither of which is a great solution. Services are either lost in thousands of lines of code, or lost in communication.
As for sharing object types across services. By design services are usually developed with in its own domain and shouldn’t share types. But!, in some cases, you might actually have a business need to share certain types. For instance, if you had two services within the same assembly that referenced a single object, when you created two different service references to the services, two objects will be defined under two different namespaces.
Solution
Disco files were created to answer these two very obvious questions. With a disco file, developers can maintain a global list of available services. Every time a new service is created, add the new WSDL URL to the list of services. This list is the single point of reference when creating a Web or Service Reference. Also, since there is only one global reference to all the services, the generated code will generate one namespace and recognized that if there are any shared types across services, it will only generate the type once.
Create the disco file number the vroot of your application. Below is an example disco file.
1 2 3 4 5 | <?xml version="1.0" encoding="utf-8" ?> <discovery xmlns="http://schemas.xmlsoap.org/disco/"> <contractRef ref="http://localhost/ServiceA.svc?wsdl" docRef="ServiceA.svc" xmlns="http://schemas.xmlsoap.org/disco/scl/" /> <contractRef ref="http://localhost/ServiceB.svc?wsdl" docRef="ServiceB.svc" xmlns="http://schemas.xmlsoap.org/disco/scl/" /> </discovery> |
Consuming the disco file is no different:
Extension methods is one of the best things added to .NET. It’s a great way to share code and helper method with other team members. Traditionally developers would create Helper Classes or Utility Classes that can perform specific actions related to an object or domain. The problem with this approach was that there wasn’t an easy way to discover that these helper or utility classes existed other than searching or asking. Now with extension methods, these helper methods that are related to the specific object can be discovered simply with the uses of intellisense. For example if you created an Extension Method on top of System.String, called ReverseString. All you would have to do is type “myString.ReverseString()”. How easy is that!!
In this example, I’ll show you how to use Extension methods to transform one object to another. This is a great way to centralize your transformation code.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ExtensionTest { class Program { static void Main(string[] args) { Butterfly butterfly = new Caterpillar().ToButterfly(); } } public static class Extensions { public static Butterfly ToButterfly(this Caterpillar caterpillar) { return new Butterfly() { Name = caterpillar.Name }; } } public class Caterpillar { public string Name { get; set; } } public class Butterfly { public string Name { get; set; } } } |
As some of you may know, I’ve been doing all my development 100% on a MacBook Pro, running VMware Fusion, running Windows Server 2008. Recently my install of visual studio started acting up (not due to the laptop or VMware) but because of a bad install.
Being the bad developer, I didn’t snapshot my image, so now I’m going through the process of creating a new image. And as I’m going through this process, I’m starting to realize I’m installing less and less on my dev machines.
So here is a list of software I needed:
That’s all I need on a daily basis. The install has a small footprint and runs a lot quicker. I’m starting to believe, setting up multiple VM with only the minimum required software on each machine is the way to go. This allows me to turn on an off VM’s as I need them. The machine can allocate 100% of its dedicated resource when it’s on and free it up once its off.
Here is a great presentation by Scott Hanselman demonstrating MVC 1.0 and how he created NerdDinner.com with it. He talks about the nuts and bolts of MVC, but also talk a bit about how MVC lends itself to support different roles within an engineering organization. Service developers only need to worry about the Service Layer and UI developers only needs to worry about the Presentation Layer. MVC is great at separation of concerns. Sit back and relax, its a long video, but well worth it.
CodePlex Project: http://nerddinner.codeplex.com
Last week I moved my domain from http://www.wadolabs.com/blog to http://blog.wadolabs.com. It was a simple migration as far as my application and data goes. But what about all the links and referring sites? Plus the indexes that Google already had on my site. I didn’t want all my pages to all of the sudden disappear and my visitors to run into a huge 404 error. So I had a simple solution. I created a new application under http://www.wadolabs.com/blog and only added a global.asax file to the application. On the Application_BeginRequest() method, I added the following lines of code.
1 2 3 4 5 6 7 | protected void Application_BeginRequest(object sender, EventArgs e) { Response.Clear(); Response.Status = "301 Moved Permanently"; Response.AddHeader("Location", "http://blog.wadolabs.com"); Response.End(); } |
This redirects your site via a 301 HTTP response code to the your new site. In my case http://blog.wadolabs.com . This keeps all my current links active and avoided a big fat 404 error. You can do more sophisticated logic here and check the requested page and map the request to the new location, but for me, I was okay just doing a global redirect to the root of my new domain.
Azure updated the beta offering to include several new exciting new features. Developers can now host their data in two geographically seperate data center, which enhances performance and avaliability. Also, they are adding the ability to run non-.NET code on the Azure Platform via FastCGI. For example developers can run PHP or Ruby on the Azure Platform.
After a long wait, Microsoft has finally released ASP.NET MVC 1.0. I’ve been following the progress of the product on ScottGu’s blog since day one. From the looks of things, its seems pretty solid. I’ll play with the final release later tonight and post my overall impressions. I’m curious how people intend to use MVC within their applications. Some people argue MVC is not only a Web Framwork for your presentation layer, but it can be a framework for building RESTful Services. What will people choose? MVC or WCF to build their RESTful services? Only time will tell.
Download the installer here:
Silverlight 3 beta and Expression Blend 3 announced today at Mix09. This is very exciting. Tons of new enhancements plus performance upgrades with graphics acceleration. The one feature I’m really interested in, is the out of browser support. This mean .NET running on a Mac!! (not like mono, the real way).
Get the lastest installers here:
Unable to attend Mix09? Watch live coverage here http://live.visitmix.com/