Microsoft Rant

[Rant On]

I’m very much pro standards.  I’m pro rail standards, I’m pro road standards, I dig web standards and browser standards, and I enjoy security standards and all sorts of standards.

Now, when there are standards and some entity ignores the standards it really pisses me off.  Recently I’m trying to download various WCF Projects from Microsoft and they ask for authentication via one’s passport.  Of course I have that and tried to login with it.  I was using Chrome and it didn’t work.  What makes this even worse is the fact that the little AJAX busy icon came up and I got zilch.  No message, no notification, no communication in any way that the site was stuck.  This is complete crap, and Microsoft should fix this immediately.  I tried a couple months ago and this even happened in IE.  Other problem being I’ve only got this to work in IE sometimes and also in Firefox… sometimes.  Opera it seems to work in consistently, which is odd.

[Rant Off]

Anyway, I’m done ranting now, on to a new topic…   which I have no idea for yet but I am actively researching WCF technology and authentication practices right now.  With that research I’ll definitely have a few blog entries coming down the pipe soon.

Stay Tuned

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.