RSS 2.0
# Thursday, January 28, 2010

On my new project I want to start using end to end testing.

The idea is to write an specification run it against an outer interface. Gui, Web service, etc. It fails. So you start implementing the feature using TDD until the Spec pass.

You write a second scenario and you start again. If everything works as supposed I should have a fairly well tested application, not only at the unit level but at the integration and user acceptance level as well.

Since the application will be written in c# I look around for some tool to write the Scenarios in the same language. There are some options but none of them was as elegant as using Cucumber. So I tried cuke4nuke but I have no luck with it. I kept getting an error about server not running or something. It looks like a permission problems with win 7.

I’m sure I could have figure it out (some confidence I have on my abilities :-)) but after giving it a second though I decided to go with Cucumber and RSpec for those test. Drive the browser with Watir and hit the web services end points with webrat, sometimes even script the UI with webrat when the browser is not really need it.

Installing all the gems is easy just

gem install cucumber
gem install webrat
gem install mechanizer
gem install watir
gem install rspec 

 

and you are done (at least in my case). Of course you need to have ruby installed in your system. I have 1.8.6

Since I haven’t really used Cucumber before and my Ruby is still very flaky, I decided to use RubyMine as my IDE to write the specs, specially because you can generate the step definitions from the features in a similar way as how you generate code with R# in VS.

You start writing an Spec with one scenario like this:

ScreenShot001

Then you run it via the console and have this result.

ScreenShot008

Note the yellow squiggly lines on the step definitions for the scenario? If you move the mouse over them a prompt will indicate that the step haven’t been created yet:

ScreenShot002 

Hit Alt+Enter to see a suggested solution:

ScreenShot003

Click enter and you have some options, to use an existing step definition file or create a new. If you hit create a new one and you don’t have an step_definitions folder RubyMine will create it for you.

ScreenShot004

In this case I select the existing bing_steps.rb file

ScreenShot005

Notice that the values between quotes are replaced by a regular expression, hit tab to modify the different tokens of the method template. After generating all the methods and adding the necessary code, this is the result.

ScreenShot006

And when running via the console this is the result:

ScreenShot007

In this case we are running this specs against an existing piece of software, in my case I will run this against a new un-written site. So to see the scenario pass I should write the feature as well.

kick it on DotNetKicks.com Thursday, January 28, 2010 12:02:27 AM (Eastern Standard Time, UTC-05:00) by Hernan Garcia #    Comments [1] - Trackback
Frameworks | Methodology | Programming | Testing | Tools
# Thursday, October 15, 2009

Some time ago I heard about the intent of putting together a package manager for .net ala gems or pear. I wasn’t aware that this project was actually under way. The name of the project, Horn.

Please check the links in the project home page on how to get started with Horn. It’s very simple and actually works as promised. One thing you need to remember is that you will have to install a subversion client and a Git client for Horn to check out the source code from the projects you want to build.

I had two issues in my Win7 machine, where I tested. The first issue is related to Git really and not to Horn and/or Win7. Make sure that you have the path to your git.cmd into the PATH of your computer.

It’s usually %PROGRAMFILES%/Git/cmd, if you don’t when trying to do a horn –install on a project using Git, Windsor (the Ioc container used by Horn) will throw an exception.

The other issue seems to be a concurrency issue when trying to read a Temp file. Not sure how this files is been created just yet. This happens while trying to build complex projects like MvcContrib. Re-issuing the install command will “resume” the build. It took me three attempts to build MvcContrib.

Even with this issue (that may not be a Horn issue at all) I think that this is a very important project for the .Net community. It makes building this complex projects with all the dependencies a routine task. You don’t have to spend hours tracking down the project, the source code and pray that everything builds and works well together.

kick it on DotNetKicks.com Thursday, October 15, 2009 9:19:19 PM (Eastern Standard Time, UTC-05:00) by Hernan Garcia #    Comments [0] - Trackback
Frameworks | Programming | Tools
# Wednesday, July 22, 2009

