sábado, agosto 26, 2006

Castle vs Spring.NET


Both frameworks provide IoC and AOP capabilities, a Web Application Framework and further complementary capabilities.

Spring makes heavy use of XML configuration files, whereas Castle also provides an API allowing to programmatically configure the Container.

Inversion of Control Container


The Spring.Core library provides Dependency Injection functionality. Most of the libraries in the Spring.NET distribution depend upon and extend the functionality provided by this core library. The basic concept here is provided by the IObjectFactory interface that provides a factory pattern removing the need for programmatic singletons and numerous service locator stubs, allowing you to decouple the configuration and specification of dependencies from your actual program logic. An extension to the IObjectFactory, the IApplicationContext is also located here and adds more enterprise-centric features such as text localization using resource files, event-propagation, and resource-loading.


The WindsorContainer aggregates the MicroKernel providing a simpler interface and a set of important features that relies on MicroKernel extension points. The MicroKernel concern is to offer an extensible inversion of control container core. The Windsor concern is to offer a façade to the kernel and deal with external configuration, proxies and automatic component/facilities install. These are not MicroKernel's concern, and we want to keep both code bases as small and simple as possible.

Aspect Oriented Programming


The Spring.Aop library provides Aspect Oriented Programming (AOP) support to your business objects. The Spring.Aop library complements the IoC container in the Spring.Core library to provide a foundation for building enterprise applications and applying services to business objects declaratively.


Aspect# is an AOP (Aspect Oriented Programming) framework for the CLI (.Net and Mono). It relies on DynamicProxy and offers a built-in language to declare and configure aspects, and is compliant with AopAlliance.

Web Framework

This is probably the feature where the frameworks differ most.


MonoRail (MR) uses the Front Controller pattern to serve web requests. A HttpHandler maps requests with a special extension (default: .rails) to controllers which in turn render the contents using a predefined view template.

Actually MR doesn't even rely on ASP.NET as view engine but integrates NVelocity as view engine. Although MR offers lots of features for Web Applications, due to its completely different approach regarding Cuyahoga, it will not be discussed further.

More detailed information can be here MonoRail at Castle

Spring Web Framework

The Spring Web Framework (SW), relies on ASP.NET's Page Controller implementation to serve requests.

Here too, a HttpHandler is used to handle calls to *.aspx requests. The page is being "preprocessed" so the IoC Container can inject dependencies to the pages or even controls.

To be able to make use of further features, aspx pages or controls have to inherit from Springs extended base classes.

Master Pages

Very similar approach as ASP.NET 2.0 Master Pages. Since Cuyahog already offers this feature (in an even more dynamic way), this is probably not much of interest.

Bidirectional Data binding

Automatic mapping from the model to the controls and vice versa. At the time of this writing, the mapping is being defined using attributes but will soon change to use methods for allowing more flexibility.

Automatic Localization

Push and Pull Localization. Whereas "Push" is probably more interesting, allowing to automatically fill predefined controls (e.g. Label) with localized strings.

Result Mapping

Page flow can be externalized using configuration files. When using Server.Transfer (internally) arbitrary objects can be transferred between pages using HttpContext.

Web Services Support

Spring allows to expose plain C# classes as webservices and brings full support for IoC with Web Services

More information can be found here Web Framework Reference

NHibernate Integration

Spring.NET: not yet available

As taken from the Spring forums, NHibernate support is on the way.

Castle: NHibernate facility

Castle offers NHibernate integration, providing session and transaction management for NHibernate.

Additional Components/Services




Automatic Transaction Management, Perform automatic transaction management for your classes through interception

Batch Registration, Registers components based on configuration instructions Cache, Allows cache for your components

EnterpriseLibrary, Provides integration with MS' Enterprise Library Configuration package

EventWiring, Allow subscribers to connect to events exposed by publishers

FactorySupport, Allow your application to use external factories

Logging, Provides logging abilities for your components

RemotingFacility, Configures and provide access to remote components in a transparent fashion.

Startable, Implements the startable semantic for components

TypedFactory, Given a factory interface, automatic implement it delegating creation to the container



Refactor!™ for Visual Basic® .NET 2005

What is Refactoring?

Refactoring describes the process of making many small changes to working code, improving the internal structure without altering the external behavior of that code.

As an analogy, consider the math statement 2*4*5*3*1, you can covert this to 1*2*3*4*5 without changing its meaning and from there into 5!. They all mean the same thing but are increasingly easier to read. Refactor! does the same thing but with working source code.

