ReSharper, The Better Way, Is it Readable?

While working through some client application services samples recently I was going through and doing a code review, of myself, to see how or were I might be causing myself duplication, have isolation issues, or am not testing something correctly.  As I went through I found this little nugget of curiosity.  The code started out like this:

   1:          public ClientFormsAuthenticationCredentials GetCredentials()
   2:          {
   3:              if (ShowDialog() == DialogResult.OK)
   4:              {
   5:                  return new ClientFormsAuthenticationCredentials(
   6:                      usernameTextBox.Text, passwordTextBox.Text,
   7:                      rememberMeCheckBox.Checked);
   8:              }
   9:              else
  10:              {
  11:                  return null;
  12:              }
  13:          }

The “If” in the statement above had the little straight line under it that ReSharper signifies it thinks you should change something.  I then hit Alt-Enter for the ResSharper menu to pop up.  It did and gave me an option for “Replace with ‘return’” and also a “Convert to ‘switch’ statement”.  I decided I’d select the first option, since it was given as the default option, and received the conversion below:

   1:          public ClientFormsAuthenticationCredentials GetCredentials()
   2:          {
   3:              return ShowDialog() == DialogResult.OK ? new ClientFormsAuthenticationCredentials(
   4:                                                           usernameTextBox.Text, passwordTextBox.Text,
   5:                                                           rememberMeCheckBox.Checked) : null;
   6:          }

There are a few things of note in the code.  First off, there are 7 less lines used.  Second, it doesn’t really seem to be easier to read nor does it layout exactly what is going on.  It almost seems to work against behavior driven development principles.  Last thing I noticed right off is that the formatting, lines, and spacing aren’t to my liking, and I fixed that by hitting a new line at the “new” keyword, did ReSharper’s cleanup code option and got this:

   1:          public ClientFormsAuthenticationCredentials GetCredentials()
   2:          {
   3:              return ShowDialog() == DialogResult.OK
   4:                         ?
   5:                             new ClientFormsAuthenticationCredentials(
   6:                                 usernameTextBox.Text, passwordTextBox.Text,
   7:                                 rememberMeCheckBox.Checked)
   8:                         : null;
   9:          }

Now we’re back up to 9 lines of code, not like the line count matters.  The second point though, is that it is a little easier to read.  The formatting was also a little bit better.  Overall though, I’m still not sure this is easier to read than the if then else statement above.  One thing I was curious about though, and haven’t checked into further, is what this will compile to.  Does the CLR actually end up with the same compiled code?  At some point I might dig it apart, but for now I know the later examples are the suggested way to do this now, and it does remove code that is redundant (such as the “else” keyword in the first code snippet above).  For now I’ve grown a bit more used to reading the later two examples, but they still just don’t jump out to explain what is going on.

Anybody else have an opinion on these three variances?  Got a favorite?

Blogroll is NOT in the Database w/ BlogEngine.NET

ARRrrrrrrrrrrrrrrrrrrrrrrrrrrrrrGHGHGHGG!

I realized after doing a full push to my host again, that my blog roll is decimated!  Obviously BlogEngine.NET, even when setup to run against a database, doesn’t run the blog roll against the database.

So you’ve been warned BlogEngine.NET users!

Meanwhile, I’m going to work on getting that list re-created again.  Ugh.

…and yeah, I should keep a backup, and I do of the database, but just not that stuff.

Code Paste Add In for Windows Live Writer

UPDATED 10/25/2008 Code Sections Formatting Fixed With CSS

What I’m using is available Plugin Collection for Windows Live Writer on Codeplex.  This comes in real useful when getting code into a blog entry.  Because straight pasting really doesn’t do so well for readability.