A few hours ago I saw a Twit by @shanselman about having Ruby and Python scripts tags in your html pages. Clicking in the URL took me to http://visitmix.com/labs/gestalt/. I didn’t have to read much to understand the potential.
I’m myself an old web guy that still love to craft my JavaScript, Html and PHP code using a text editor. (My old time favourite was PSPad but lately I have been using e, a “clone” of TextMate for windows.

My team make fun of me since sometimes I even fire up e to fix some bug in C# files.

Don’t get me wrong, I love a good IDE and there is no way I can be as productive as I am writing C# without Visual Studio and add ins like R# or CodeRush. This post is not about IDE’s vs. Text editors anyway.

This post is about Gestalt. What is Gestalt? It’s a JavaScript library that act as a bootstrapped to load Silverlight and the DLR engine to interpret Ruby, Python and Xaml code embedded directly in your pages. (Ok, It doesn’t need to be embedded you can use linked files, what is the recommended way anyway.)

Of course, been the ADD person that I am, and such a geek, I needed to try it and see how long would take me to create a simple (emphasis on simple) video player.

11:25 PM Make a mental list of the requirements:

  1. Add a MediaElement that loads a video into a page (Xaml file linked, not inline).
  2. Add three html input buttons, one for play, one for pause and one for stop. (These are in the html page).
  3. Wire up the control of the MediaElement to the input buttons using python. (Since I’m learning the language).
  4. Have it working before midnight or go to bed.

11:26 PM

Download Gestalt and extract to my Development folder.

11:27 PM

Download the TextMate bundles provided by the Gestalt team and extract them into the Bundles folder of e (e can use TextMate bundles, if you don’t know what this bundles are, let’s put it this way, are like Resharper templates+macros+code snippets ).

11:28 PM

Create a folder under wwwroot (not a virtual directory), copy the Gestalt library and folders into it, and added a few more folders to keep the structure clean.
Start to download the interview from channel 9 program “The knowledge chamber” where Nishant Kothary and Joshua Allen present Gestalt.

11:30 PM

Launch e, create a new HTML (Gestalt) file. Check the menu to try to get a grasp on the bundles shortcuts. Type skelg+Tab and a basic html skeleton get’s generated for me.
Remove the link to the CSS file since I want be using any in this test.

11:32 PM

Open the “Designer” that the Gestalt team offers online, select a MediaElement and change the size, type something in the source and change AutoPlay to False.
Check the XAML, copy and paste inside e in a new Xaml file. (Syntax highlighter works as expected.)
Change the source to the absolute location of the video previously downloaded.
Save the file inside a Xaml subfolder.

11:35 PM

Create a link to the Xaml file in the html file (needed to consult the documentation, sample files).
Create three input elements, give them names and id’s (Id’s is the way you will access them from your code later on).

11:40 PM

Create a new Python file inside a python subfolder.
Create three methods (ClickPlay, ClickPause, ClickStop), to handle the onclick event on the input elements. (have to consult the documentation for the method signature).
Attach the this method to the proper event for each of the input elements, the code is very similar to the way that both prototype and JQuery do this.

11:43 PM

Launch the page in my browser, I got an error message that told me that I have to put the correct path for the gestalt.xap files (I remember reading about that in the Faq’s)
There is two ways to change the default path, I decided to open Gestalt.js and edit the file directly. You can also change the path programmatically.

11:44 PM

Try again, video playing, but not showing completed. Half of the frame is hidden. Open the html file adjust the size of the xml tag.
Refresh the browser. Success!

11:45 PM

Click in the buttons, nothing happens. Open FireBug Net tab to check for the traffic in the network, my python file is red. I guess IIS doesn’t know how to handle .py files. Open location in new tab, and sure enough, need to add a mime type or specify a handler.
I don’t want to do that. The good thing is that source code is text, so let’s change the name from hdplayer.py to hdplayer.py.txt.
Refresh the browser one more time. Click the button. Success!

11:47 PM

Right click on the video opens the Silverlight preferences dialog, like it should.

In no more than 21 minutes I was able to create a Silverlight player that is controlled via html controls without opening either Blend or VS. Also notice that I didn’t have to expose any properties as Scriptable, since Python code is running inside the same sandbox (I’m guessing here, but I’m pretty sure that I’m close enough :-)).

It took me longer to write this post that write the simple video player.
So, what are you saying, we don’t need blend and VS to write Silverlight applications? No, I’m not saying that. I’m pretty sure that there may be scenarios where writing you code in c# a deploy a XAP file are the way to go. But I see a lot of other scenarios where Gestalt is the way to go.

I may be do some more on top of it or something else, maybe investigate how difficult will be to implement drag and drop.

kick it on DotNetKicks.com Wednesday, July 22, 2009 12:00:47 AM (Eastern Standard Time, UTC-05:00) by Hernan Garcia #    Comments [0] - Trackback
Frameworks | Gestalt | Programming
# Saturday, July 11, 2009

You can find this text in the the wiki for Pronghorn on Code

plex. http://pronghorn.codeplex.com

Pronghorn is still a work in progress and the architecture+design is changing very fast.
At this moment the main focus is on the ViewEngine because is what will provide most of the value for my actual employer.


Most LOB applications can be done using just one or two master pages and one area of content per URL. In this context ASP.NET MVC can be used out of the box with no or just a few changes. HTML.RenderAction can be used in lieu of widgets in the page without a big penalty on composition.

But there is also a need for more complex applications, those where web pages are build from a collection of discrete components (widgets). These widgets should be added or removed in a dynamic fashion without the involvement of a developer. Those are the scenarios where CMS frameworks come to play. Pronghorn is not a CMS but it provides the tools to make this type of composition on top of ASP.NET MVC.

To accomplish that much, Pronghorn has “some opinions" on the way you should build composite applications using MVC. These opinions are expressed via the use of interfaces and base classes that extend and sometime constrain the MVC framework.