There was a time not too long ago when just for fun developers would actually engage in obfuscated code competitions to produce the most difficult to read code. Well unfortunately there is a lot of code out there that is not much more readable than that intentionally obfuscated code - which is where refactoring comes in. The goal of refactoring is to take working code that is harder to read than it needs to be, and tweak its structure to make it more readable and more easily maintained.

.NET languages have been designed to self-document and encourage the development of readable, maintainable code - but even these languages code can grow organically over time and become cluttered and overly complex. Refactor! has numerous industry-first features that can help you take this complex code and make it easier to read and less costly to maintain.

Why Refactor!™

Refactor! does something no other tool can claim to do: it brings the power of an entire suite of refactoring tools to bear with just one key ("One Key Refactoring") and it works directly on your code in your editor - so you'll never have to leave your code just to restructure it.

Figure 1. One Key Refactoring - press CTRL+~ at any point to see all available refactorings with a short description of each.

Refactor! is built upon a language neutral architecture that offers exactly the same functionality for Visual Basic .NET and C# developers (beta support of C++ is also available). Refactor! even includes extensibility features to allow developers to easily build language-independent refactorings that can be used internally or shared with a growing community of highly satisfied Refactor! Pro customers.

Before we describe to you just a few of the over 50 refactorings available within the product, let us assure you that everything you can do with Refactor! can be rolled back using the standard Visual Studio Undo/Redo mechanism. So you really have the freedom to explore with this tool - simply hit CTRL+Z (or whatever key Undo is bound to) if the refactoring is not what you expected.

Refactoring: Reorder Parameters

Change the order of parameters in a Method signature, while also updating all calls to this method. Great when you need to change the parameter declaration order so that the most important parameters appear first, which will improve the usability of the method.

"Reorder Parameters" is probably the best example of how Refactor! is different, because the entire process is extremely visual and happens right there in your code. Here is how you reorder your parameters. Simply move the text cursor into the declaration of a method with parameters and this refactoring will be available. You can see that it is available if you stay there for a moment, because the refactoring smart tag will show up with a list of all the refactorings available. But you don't need to wait for anything - just hit the "One Key Refactoring" key (CTRL+~) and now you can move all your parameters left and right simply using the left and right cursor keys.

Figure 2. Reordering parameters directly upon code in the Editor - no modal dialogs to slow you down.

Refactoring: Rename

This refactoring renames a local variable or a private field, property or method. This refactoring affects both the declaration and any references within the class.

Choosing meaningful identifier names is one of the simplest ways to improve the readability of your code - Refactor! makes this process trivial. You simply put the text cursor into the identifier, and hit the "One key refactoring" key (CTRL+~), and start changing your identifier. You will see all references to your identifier highlighted with a light green box. You can now cycle through each call using the TAB and SHIFT+TAB keys, and if you change any one - the others all reflect the change.

Refactoring: Extract Method

The most sophisticated of all class based refactorings is probably "Extract Method". This refactoring allows you to select a piece of code from inside a method and extract it outside into a method of its own - while leaving a call to that new method in the code the method came from.

You are probably already several steps ahead of us in how to activate this refactoring by now; You simply select some code, put the text cursor in the code, hit the "One Key Refactoring" key (CTRL+~), and now you have a new method containing your block of code, with a call where that code came from.

Consider this example code which calculates the volume of a cylinder. Suppose we decide to extract the code that calculates the area of a circle to a method of its own, for later reuse. To do this all we do is select the specific block of code and hit the "One key Refactoring" (CTRL+~), the code is cut from the source method, and we are prompted for a location for the target method.

Figure 6. You can place the extracted method precisely using the red Target Picker.

Once we have chosen the location for the new method, Refactor! calculates how many parameters need to be passed, creates some default names for the new method and any parameters, generates the code for the new method and calls it, and finally invokes the "Rename" refactoring in case we wish to override any of the default names chosen.

Figure 7. The fully extracted method - Refactor has determined parameters to pass and even come up with a meaningful name.

You know there is actually an even faster way to extract. Select the code - Cut the code - Paste it outside the Method but inside the class and Refactor! will extract the method for you automatically.

Notice that the method name and the call are both linked with green boxes - the "Extract Method" has automatically invoked the "Rename" refactoring for you. Also if there are any variables referenced outside as well as inside the block you selected, then Refactor! will automatically give your new method the appropriate parameters to pass in that data and if needed pass it back.

Over 50 Built-in Refactorings

