chris carter's web log

Home |  Contact |  Admin
 

ASP.NET MVC(Preview 4): Initial Thoughts

Posted on July 30, 2008      0 Comment(s)

Overall

I've spent the last few days exploring the MVC offering from Microsoft.  I like it.  Alot.

Remove everything that sucks about webforms, which is pretty much everything, but more specifically, the page and control lifecycles, and you have ASP.NET MVC. Well, Microsoft MonoRail really.

Brail

I started with the Brail ViewEngine  from the MvcContrib project.  I was impressed with how it was identical in usage as compared to the actual MonoRail flavor.  However, I noted that ViewComponentswere not implemented for whatever reason.  I find them very useful in MonoRail, so I'm not sure they were left out intentionally or not, but after too many yellow screens of death I bailed and went to the out of the box stuff.

Out Of The Box

The out of the box stuff is pretty good.  I don't like the casting that has to take place when requesting things out of the ViewData dictionary.  The runtime should be doing this for us, the Brail ViewEngine does this, the out of the box ViewEngine(what the hell is that called anyway?) should as well.  Maybe that's on the radar for the MVC team.

Source Code

I'm glad they posted the source code.  There some things that were hard to figure out[without documentation], like how to create your own helper class that were difficult without the source code to refererence.  And creating the helper class wasn't the hard part, getting the ViewContext was the hard part(in hind site, not hard at all).

Add New Item

When you add a new item like an MVC View Page, MVC View Content Page, or MVC MVC View User Control, it automatically adds the .aspx(or .ascx) fle, as well as the code behind file and designer file.  This is a little annoying being that I'm not seeing why they're included as they are not needed.  In the .aspx(or .ascx) file, you can set the inherits attribute to either the ViewUserControl or ViewPage, and that's good enough for the ViewEngine.

Html Should Be Simple

 Webforms made html complicated.  ASP.NET MVC is bringing back the simplicity.  If you've ever stepped into System.Web, and viewed the source code for MVC, you'll see a HUGE difference in the amount of code needed to produce simple html.

More to come on MVC...

Html on CodePlex

Posted on July 30, 2008      1 Comment(s)

I finally got around to posting my Html project on codeplex.

Visual Search: aga-kids.com

Posted on July 29, 2008      0 Comment(s)

Natali commented on this post about a visual search engine for kids.  It's not exactly a visual search in terms of searching by image, but search results are all visual.  Check it out, it's really pretty cool.

firefox.exe vs. devenv.exe

Posted on July 29, 2008      1 Comment(s)

On the surface it looks like the devenv.exe's are in the lead. But I bet if i leave my instance of firefox open, by tomorrow those results will be different.

Cannabis Sativa, or How I Spent My Sunday

Posted on July 28, 2008      0 Comment(s)

Although I don't smoke the stuff, my clothes reek of it; even my camera has that smell. 

Music

Last night was Cruefest, and Motley Crue rocked!  Vince Neil sounded incredible. 

Shout at the Devil amazing, check out the video we took(it's not great cuz it's dark, but the sound is pretty good).  And a little snip of a guitar solo thing here.

I did find out that apparently I'm not a fan of Buckcherry or Papa Roach.  Just not my kind of music.  Here's a vid of Papa Roach.

Parking

I have never been to Fiddlers Green before but it's a good place to hear music, great sound.  However, we got to the show early enough to hit up a bar.  When we pulled into the parking lot some guy asked for 20 bucks to park there.  I flipped, dropped a "Are you f*cking kidding?" and he said, "Ok, how bout 15".... long story short, i said i'm going to a bar so i'm parking here and not paying.  He said fine, just don't go to the concert.  Ya, we went to the bar for one drink, then went to the concert. 

Beer

Wow, how beer prices have increased.  OMG, 9 bucks for a Miller Genuine Draft.  Those guys must rake in cash hand over fist.

Mullets Mullets Everywhere

Here's what was in front of us:

Dorks

Visual Search

Posted on July 28, 2008      1 Comment(s)

Interesting search idea at like.com.  You click on the visual search button, and draw a rectangle on an area of the product and then search for similar items based on shape or color of whatever is inside the rectangle you drew.  I'm not sure how accurate the search is, but it's nice to see attempts at changing and/or improving the way we look for things. 

I wish they had something similar for music, you know, when you can't remember the name of a song but you know the melody, a search engine could give close matches for that melody...

Iris Syntax Highlighter

Posted on July 27, 2008      0 Comment(s)

