Sunday, 19 June 2011

Ouch - abandon project?

Maybe not but suspend in favour of something more important? Certainly yes.

Saturday, 18 June 2011

New nUnit Test style; Assert.That

New (actually quite old by now) NUnit test style reads far more fluently than the old one. It is more verbose by I greatly prefer it.


[TestFixture]
public class HelloWorld {
[Test]
public void Should_say_hello() {
Assert.That("Hello World",
Is.EqualTo( new Welcomer().SayHello() ));
}
}

MVC 2 features.

Strongly types helpers

MVC1 : Html.TextBox("Name");
MVC2 : Html.EditorFor(person => person.Name);

With MVC1 there is no way to check the syntax of the model properties such as Name. One would have to type it twice like so: Html.TextBox("Name", Model.Name); for a strongly typed view.

Data Annotations.

[StringLength (25, ErrorMessage = "Invalid Length")]
public string Name { get; set; }

Annotations such as this, are explicit constraints in the model itself. Validation is simpler because most validations can be such data annotations.

Templated Views. TODO
Areas. TODO
Asynchronous Controllers. TODO
Html.RenderAction() TODO


Why prefer ASP.NET MVC over Web Forms?

  1. Simple html ids are available with web forms, without the mysterious $ prefixes. These simpler tags are easier to use with JavaScript
  2. The page life-cycle is much simpler. It's just http request-response. The web forms page event cycle is no longer there.
  3. Code behind files are no more. It's easier to properly model the problem with code.
  4. URLs are easier to control, making it easy for users to bookmark pages.
  5. No more oblique web forms with its server controls page events, viewstate, messy html.
  6. Much easier to write simple JavaScript and Ajax
  7. Far easier to test.

Reading Jonathan McCracken's Test-Drive ASP.NET MVC2

Rereading this determined to do it properly. [Writing all the missing tests, etc. Doing the persistence with nHibernate 3, and so forth.]

Taking notes from now on - only for me!

Stranger: - if you come here and accidently read this - too bad if it doesn't make sense because it's only here for my benefit.