Tag: grails

ASP.NET MVC, good or bad?

Posted by – March 15, 2008

I have been listening some screencasts about ASP.NET MVC, at first moment we can see few features found on the other web frameworks like Grails and RoR, the controllers are very easy to write and all controllers actions can be bind easily on your view code by using helper methods.

The default view engine of ASP.NET MVC is terrible, remembers the way that we wrote some ASP and PHP pages in the past, if you need more control over page rendering you must place some conditional statements there, take a look on the code block below:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<form action="/App/InsertCustomer">
  <% if (ViewData.ErrorMessage != null) { %>
    The following error occurred while inserting the customer data:
    <br />
    <%= ViewData.ErrorMessage %>
    <br />
  <% } %>

  First name: <input type="text" name="firstName"
      value="<%= ViewData.FirstName %>" /><br />
  Last name: <input type="text" name="lastName"
      value="<%= ViewData.LastName %>"  /><br />

    <input type="submit" value="Insert" />
</form>

Note the presence of ASP tags <%= somecode %>, this kind of web page code can be very easy to understand on small pages, but if your pages start to be bigger and bigger you will have some problems with code readability, I don’t like this kind of view coding, it can turn into a nightmare.

But, in other hand, you can put all this mix of markup and C#/VB code into an ASP.NET user control, separating small pieces of reusable code into .ascx files, with this approach you can reduce the amount of non markup code into your page and all page rendering logic will be a little more easier to understand.

Share

Groovy and Rails = Grails

Posted by – February 28, 2008

I started my study about grails few weeks ago, grails is a rad framework, very similar to Ruby on Rails but with a lot of nice features, one of them is the builtin support for rest webservice, you just need create your domain and controller classes, start the application and then you can submit your xml over GET, POST, PUT and DELETE methods! Very easy and handy!

You only need type these command on command line window:

grails create-app restservice

grails create-domain-class Person

grails create-controller Person

Now you must edit Person.groovy at restservice/grails-app/domain folder and then add Person class properties like below:
More

Share