When it comes to scope, breadth, and ease-of-use, no other product in the market even comes close to Refactor! It would be impossible to describe each of the 50+ refactorings in detail within this white paper and so we wont try – but to whet your appetite, here are a few others worth consideration.

  • Compress to ternary expression / Expand ternary expression
    Converts an if/else conditional with assignments in each branch into a ternary expression, or expands a ternary expression into an if/else block.

  • Widen scope
    Moves a variable declaration up and out in scope.

  • Flatten conditional
    Unindents the If or Else statement for a conditional. This will apply one of the following refactorings: Replace Nested Conditional with Guard Clause, Remove Redundant Else, or Reverse Conditional followed by Remove Redundant Else. Flatten conditional is also smart enough to recognize "if (E) return true; else return false;" and convert that condition to simply "return E;".

  • Simplify expression
    Resolves a complex expression to its simplest form.

  • Combine conditionals
    Combines two or more neighboring conditionals with identical bodies into a single conditional statement where each conditional expression is logically OR'd.

  • Create method contract
    Creates a contract for the current method, verifying that parameters are valid.

  • Inline result
    Replaces final assignments to the temporary variable with a statement that immediately returns the value, removing the temporary variable if possible.

  • Move type to file
    Creates a new file with the same name as the type at the caret, adds the file to the project, and then moves the type to that file, along with any leading comments, attributes, and XML doc comments. This refactoring is available when the caret is on a type declaration and the file contains two or more types.

  • Use String.Format
    Converts a composed string expression into a single String.Format call.

  • Use StringBuilder
    Replaces these string concatenation operations with method calls on a local StringBuilder instance to improve performance (working with a StringBuilder is faster than concatenating strings).

  • Optimize namespace references
    Removes unused namespace references (using/imports statements in VB and C#, and unused #include files in C++).

jueves, agosto 24, 2006

VMWare Image


What do I do with the image?

You can use the free VMWare player to run this virtual machine: [download (http://www.vmware.com/products/player/)] You can also use this image with any VMWare product compatible with VMWare Workstation.

What is the root password for the image?

The root password is 'mono'. The image is set up to automaticially log on as the 'mono' user, and that account's password is also 'mono'.

What's a torrent file?

Ask Google instead. By using BitTorrent, we are able to distribute the bandwidth loads of the 1.3 GB file.

Network connections are slow, why?

Most likely your DNS is not correctly setup, select "control center" from the Computer menu, and then select "System" to configure your networking.

If SLED can't find your hostname, use the ipconfig command on Windows to get your IP Address. Ipconfig will list the IP address for your VMWare guest (SLED) as well.

Will binaries from Windows work?

Yes, they will.

See our Guidelines:Application_Portability for recommendations on how to make your software port better.

How do I know my torrent downloaded successfully?

Use md5sum to verify the download:

md5sum mono1.1.16.1_sled10_vmware_2.zip
8b0dcad3cc9a046717c4798e831a9f82 mono1.1.16.1_sled10_vmware_2.zip

New Visual Basic Framework

A new Visual Basic.NET framework is under development, and it consists of two components: a new VB.NET compiler written in VB.NET (developed by Rolf Bjarne) and a new VB.NET runtime developed completely in VB.NET under development at Mainsoft by Rafael Mizrahi and Boris Kirzner.

The new runtime is being developed in VB.NET and does no longer require the ILASM and Perl hacks that were required to implement the Visual Basic runtime as we did in the past. The new runtime also contains a large collection of regression tests to ensure that the quality of the runtime, something that we did not have in the past.

Currently this infrastructure is not shipping, but we will soon package it up and distribute it.

The code is currently available from SVN from the modules vbnc for the compiler and mono-basic for the new runtime.

Mono Live

What's this?

The Mono Live LiveCD is a way for you to try out Linux, the Mono Framework, and the newest desktop applications without modifying your current computing environment.

What can I do?

This Live CD contains lots of exciting software. You can:

The i386 CD also contains the files necessary to install Mono on Windows computers. This allows you to expore the framework without installing a Linux desktop, and begin developing cross-platform applications with Mono and Gtk# today.

I want it now!

To get started, download the Mono Live LiveCD ISO disc image from one of the links below. Once you have obtained the ISO, burn it to a CD. Insert the CD, reboot your computer, ensure that in the BIOS the CD is used before your hard disk. You will be asked a few simple questions, and your desktop will soon be good to go.

Once the Live CD loads, you can find help getting started by opening the "Welcome" message in Tomboytomboy icon located in the tray in upper-right hand corner of the screen.

Download via BitTorrent (i386)
Download via HTTP (i386)

For best results, download the torrent. For BitTorrent instructions and to download the BitTorrent client, go to the BitTorrent site.