Controllers should be small and map to only one resource. They should be Rest-like (use the HTTP verbs for the actions names, enforced via the ControllerBase.ExecuteCore).

The ControllerBase.OnActionExecuted adds "Areas" for a given view based upon the Controller, Action and SiteContext. This Area loads a collection of widgets in a specific order, that can change from area to area between pages.

At this point is where the ProngHorn.ViewEngine kicks in. ProngHorn.ViewEngine is an html based view engine, that uses a similar syntax to the one used in the prototype.js templates.

Composition is achieved via some Injection mechanism using DI.

Widgets "publish" to the page, called skin in Pronghorn witch css, js files will need. These resources should be minified and combined to reduce network traffic and # of http calls from the browsers to improve performance and load time.


To keep up with the project you can subscribe to the project’s wiki RSS. Where you can get all the updates, a bit chatty but may be useful or visit the project’s home page periodically.

kick it on DotNetKicks.com Saturday, July 11, 2009 10:32:53 PM (Eastern Standard Time, UTC-05:00) by Hernan Garcia #    Comments [1] - Trackback
Frameworks | Programming | Tools
# Sunday, June 21, 2009

 

This post have been inspired by the talks about controllerless actions. This is NOT an alternative to that. Controllerless actions is an interesting concept that should be study. Actually Jeffrey Palermo has a concept implementation.

There is a problem with controllers that grow or contain too much code in them.

For the second problem, containing too much code, the only solution I see is code reviews and practice of proper separation of concerns.

For the first problem, we can apply some constrains in the way controllers are written and used to limit the number of methods.

The way we use controllers today is by (sometimes) mimicking the old document based model for web applications.

We call the first screen of our web application Home page, so to handle access to this resource we create a HomeController (so far so good). Now what happens when somebody browse to the route we assign to this resource with no action defined in it? The controller is called and “a default action” is executed, and we tend to call it “Index”.

Think about it, why is this action called “Index”? What are we indexing? Nothing. We call it Index and we never look back, because it fits with our old way of doing things. Remember how we used to call the default document/page in the document based web applications a long time ago? index.html