So here are my test code pastes.  A basic view in C#.

   1:  using System;
   2:  using System.ComponentModel;
   3:  using System.Windows.Forms;
   4:  using Microsoft.Practices.Unity;
   5:  using Tsr.SeatingSystem.Controller;
   6:  using Tsr.SeatingSystem.Controller.Views;
   7:  using Tsr.SeatingSystem.WinForm.Properties;
   8:  using Tsr.SeatingSystem.WinForm.Seating;
   9:
  10:  namespace Tsr.SeatingSystem.WinForm
  11:  {
  12:      public partial class SeatingSystemMainView : Form, ISeatingSystemMainView
  13:      {
  14:          private TsrController controller;
  15:
  16:          public SeatingSystemMainView()
  17:          {
  18:              InitializeComponent();
  19:              Icon = Resources.Clock;
  20:          }
  21:
  22:          [Dependency]
  23:          public TsrController Controller
  24:          {
  25:              get { return controller; }
  26:              set
  27:              {
  28:                  controller = value;
  29:                  controller.SetSeatingSystemMainView(this);
  30:              }
  31:          }
  32:
  33:          #region View Events & Raise Events
  34:
  35:          public event EventHandler SeatingSystemMainView_Load;
  36:          public event EventHandler ExitToolStripMenuItem_Click;
  37:          public event EventHandler TicketingToolStripMenuItem_Click;
  38:          public event EventHandler SeatingToolStripMenuItem_Click;
  39:          public event EventHandler ReservationsToolStripMenuItem_Click;
  40:          public event EventHandler OptionsToolStripMenuItem_Click;
  41:          public event EventHandler AboutToolStripMenuItem_Click;
  42:          public event PropertyChangedEventHandler PropertyChanged;

Some basic SQL.

   1:  /****** Object:  View [dbo].[tmtUserListing]    Script Date: 07/06/2008 01:27:11 ******/
   2:  IF  EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[tmtUserListing]'))
   3:  DROP VIEW [dbo].[tmtUserListing]
   4:  GO
   5:  /****** Object:  View [dbo].[tmtUserListing]    Script Date: 07/06/2008 01:27:11 ******/
   6:  SET ANSI_NULLS ON
   7:  GO
   8:  SET QUOTED_IDENTIFIER ON
   9:  GO
  10:  IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[tmtUserListing]'))
  11:  EXEC dbo.sp_executesql @statement = N'CREATE VIEW dbo.tmtUserListing
  12:  AS
  13:  SELECT     dbo.tmtUsers.UserId, GrandCentral.dbo.aspnet_Users.UserName
  14:  FROM         dbo.tmtUsers LEFT OUTER JOIN
  15:                        GrandCentral.dbo.aspnet_Users ON dbo.tmtUsers.UserId = GrandCentral.dbo.aspnet_Users.UserId
  16:  '
  17:  GO

Some XAML (Which technically isn’t on the list, but I formatted it via HTML)

   1:  <UserControl x:Class="SecurityAdministratorWpf.Login"
   2:      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
   3:      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
   4:      Height="225" Width="410">
   5:      <Grid>
   6:          <Button Height="23"
   7:                  HorizontalAlignment="Right"
   8:                  Margin="0,0,28,15"
   9:                  Name="buttonLogin"
  10:                  VerticalAlignment="Bottom"
  11:                  Width="75"
  12:                  ToolTip="Click to login.">Login</Button>
  13:      </Grid>
  14:  </UserControl>

Some HTML

   1:  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
   2:  <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
   3:  <head runat="server">
   4:      <link rel="stylesheet" href="default.css" type="text/css" />
   5:      <link rel="shortcut icon" href="~/pics/blogengine.ico" type="image/x-icon" />
   6:  </head>
   7:  <body>
   8:      <form id="Form1" runat="server">
   9:      <div class="outerouter">
  10:          <div class="outer-container">
  11:              <div class="inner-container">
  12:                  <div class="header">
  13:                      <div class="title">
  14:                          <div class="sitename">
  15:                              <a href="~/" runat="server">
  16:                                  <%=BlogSettings.Instance.Name %></a></div>
  17:                          <div class="sitenameshadow">
  18:                              <%=BlogSettings.Instance.Name %></div>
  19:                          <div class="slogan">
  20:                              <%=BlogSettings.Instance.Description %></div>
  21:                      </div>
  22:                  </div>
  23:                  <div class="path">
  24:                      <div class="left">
  25:                          <ul>
  26:                              <li>
  27:                                  <asp:HyperLink ID="HlHome" NavigateUrl="~/default.aspx" runat="server">Home</asp:HyperLink></li>
  28:                              <li class="page_item">
  29:                                  <asp:HyperLink ID="HlArchive" NavigateUrl="~/archive.aspx" runat="server">Archive</asp:HyperLink></li>
  30:                              <li class="page_item">
  31:                                  <asp:HyperLink ID="hlContact" NavigateUrl="~/contact.aspx" runat="server">Cont
act</asp:HyperLink></li>
  32:                          </ul>
  33:                      </div>
  34:                      <div class="right">
  35:                          <a href="<%=Utils.FeedUrl %>">Subscribe to My Feed<asp:Image ID="RssIconImage1" runat="Server"
  36:                              Width="24px" Height="24px" AlternateText="RSS Feed" ImageAlign="AbsMiddle" Style="margin: 0 0 0 10px" /></a>
  37:                      </div>
  38:                      <div class="clearer">
  39:                      </div>
  40:                  </div>
  41:                  <% if (Page.User.Identity.IsAuthenticated)
  42:                     { %>
  43:                  <div class="adminpath">
  44:                      <h2>
  45:                          Admin:</h2>
  46:                      <uc1:menu ID="Menu1" runat="server" />
  47:                  </div>
  48:                  <%} %>
  49:                  <div class="main">
  50:                      <div class="content">
  51:                          <asp:ContentPlaceHolder ID="cphBody" runat="server" />
  52:                      </div>
  53:                      <div class="navigation">
  54:                          <blog:SearchOnSearch ID="SearchOnSearch1" runat="server" MaxResults="3" Headline="You searched for"
  55:                              Text="Here are some results for the search term on this website" />
  56:                          <div class="block">
  57:                              <h2>
  58:                                  Search</h2>
  59:                              <blog:SearchBox ID="SearchBox1" runat="server" />
  60:                          </div>
  61:                          <div class="block">
  62:                              <h2>
  63:                                  Tags</h2>
  64:                              <blog:TagCloud ID="TagCloud1" runat="server" />
  65:                          </div>
  66:                          <div class="block">
  67:                              <h2>
  68:
       Categories</h2>
  69:                              <blog:CategoryList ID="CategoryList1" ShowRssIcon="true" runat="Server" />
  70:                          </div>
  71:                          <div class="block">
  72:                              <h2>
  73:                                  Archive</h2>
  74:                              <blog:MonthList ID="MonthList1" runat="Server" />
  75:                          </div>
  76:                          <div class="block">
  77:                              <h2>
  78:                                  Blogroll</h2>
  79:                              <blog:Blogroll ID="Blogroll1" runat="server" />
  80:                          </div>
  81:                          <div class="block">
  82:                              <h2>
  83:                                  Disclaimer</h2>
  84:                              <p>
  85:                                  The opinions expressed herein are my own personal opinions and do not represent
  86:                                  my employer's view in anyway.</p>
  87:                              <p>
  88:                                  &copy; Copyright
  89:                                  <%=DateTime.Now.Year %></p>
  90:                          </div>
  91:                      </div>
  92:                      <div class="clearer">
  93:                          &nbsp;</div>
  94:                  </div>
  95:                  <div class="footer">
  96:                      <div class="left">
  97:                          <div>
  98:                              Powered by <a href="http://www.dotnetblogengine.net/" target="_blank">BlogEngine.NET</a>
  99:                              <%=BlogSettings.Instance.Version() %>
 100:                              | Design by <a href="http://michael.sivers.co.uk">Michael Sivers</a>
 101:                          </div>
 102:                      </div>
 103:                      <div class="right">
 104:                          <asp:LoginStatus ID="LoginStatus1" runat="Server" LoginText="Sign in" LogoutText="Sign out"
 105:                              EnableViewState="false" />
 106:                      </div
>
 107:                      <div class="clearer">
 108:                      </div>
 109:                  </div>
 110:              </div>
 111:          </div>
 112:      </div>
 113:      </form>
 114:  </body>
 115:  </html>

Open Beer/Coffee Days and Awesome Geek Discussion

Ben Strackany has been putting on Open Beer and Open Coffee days over the last half dozen or so months.  I often try to attend because these events have great tech talk and other topics of discussion.  I suppose that always happens when you get smart people together for caffeine or beers.

I’m aiming to attend the next Open Beer day at The Green Dragon so make a point to head out and say hello.  I’m always looking to meet new people out there in Portland and see what everyone is up to.

Open Beer Day Thursday, October 9th, at 5pm The Green Dragon 928 SE 9th Ave.

View Larger Map

Open Coffee Day Last Wednesday of Every Month at 10am Backspace 115 NW 5th Ave

View Larger Map

Coffee or beer, you gotta like one, so come down and meet us, show us what you’re working on and who knows, maybe we’ll just invent the next big thing.

Interview w/ Umpqua, Review of Banking Web Sites

I spoke with the Umpqua Bank Web Development Team day before yesterday for an interview.  It was fun talking to the crew over there and discussing what they’ve been working on.  It sounds like a lot of things are afoot at the Umpqua.  One of the things speaking with them has led me to do was to really check out further the Umpqua Web Experience and do a little comparison check.

First off, take a look at the clean design, right front and center, of their web site.

Now take a look at Bank of America, Citigroup, and US Bank.

First off, I can honestly say Generation X & Generation Y will most likely find the Umpqua Site far superior in first appearance than any of the other sites.  Let me review real quick why.

The Bank of Americasite comes up, with the entire thing shifted to the left, and forced to a set pixel width.  The pixel width is fine, except on modern machines that have decent resolution, it gets really weird.  The big problem though, is the fact that one’s eyes actually TURN to see were on the page the site has been painted.  Not front and center were it should be, but off to the left.  This I find nuts that anybody still does this.  On an Intranet Site it would be acceptable, but online, “very not cool”.

I rarely have anything negative to say about BOA but their current site definitely needs an update – SOON.

The second site, from Citigroup, definitely comes up front and center on any browser I use.  There is one slight problem for Gen X & Gen Y though.  Their site immediately makes you think of some big wormy corporation or being accosted by a suit attempting to sell you a car.  Nice site, nice layout, wrong first impression, especially being that it is NOT the first impression Citi has been working years to achieve.  Somehow they continue to miss the mark.

The US BankSite is just rough.  It looks very dated, hangs to the left, has an odd initial login section on the side that people do NOT trace with their eyes first, and overall is just laid out poorly.  There is too much activity on the site and…  ok, I’m done, this site is just going to frustrate me.  This is the type of site that Gen X & Y don’t prefer, and anyone not in those groups usually gets overwhelmed by the busy nature of the layout.  I personally wouldn’t have kept it open this long except I’m reviewing the page design.

So back to Umpqua.  First I’ll hit on the very minor negatives, there aren’t many to start with.  The site has good colors, but doesn’t quit scale right to bigger screens.  Being this is the only site of those mentioned that even attempts to handle some scaling in a minor way, I’m impressed.  The second thing is the square corners, it is dumb to say this, but rounded corners are easier on the eyes and more oriented toward the whole web 2.0 ideal.  It’s a minor thing, but it does differentiate and it absolutely makes a difference in the long term.  Yeah, I know, here I am arguing for rounded corners.  Never thought I’d be blogging about such a thing, but I stand by it.  Rounded corners are cool and important to layout.

Now for the good parts.  The Umpqua Site has good white space, the type that allows you to actually see the focal points of the page.  The white space allows you to see the priority sections also.  The colors that surround some words, the other background behind the white space, and the lower “Umpqua Extras” section has colors that do not clash, and help to bring a slightly more focused look at some of the other priority spaces without drawing you away from the important market spaces for “e-switch to Umpqua”, “LocalSpace”, and “earn cash back”.  The sign in section is fairly easy to find, being bolded and colored with a bluish off tone.

Overall the site looks great, is easy on the eyes, doesn’t cause one to look it over in an unnatural way, is easy on the eyes, and above all, attracts new users to were they should look and provides an easy to find area for returning users.

I rate it A+ for bank web site!