I found this cool syntax highlighter Iris yesterday.  Not sure how I missed this one in my quest for syntax highlighters.  I've used Wilco Bauwer's(as of the time of this posting, Wilco's site was having some issues) tools which are cool,and squishyware was cool too.

At some point yesterday, I clicked into this blog post by Gustavo Duarte.  The post had nothing to do with syntax highlighting but after poking around the site I noticed Iris was one Gustavo's projects so I checked it out.  It totally trumps the other two highlighters I was using so I integrated it last night into my blog software.  Since I highlight code on the fly, all of my code examples have picked up the new flavor of highlighting.

I like how it separates the line numbers from the code, that way when you select the code you don't get the line numbers too.

Here's some SQL:

select first_name, last_name
from customer
where last_name like 'c%'
1
2
3

And Html:

<table>
  <thead>
    <tr>
      <th>First Name</th>
      <th>Last Name</th>
    </tr>
  </thead>
</table>
1
2
3
4
5
6
7
8

And of course C#:

public class Customer{
  public int ID{ get; set; }
  public string FirstName{ get; set; }
  public string LastName{ get; set; }
  public void SayHello(string name){
    Console.WriteLine("Hello {0}!", name);
  }
}
1
2
3
4
5
6
7
8

Anyway, it's a cool tool, check it out.  Since I found the tool useful, I made a small donation to the children in Uganda via ICCF Holland per the suggestion by the Iris team.

Terminator Salvation

Posted on July 17, 2008      2 Comment(s)

I just saw a preview of the new Terminator movie due out next summer, holy crapper Batman, Christian Bale is John Connor, how bomb ass is that! Trailer here, they don't show much which is good.

C# Var : The Religious War

Posted on July 14, 2008      1 Comment(s)

OK.  So I had no clue when I posted previously about the C# var keyword that the use of var is a religious war that's going on right now.  I'm not sure where I stand right now, I'd have to say, "it depends". 

I wouldn't use it in my current work, it would confuse other devs not up on the var usage and would unnecessarily complicate things at this time. 

I'm also not sure due to the fact that people far smarter than me are on both sides of the fence, so right now is a good time to sit back and REALLY think before introducing var into my everyday code.

Getting Started With MonoRail and VS2008 Screencast

Posted on July 14, 2008      0 Comment(s)

This is an 11 minute(or so) long screencast demonstrating how to pull down the latest bits from the castle folks and get a monorail project up and running. It goes through configuration and creating a simple controller/view using the build from 7/11/2008 off of the castle build servers.

View It!

Here's the code used for the solution. I've included the bin directory from the castle download, so the project is just over 5 megs.

C# Var

Posted on July 14, 2008      0 Comment(s)

I've been seeing a lot of people posting code examples that have the C# var keyword sprinkled liberally through their code. It's a handy little feature that helps you with LINQ queries, anonymous types, etc. For example, you can create a new type on the fly like this:

var person = new { Name = "Chris" };
Console.WriteLine(person.Name);
1
2

Not everyone reads from left to right, but I do, as does every single person who works with me and every single blog and code example I've ever seen. This is important when considering the liberal use of var because now one would have read a whole line of code and figure out the type for themselves, rather than just reading the first word on the line(if declaring a local variable).

Look at the following snippet:

var bus = FacilityConfig.Children["bus"];
if (bus == null)
  throw new InvalidOperationException("bus is a mandatory element");
1
2
3

What type is bus in the previous example? You would have to hope that you're in visual studio and can hover over it with the mouse pointer so you could see the type which is lame.

The var keyword should be used sparingly, only when the type is unknown, like in a linq query that returns an anonymous type. Using it in situations where you know what the type is makes your code hard to read.

Test First Development Screencast

Posted on July 9, 2008      0 Comment(s)

This is nothing major, and actually producing the screencast was harder than normal.  It's silent so you don't have to hear my awesome voice.  Check it out here: View It!

Simple Forms and Ajax

Posted on July 9, 2008      0 Comment(s)

So, I'm not seeing any good ways of returning a script block that can be executed on the client side.  What i was doing was having a block of javascript validation code below my block of html form elements.  I couldn't get this working, it may just not be possible, I'll try again later.  However, you can put all of the javascript you need into the onclick event of a button.  So trying that, I now have this, which isn't pretty, but my intentions are that the form would be autogenerated anyway, so I don't think I'll care about how pretty it is.

<form>
	<table>
		<tr>
			<td>
				<label>
					First Name:</label>
			</td>
			<td>
				<input type="text" id="FirstName" />
			</td>
		</tr>
		<tr>
			<td>&nbsp;</td>
			<td>
				<input type="button" value="Save" onclick="
				if($('FirstName').value.length == 0){
					alert('First Name is required!');
					$('FirstName').activate();
					return false;
				};
				" />
			</td>
		</tr>
	</table>
</form>
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

Simple Forms

Posted on July 8, 2008      0 Comment(s)

My forms need to be simple.  Can you tell I'm talking this one out? I have some really good ideas, and some mediocre solutions so far.

The area of a form to concentrate on is just the middle contents of a page.  The type of target application is a business application, so there will be a lot of standard things we can do, think Microsoft CRM sort of(and I'm really sick of that flavor of blue we stole from the CRM follks). 

The look and feel needs to be super easy to swap out, not just the stylesheets, but the layout as well.  Not sure if this is a pipe dream, but I think it's doable.

Faster Forms

Posted on July 8, 2008      0 Comment(s)

How do you build forms?  We are tasked with building a toolkit that's pretty framework agnostic, meaning it should work in asp.net webforms, asp.net mvc, castle monorail, or any other framework.  It needs to only be tied to html, meaning all it does is generate the html for a form that has nothing to do with any framework. 

Whatever "it" is,  needs to generate forms, in an intelligent way, not just CRUD forms that have no life.  By intelligent, I mean they need to fit the destination application in look, feel and behavior, and they are not generic in any way shape or form, other than that they have to fit most of the cases for the destination application. 

How fast can you build forms? And by speed I mean, what's the least amount of code you can write to get no less than 100% of the desired form functionality.  This includes any field validation, etc.