Side note: [In asp and asp.net default.asp was the general name of this page and how IIS got configured, so this action could very well be called Default for similar reasons, but default (all lowercase) is a reserved world in C#, so maybe that played against it. In any case, even when Default is a more meaningful name for the action than Index, it’s still not good for our purposes.]

Of course there is nothing that force you to call this Actions Index and maybe you are calling them something completely different, but this is the default name after creating a new project.

When you do a request to the Home resource typing the route in the address bar of the browser and hit enter you are using the Get http verb, so the name of the action should be Get(). Where am I going with all this?

The controller should control how your presentation handle request, and request are performed using different verbs against resources, so the controller should know how to react to those verbs and coordinate some work with a lower layer, acting almost as a translation layer between your business code and the view. The controller should not know that you want to FindABook or SignIn or LogOut or SendAMail.

Let’s limit the actions in a controller to the HTTPVerbs you want to support and no more than that. There are only (4-5 at the most) http verbs you may want to support for a given resource. (Get, Post, Put, Delete, Head)

Most web applications will only support two Get and Post. These will keep your controllers very, very small as far as you don’t write 500 lines in each method, or switch statements to support “multiple actions” per method.

To enforce this on code you can create your own base controller overridden the ExecuteCore method with something like this:

  1:     protected override void ExecuteCore()
  2:     {
  3:       TempData.Load(base.ControllerContext, TempDataProvider);
  4:       try
  5:       {
  6:           string actionName = base.ControllerContext.HttpContext.Request.HttpMethod;
  7:           if (!ActionInvoker.InvokeAction(base.ControllerContext, actionName))
  8:           {
  9:               HandleUnknownAction(actionName);
 10:           }
 11:       }
 12:       finally
 13:       {
 14:           TempData.Save(base.ControllerContext, TempDataProvider);
 15:       }
 16:     }

Please note that this is not REST, if you want or need to go REST make yourself a favor and take a look at openrasta.

If your view have multiple parts, like in most complex applications, you may think that this approach is limited and unpractical and it won’t work. I plan to show in a later post how to implement widgets following this approach, keep tune.

I hope this is useful.

Technorati Tags:
kick it on DotNetKicks.com Sunday, June 21, 2009 10:43:05 PM (Eastern Standard Time, UTC-05:00) by Hernan Garcia #    Comments [2] - Trackback
Frameworks | Programming
# Saturday, January 17, 2009

 

A few moments ago (55 minutes to be exact) Chad Myers made a commit on revision 55 of the FubuMVC enabling this to run using F5 inside Visual Studio, using Cassini.
He also updated the wiki with new information about minimum requirements, compiling the code and running the demo site.

It’s interesting to look at the details of the commit and notice the changes needed on the project file to launch Cassini.

kick it on DotNetKicks.com Saturday, January 17, 2009 5:49:52 PM (Eastern Standard Time, UTC-05:00) by Hernan Garcia #    Comments [0] - Trackback
Frameworks
# Thursday, January 15, 2009

 

This week the guys at the herding code chat with Chad Myers and Jeremy Miller on FubuMVC, testing with JavaScript and QUnit and SOLID principles.

http://herdingcode.com/?p=131

kick it on DotNetKicks.com Thursday, January 15, 2009 6:51:00 AM (Eastern Standard Time, UTC-05:00) by Hernan Garcia #    Comments [0] - Trackback
Frameworks | Methodology | Programming
# Monday, January 12, 2009

 

We are living in very exiting times in the .Net world. Every time I look I find a new framework to do web development. I recently found FubuMVC. This framework is a bit different from Sharp Architecture or the Catharsis guidance since this one does not use ASP.NET MVC but is inspired by it.

Fubu is an acronym which means "For us, by us." After using the Microsoft ASP.NET MVC Beta framework and disagreeing with some of the design choices made therein, several of us decided to try to bend it to our design choices using its extensibility points. Eventually we reached our goal, but we realized we had overrode or replaced large portions of the MVC framework. At this point, it was suggested that maybe we take it one step further and write our own MVC framework starting at the same layer where ASP.NET MVC begins. This is the realization of that suggestion.

To be clear: This framework is NOT based on the ASP.NET MVC Framework at all. It is inspired by it, however.

The project is very active at the moment with several daily commits almost every day, but there isn’t a lot of documentation. The wiki is practically empty. I guess at this point they are focusing on functionality. I downloaded the code and was able to do a build with no problems. You can build using VS or Rake. See this wiki article on how to start with Fubu.

To use Rake you need to have Ruby installed on the machine to take advantage of their script. There is a batch file to install the Rake gem if you don’t have it, so just install Ruby and them start playing.

ScreenHunter_01 2009-01-08 23.18.13

Here is some of the output using Rake, notice that the build script runs the test as well, something we all know is a good practice, but not everybody does, doesn’t it?

ScreenHunter_02 2009-01-08 23.18.55 ScreenHunter_03 2009-01-08 23.19.32

Taking a look at the Project

Open the FubuMVC solution file inside the src folder. Run the Test projects, everything should be green, you should see 3 ignored cases.
Since I’m using windows XP in this machine I wasn’t able to properly run the AltOxite project since It doesn’t seem to work properly with Cassini and or IIS 5.1. UPDATE: This have been already fixed on the trunk, so update your checkout now.

I really like this framework, so far (looking and browsing the code) this is the one I like the best from an architectural point of view. It’s simple and powerful at the same time. Enforcing best practices (or what I think about us best practices) like separation of concerns. See in the example the controllers live in a separate assembly from the web project. (Sharp Architecture and Catharsis both take the same approach by the way).

A few links to the project author’s blogs.

kick it on DotNetKicks.com Monday, January 12, 2009 1:53:00 PM (Eastern Standard Time, UTC-05:00) by Hernan Garcia #    Comments [0] - Trackback
Frameworks | Patterns
# Sunday, January 11, 2009

 

I found this project on CodePlex called xVal. It’s Steve Sanderson’s take on validation for the ASP.NET MVC framework, more to the point on how to use validation across tiers (validate on the server side, present errors to the client, etc.)

xVal is a validation framework for ASP.NET MVC applications. It makes it easy to link up your choice of server-side validation mechanism with your choice of client-side validation library, neatly fitting both into ASP.NET MVC architecture and conventions.

It’s extensible so you can use whatever validation framework you want in the server and client side.

  • Define your validation rules using attributes on model properties, e.g.,
  • Designed to fit into ASP.NET MVC conventions for handling form posts and storing and retrieving error information in ModelState
  • Use your choice of server-side validation framework. Out of the box, xVal lets you use .NET 3.5's built-in DataAnnotations classes or Castle Validator (or both). If you want to use something different, you can create your own provider just by implementing IRulesProvider.
  • Use your choice of client-side validation library. Out of the box, xVal lets you use jQuery Validation or ASP.NET's native client-side validation library (a.k.a. WebUIValidation.js, as used by WebForms). Or, use any other client-side validation library by writing a plug-in to configure it using xVal's standard JSON rules description format.
  • Supports localized error messages using resource files. Vary the language of your validation messages according to the current thread's culture.
  • Add custom validation logic that runs both on the server and on the client, either by sub classing an existing rule or by referencing a custom JavaScript function

It just released version 0.5 and you can find a quick tutorial on Steve’s blog.

kick it on DotNetKicks.com Sunday, January 11, 2009 11:52:11 AM (Eastern Standard Time, UTC-05:00) by Hernan Garcia #    Comments [0] - Trackback
Frameworks | Programming
# Thursday, January 01, 2009

 

Once in a while I like to browse around Codeplex to see what’s new and if I found anything interesting.

Today I found this Gem of a project called Catharsis.
To be able to use it you will need VS 2008 with SP1.
The Guidance Automation Toolkit  and I also installed the GAX SP1
The ASP.NET MVC (BETA) installed via the installer.

What is Catharsis? You may ask. It’s a complete application framework that uses ASP.NET MVC for the UI layer, they mention to support WPF projects as well but I haven’t see it yet, maybe 1.0 version, the current release is 0.95.

But it’s more than that. It’s also a set of tools that integrate with Visual Studio and provide several Wizards to do most task in a very simple way. The solution created is quite complicate but very well organized.

ScreenHunter_02 2009-01-01 23.13.49

Installing Catharsis

In the documentation of how to install Catharsis they recommend using the msi file, but I couldn’t find it in the release, so I have to open the Guidance projects, do a build and them run the msi. This was a non issue, you will be prompted to remove the references to Source Control from the solution when you open it for the first time, just click yes.

Creating your first project.

It’s very simple open the Create new project dialog and you will see a new Catharsis type of project

ScreenHunter_03 2009-01-01 23.19.58

Enter the Name and click Ok, another window shows

ScreenHunter_04 2009-01-01 23.20.26

Click Finish, sit and wait.

At this moment you should be able to set up you Web project as the startup project and the Default.aspx file as the Star up page, hit F5 and see it work. I had a few issues at this point.

The first one was that the project did not compile:
The problem was an extra comma on the file: BaseEntityControllers.cs in the Controllers project under the Project.Web folder. This comma is in the list of Interfaces the class implements.

Once fixed the project compiled with no problems but when trying to run it I had my second issue, the tables in the database have not been created. So I had to run the scripts located at DB_SQLServer in order 01_ first and 02_ afterwards. Notice that the connection string I provide in the wizard was correct since NHibernate can connect to the database, so no sure why the scripts didn’t run.

Note: To run the scripts make sure you change the first line of them to point to your database (they are pointing to a Catalog called Project, maybe this is the problem during the setup wizard?)

Once you have done this, make sure you rebuild the project and hit F5 again and, another problem (the last one). The log4net.dll wasn’t copy into the bin folder of the web solution, so copy it from Assemblies/Log4Net into the proper bin or add a reference from you web project to the log4net dll and rebuild.

After that everything worked fine for me. I will try to port an old asp classic application using this architecture and see what I like and what I don’t, but I suggest you give it a try.

There are several articles at CodeProject on how to do different things and in more details about the architecture, Ioc, Tracking Changes and more.

kick it on DotNetKicks.com Thursday, January 01, 2009 11:38:20 PM (Eastern Standard Time, UTC-05:00) by Hernan Garcia #    Comments [1] - Trackback
Architecture | Frameworks | Programming | Tools
# Friday, December 26, 2008

 

I was going to write a post about this but my thoughts are exactly the same as Fredrik Normen’s.

For example, one thing that creeps me out is seen think like this in the Controller.

   23         public ActionResult Index()

   24         {

   25             var repository = IocContainer.GetClassInstance<IRepository>();

   26             var members = repository.GetAll<Member>();

   27             ViewData["members"] = members;

   28             return View();

   29         }

Or even worse:

   45         public ActionResult CreateMember()

   46         {

   47             var member = new Member();

   48             member.Hydrate(Request.Form);

   49 

   50             if (member.Email == null)

   51             {

   52                 ViewData.ModelState.AddModelError("Email", "Email can't be empty");

   53             }

   54             //More code here

   55         }

I don’t think that the controller should ever touch the repository and of course it shouldn’t do any type of validation besides data entry from the view.

kick it on DotNetKicks.com Friday, December 26, 2008 8:22:47 PM (Eastern Standard Time, UTC-05:00) by Hernan Garcia #    Comments [0] - Trackback
Frameworks | Patterns | Programming
# Saturday, December 20, 2008

 

At least two really good post today about the future RC1 for the ASP.NET MVC framework. Scott Gu has a very detailed post with some of the new features expected in RC1. Phil Haack talks about the delay and the improvements with the Views.

Scaffolding, views without code behind (yeah!), new HtmlHelper<TModel> and AjaxHelper<TModel> types to build strongly typed HTML and AJAX helpers (this should remove the need for magic string.

The feature that got most exited was the changes to the Views, no code behind is, IMHO the way the Views should be.

I can’t wait to put my hands in this release.

kick it on DotNetKicks.com Saturday, December 20, 2008 5:48:00 PM (Eastern Standard Time, UTC-05:00) by Hernan Garcia #    Comments [0] - Trackback
Frameworks | Programming
# Friday, December 19, 2008

 

On December 2nd Sharp Architecture released version 0.9.114.

Sharp Architecture is a project created by Billy McCafferty. It’s an architecture framework for web application that uses ASP.NET MVC, NH 2.0.1, NHibernate.Validator, Fluent NHibernate, and Castle Windsor.

From their site:

Pronounced "Sharp Architecture," this is a solid architectural foundation for rapidly building maintainable web applications leveraging the ASP.NET MVC framework with NHibernate.

The overall goal of this is to allow developers to worry less about application "plumbing" and to spend most of their time on adding value for the client by focusing on the business logic and developing a rich user experience.

  • Focused on Domain Driven Design
  • Loosely Coupled
  • Preconfigured Infrastructure
  • Open Ended Presentation

There is of course a strong focus on TDD as well. New on this version (from the change log)

* A Visual Studio 2008 template project has been added under /TemplatesAndCodeGen to get your own S#arp Architecture project up and running quickly
* Replaced Ninject with Castle Windsor
* Added support for behavior driven unit testing
* Unit tests now use an in-memory SQLite database for testing data access methods along with providing an integration verification mechanism to check mappings against a live database
* This will likely be the last interim release before version 1.0

I think that the project templates and wizards are a big plus on this package. In the roadmap for version one this is what we can look for:

* WCF integration
* Hone CRUD capabilities
* Support for multiple databases
* Example of using a Unit of Work to encapsulate non-trivial controller logic
* Scaffolding generators!

There is a discussion group on Google groups to provide support and ask for help.

Another thing that really impress me was the 34 pages Word document included with the release. It’s very detailed, from configuration to usage. There is a explanation for each of the Tiers in the architecture, a tutorial to develop with it that covers the TDD cycle and a set of best practices.

The documentation is very detailed, specially on thing that may seem of minor importance as on how to configure the IDE to be consistent with the sample code!!!

If you haven’t do so, go download it and play with it.

kick it on DotNetKicks.com Friday, December 19, 2008 7:03:00 AM (Eastern Standard Time, UTC-05:00) by Hernan Garcia #    Comments [0] - Trackback
Architecture | Frameworks | Patterns | Programming
# Saturday, November 22, 2008

I will try to create a simple CMS framework on top of the ASP.Net MVC. This will be mostly an exercise, something that I feel I need to try to see how it works. Some of the goals:

  1. The framework will be extensible but opinionated.
  2. The views need to be composite and the markup created by the designer should be very simple with minimum or no code at all.
  3. The framework needs to provide a centralize Exception handler mechanism.
  4. Multiple sites in one install.
  5. Partial views should use a common interface (IViewModule?) so we can provide a modular architecture.
  6. Easy to template by a designer, easy to skin by a designer.
  7. HTML and CSS standards compliance friendly.
  8. In line administration are fully backend integrated to the site.
  9. Testability is paramount, and the framework should come with a good set of unit test as part of the release.
  10. Been able to run the test from inside the framework, so install can diagnose problems.

I will be posting more about this and some code as soon as I have something put together.

kick it on DotNetKicks.com Saturday, November 22, 2008 1:15:45 AM (Eastern Standard Time, UTC-05:00) by Hernan Garcia #    Comments [1] - Trackback
Architecture | Frameworks | Patterns
# Friday, May 16, 2008
Jeffrey Palermo gave a great presentation about the ASP.NET MVC framework.
If you read my blog you know that MVC is kind of an obsession with me.
The presentation used the codecampserver project that use the last drop of the code for the MVC and the last version of Palermo's MvcContrib as well.It was concise and covered the most important topics (at least from my point of view), it was fast paced and good fun.
There was a very nice moment where he shows up how to use a controller to render different views.
Sometimes return Json data amd sometimes return a web page.
You can also see something similar at Iridescence.
It was very interesting to see the architecture of codecamp, he uses a Layered onion architecture for the multi tier architecture, very interesting concept.
I think that you may have used something like this but I never saw this graphical representation and makes a lot of sense. The most traditional representation doesn't work as well as this one. At least for this type of applications.
I recommend that you download the slides for the presentation and take a look at it.One of the things I like the most is that he include the Test as a layer of the architecture.
This is important because It make the tests first class artifacts on the solution and not an after though or something that can be considered as trivial.
I almost forget, Palermo played some very cool music before and after the presentation.
Palermo posted the material for this presentation on his blog.
kick it on DotNetKicks.com Friday, May 16, 2008 1:26:16 PM (Eastern Standard Time, UTC-05:00) by Hernan Garcia #    Comments [0] - Trackback
Architecture | Frameworks | Patterns
# Tuesday, December 25, 2007

The guys from InfoQ have this very good article about the release of Ruby on Rails 2.0.

It's very interesting to notice that 2.0 won't be fully compatible with the previous versions of Rails, I don't have nothing important or too complicated written with Rails so I don't expect to have too much trouble upgrading but I will like to see what is the response of the rails community to this.

Of course a major version upgrade can't be fully backward compatible with some older versions of the framework so I don't see the problem but we usually hear complains when some other vendors make some drastic changes. The argument can be made that Rails (and ruby) are open source and free, so you don't have the same investment than when you pay tons of money to a vendor for a platform and them  he decides to change without consulting you.

Worst case scenario you may probably keep running your old Rails app in the old version of the framework.

I'm personally doing most of my Rails work using the Jruby interpreter and Netbeans 6.0, the support of this IDE to the framework and the language is very cool, there is nothing like that so far in all the others I tried, even RadRails (now supported by Aptana and very much improved).

 

kick it on DotNetKicks.com Tuesday, December 25, 2007 12:10:18 AM (Eastern Standard Time, UTC-05:00) by Hernan Garcia #    Comments [0] - Trackback
Frameworks | Programming
# Sunday, December 23, 2007

I have been reading a lot about how this framework will better be used in brand new developments. I agree that you won't migrate an existing site to this framework if the existing site is working, but I'm worry that we are missing another opportunity to use this framework and that is leverage existing models an business logic.

Most examples keep using LINQ TO SQL to generate the model from scratch and that may give the false impression that you need to generate the model that way.
I will show how to use an existing model with the MVC, in this case a DooDads DAL.

Notice that the only difference between this and my last post is that the project doesn't have any files under the model folder, I'm actually using those files to create the dll for the DAL.

I just added  a reference to the classes that I need to consume my model from.

 

At this point all the controller classes will have access to my model.

using System;
using System.Web;
using System.Web.Mvc;
using LaTrompa.Dal;
using MyGeneration.dOOdads;

namespace MvcDemo2.Controllers
{
public class MovieController : Controller
{

[ControllerAction]
public void List()
{
Movies movieList = new Movies();
movieList.LoadAll();
MovieViewData customViewData = new MovieViewData();
customViewData.MovieList = movieList;
RenderView("List", customViewData);
}
}

public class MovieViewData
{
public Movies MovieList { get; set; }
}
}

I think that this is a really cool application for the MVC framework, imagine how fast you can implement a web front end leveraging existing Model and Business objects, maybe used by a desktop app.

And further on, this objects don't even need to connect to a MSSQL database, they can point to whatever db your layer support.

kick it on DotNetKicks.com Sunday, December 23, 2007 2:50:21 PM (Eastern Standard Time, UTC-05:00) by Hernan Garcia #    Comments [0] - Trackback
Frameworks | Patterns | Programming

I have been using DooDads, a free, open source ORM architecture for a while now. I like that I can easily use it with any database structure, not matter how bad is it.

When I come across such designs DooDads is the tool that allows me to create a layer of abstraction pretty fast into the application, that will later on allow me to make changes and refactor the database with minimal impact in the upper layers.

I'm also a sucker for the MVC pattern and I downloaded as soon as was avalable, I have been playing around with it and one of the things I wanted to do was test it's extensibility using my favorite ORM tool.

Setting things up.

So I fired up VS and create a new MVC application.

I create a db with one table and I call it Movies.

I open MyGeneration and generate the code for the business entity for the table and the Stored Procedures that the object will use.

DooDads Stored Procedures

 

 

The Model.

Then I added the code into the Model folder in the solution opened in Visual Studio 2008 and create the concrete class for the Movie object, Doodads generated code use abstract classes.

Model classes in the MVC project

 

I like to separated the generated code from my implementation using two different folders but you don't need to do so if you don't want. I think that is easier to maintain this way.

 

My next step was to modify the menu to create a Movies item, so I opened the master page and added the following line.

<ul>
<li><a runat="server" href="~/">Home</a></li>
<li><%= Html.ActionLink("Movies", "List", "Movie") %></li>
<li><%= Html.ActionLink("About Us", "About", "Home") %></li>
</ul>

 You will need to add the connection string as and appSetting in the web.config for Doodads to pick it up. The key should be dbConnection.

 

<appsettings>
<add value="Data Source=SERVERNAME;Initial Catalog=DATABASE;Integrated Security=True" key="dbConnection"></add>
</appsettings>

 

The Controller.

Them I added a reference to MyGeneration.Doodads.dll and them create a new Controller class named MovieController

 

The code for this class is very simple. I added the using statement for the namespace of my Model classes and I create a custom ViewData object using the new simpler properties. Declaring the type of the property will give me a strongly typed ViewData in the View.

using System;
using System.Web;
using System.Web.Mvc;
using LaTrompa.Dal;

namespace MvcApplication1.Controllers
{
public class MovieController : Controller
{
[ControllerAction]
public void List()
{
Movies movieSelection = new Movies();
movieSelection.LoadAll();
MoviesViewData customViewData = new MoviesViewData();
customViewData.MovieList = movieSelection;

RenderView("Movie", customViewData);
}
}

public class MoviesViewData
{
public Movies MovieList { get; set; }
}

}

 

The View.

 

I created a folder called Movie under View and inside a Movie page (I made this page of the MVC Content page type to use the same master page).

 

 

I added a using for the controllers namespace and set the type of the ViewPage<T> object to my custom viewdata object.

using System;
using System.Web;
using System.Web.Mvc;
using MvcApplication1.Controllers;

namespace MvcApplication1.Views.Home
{
public partial class Movies : ViewPage<moviesviewdata>
{

}
}

 I them opened the aspx page and added the following.

<%while (!ViewData.MovieList.EOF)
{
%>
<h2><%= ViewData.MovieList.Title%></h2>
<p><%=ViewData.MovieList.Description%></p>
<%= Html.ActionLink(ViewData.MovieList.Category, "List", "Category")%>
<%
ViewData.MovieList.MoveNext();
}
%>

 

And that is all you need, in a future article I will consume the Model as a precompiled assembly and I will demostrate how to use a webservice as a model.

 

kick it on DotNetKicks.com Sunday, December 23, 2007 2:44:41 AM (Eastern Standard Time, UTC-05:00) by Hernan Garcia #    Comments [0] - Trackback
Frameworks | Patterns | Programming
# Tuesday, December 11, 2007

The CTP release of the Microsoft MVC framework is available with the ASP.NET 3.5 extensions.

Scott Hanselman has a post on this release so does Scott Gu, don't miss the 40 minutes video on Hanselman's, it's a quick introduction to the MVC framework and is worthy even if you already saw the original presentation at Alt.Net that started it all.

I didn't download it yet, since the machines I have at home at this moment don't have VS 2008 but I will do first thing tomorrow morning. There is an extra download for the MVC framework with html helpers and data support (not sure what is in it).

I can't be more exited about it.

kick it on DotNetKicks.com Tuesday, December 11, 2007 2:27:41 AM (Eastern Standard Time, UTC-05:00) by Hernan Garcia #    Comments [0] - Trackback
Frameworks | Patterns | Programming | Testing
# Saturday, December 08, 2007

I just came across this: http://labs.live.com/volta/.

I haven't downloaded or anything but my first impression is that this try to be some kind of AIR. It's not exactly the same, but the idea, according with my limited understading, is that you program an application using any .NET language and them you can compile the application targeting different architectures. The client side always run on a JScript interpreter, most of the time that will be a browser.

I tried some of the examples and the load time seems to be a little too much for my taste. Upon looking at the Net tab in Firebug, a simple Ajax dictionary download 2.67 Mg of code mostly JavaScript files that map into .net classes, but that is not the worst part, the really bad thing is that it do this making 175 individual httpRequest!!!!

To be fair this is just a Technology Preview and I'm sure that they may work on some of this issues. This came out just two days ago, so I encourage you all to download it and give a try to learn more, I know I will do that.

kick it on DotNetKicks.com Saturday, December 08, 2007 12:33:11 AM (Eastern Standard Time, UTC-05:00) by Hernan Garcia #    Comments [0] - Trackback
Frameworks | General
# Friday, December 07, 2007

Yesterday Scott Gu post again about the MVC framework. Don't miss his post about Passing View data from controllers to view.

There was some talk about the release date being this week, but that wont be the case. I think that is just fair to tell that we are all waiting for it. I just want to get my hands on the code, and have an old asp classic site that can be a great candidate to migrate using the framework.

kick it on DotNetKicks.com Friday, December 07, 2007 11:06:37 PM (Eastern Standard Time, UTC-05:00) by Hernan Garcia #    Comments [0] - Trackback
Frameworks | Patterns | Programming
# Saturday, October 13, 2007

In the altnet conference the guys from Microsoft presented an MVC framework that will be released on the spring.

It promise to be something really good, it's seems to be so flexible that you can plug into it whatever framework you are used to do, for example, Nunit of MBunit for testing, Spring for DI or NVelocity as your template engine. The framework comes with all this already implemented but they don't force you to use their implementation if you don't want to.

Visit Scot Hanselman's blog for two videos where ScottGu and Hanselman himself demo the framework and right some code. Hanselman does his presentation using IronPython and shows an alternative view engine.

You will need at least two hours of quiet to really enjoy this presentations but they totally deserve it.

 

kick it on DotNetKicks.com Friday, October 12, 2007 11:58:39 PM (Eastern Standard Time, UTC-05:00) by Hernan Garcia #    Comments [0] - Trackback
Frameworks | Patterns
Add The Dynamic Programmer Mippin widget
Navigation
Archive
<March 2010>
SunMonTueWedThuFriSat
28123456
78910111213
14151617181920
21222324252627
28293031123
45678910
What I'm reading
Shelfari: Book reviews on your book blog
About the author/Disclaimer
Hernan Garcia I have been a software developer for the last 16 years or so.
I was a journalist before and I still consider myself one.
Besides baseball, programming is my other big passion.

Me on twitter. @TheProgrammer
Certified Scrum Master
© Copyright 2010
Hernan Garcia
Sign In
Statistics
Total Posts: 197
This Year: 15
This Month: 1
This Week: 0
Comments: 70
Themes
Pick a theme:
All Content © 2010, Hernan Garcia