Thursday, February 07, 2008

Resharper 3.1 Upgrade Issues

I upgraded from Resharper 3.0 to 3.1 today and immediately had some issues. 

Issue #1 - Intellisense was disabled. 

My intellisense was disabled on the Visual Studio level.  To re-enable it, I went to Tools -> Options -> Text Editor -> C#.  In the Statement Completion control grouping, I checked "Auto list members"  to turn it back on.

Issue #2 - Alt+Enter stopped working.

To fix this, just go to Resharper -> Options -> General.  Then select the "Visual Studio" radio button under "Restore Resharper keyboard shortcuts". Then click "Apply"

Here's another handy tip.  Since Resharper won't play nice with the new .NET 3.0+ features until version 4.0, you can temporarily disable/enable it on any open file with the Ctrl+8 keyboard shortcut.

Tuesday, January 15, 2008

CSS Lessons

I just finished re-skinning a website and came across a couple of CSS stumbling blocks that gave me a little trouble.  Hopefully these my save you some time in your future projects.

My first issue has to do with the position style.  Absolute positioning will place an element at the exact pixel location on the page.  However, if the parent element has a position style of "relative", then the absolutely positioned element will use the parent element to determine position, instead of the page itself.

My other issue revolved around the anchor pseudo classes.  If you assign them directly to the "a" element, they will be used by all the anchors on the page, whether you like it or not.  Consider the following CSS styles:

a:link { color: red; }
a:active { color: red; }
a:visited { color: red; }
a:hover { color: green; }

#mydiv a:link { color: blue; }
#mydiv a:active { color: blue; }
#mydiv a:visited { color: blue; }
#mydiv a:hover { color: yellow; }

In this scenario, all the links in mydiv will be red.  To get around this, you need to put identifiers in front of all the "a" styles.

I experienced this behavior in both IE and Firefox. 

Thursday, January 10, 2008

Microsoft AJAX UpdateProgress Control

Today, I learned that the coconut crab is the largest land-living arhropod in the world, Clinophobia is a fear of going to bed, and you can easily cause an animated gif to display while your ASP.NET AJAX Update panel is busy doing a call back. 

It's easy, just use the UpdateProgress Control.  Point it at the update panel and give it something to display and voila!  Here's a code example:

<asp:UpdateProgress ID="updateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel1" DisplayAfter="100" DynamicLayout="true">
<ProgressTemplate>
<div class="Update"><img src="MyAnimated.gif" /></div>
</ProgressTemplate>
</asp:UpdateProgress>

Wednesday, January 09, 2008

Use .NET 3.5 in ASP.NET 2.0

Today, I was able to get an ASP.NET 2.0 application to successfully reference and use a .NET 3.5 dll.  I don't know why this surprised me, but it did.  The dll uses Linq to do some XML parsing among other things.  All I had to do was install the framework on the server.  Sweet!  I may have to rename my site to something like "Frankenstein".  :)

Monday, January 07, 2008

Count things with Linq

I had a situation where I needed to determine how many objects in a generic list were missing a value in a property.  That count was very important to the user.  Basically, I was looking for all the objects in the list that didn't have a value in the path property.  Normally, I would have created a count integer and a loop of some sort and just counted. 

int count = 0;
foreach(Profile p in Profiles)
{
if(String.IsNullOrEmpty(p.Path))
{
count++;
}
}



I could have also used an anonymous delegate, but I was playing with Linq and found this little short cut.



int count = (from p in profiles where String.IsNullOrEmpty(p.Path) select p).Count();



I think that this is much cleaner and easier to read.   Happy Linq'n!

Friday, January 04, 2008

Multiple Using Statements

Using statements are used to define a scope on an object that implements the iDisposable interface.  It automatically calls the Dispose method on the object when it goes out of scope.

Here's a neat little trick to deal with nested using statements.  Consider the following code snippet that has a couple of them:

using (FileStream fs = File.Create("File.txt"))
{
using (TextWriter tw = new StreamWriter(fs))
{
tw.WriteLine("The content of my file!");
}
}



Here's a cleaner, and in my opinion easier, way to write these.  Notice that the FileStream object is useable when creating the TextWriter object.



using (FileStream fs = File.Create("File.txt"))
using (TextWriter tw = new StreamWriter(fs))
{
tw.WriteLine("The content of my file!");
}



If you are instantiating multiple objects of the same type, you could put them all on one line.  It is harder to read this way, but maybe that's just me. ;)



using (StreamWriter tw1 = File.CreateText("W1"), tw2 = File.CreateText("W2"))
{
tw1.WriteLine("The content of my first file!");
tw2.WriteLine("The content of my second file!");
}

Thursday, January 03, 2008

Databinding a Generic List to a WPF ListView

Inevitably there will come a time when you will want to start using the WPF framework for your business apps, and that means that you'll need a grid.  The WPF grid of choice is the ListView control. 

The ListView control is extremely powerful, flexible and customizable.  It's also way complicated!  On the Microsoft campus, in the basement, past the closet where they hide the Steve Balmer bobble-heads and the unused copies of Microsoft BOB, from a darkened cubicle, a developer is laughing at us.

Anyway, there are not a lot of examples of how to programmatically bind a generic list to a ListView control.  So, here's mine.

First let's take a look at the class that we want to add to the collection:

namespace MyNameSpace
{
public class Item
{
public string Description { get; set; }
public string Name { get; set; }

public Item(string name, string description)
{
Name = name;
Description = description;
}
}
}


It's just a simple class with a couple of public accessors.  Now lets turn our attention to the xaml file:




   1:  <Window x:Class="DMG.AnyStream.ProfileEditor.Main"


   2:      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"


   3:      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"


   4:      xmlns:tools="clr-namespace:MyNamespace;assembly=MyAssemblyName"


   5:      Title="Sample Application" Height="600" Width="800">


   6:      <Window.Resources>


   7:          <DataTemplate x:Key="NameHeader">


   8:              <StackPanel Orientation="Horizontal">


   9:                  <TextBlock Margin="10,0,0,0" Text="Name" VerticalAlignment="Center" />


  10:              </StackPanel>


  11:          </DataTemplate>


  12:          <DataTemplate x:Key="NameCell" DataType="Profile">


  13:              <StackPanel Orientation="Horizontal">


  14:                  <TextBlock>


  15:                      <TextBlock.Text>


  16:                          <Binding Path="Name" />


  17:                      </TextBlock.Text>


  18:                  </TextBlock>


  19:              </StackPanel>


  20:          </DataTemplate>


  21:          <DataTemplate x:Key="DescriptionHeader">


  22:              <StackPanel Orientation="Horizontal">


  23:                  <TextBlock Margin="10,0,0,0" Text="Description" VerticalAlignment="Center" />


  24:              </StackPanel>


  25:          </DataTemplate>


  26:          <DataTemplate x:Key="DescriptionCell" DataType="Profile">


  27:              <StackPanel Orientation="Horizontal">


  28:                  <TextBlock>


  29:                      <TextBlock.Text>


  30:                          <Binding Path="Description" />


  31:                      </TextBlock.Text>


  32:                  </TextBlock>


  33:              </StackPanel>


  34:          </DataTemplate>


  35:      </Window.Resources>


  36:      <Grid>


  37:          <ListView Margin="0,22,0,0" Name="lvItems" ItemsSource="{Binding}" 


  38:                    IsSynchronizedWithCurrentItem="True" 


  39:                    SelectionMode="Single" >


  40:              <ListView.View>


  41:                  <GridView>


  42:                      <GridViewColumn Header="Name" HeaderTemplate="{StaticResource NameHeader}" CellTemplate="{DynamicResource NameCell}" Width="200px"  />


  43:                      <GridViewColumn Header="WatchFolderPath" HeaderTemplate="{StaticResource DescriptionHeader}" CellTemplate="{DynamicResource DescriptionCell}" Width="400px" />


  44:                  </GridView>


  45:              </ListView.View>


  46:          </ListView>


  47:      </Grid>


  48:  </Window>


Take a look at line 4. If your class lives in an assembly outside of your WPF project, like mine, then you will need to add this line to declare it to the xaml.



The Windows resources section starts at line six. Here, I'm just defining some templates that will tell the ListView how to present my information.  Without these, the control will show the results from typeof() for each item.  Not good.  Inside the "NameCell" template, I'm just creating a TextBlock control.  There's nothing to stop you from inserting images, checkboxes, radio buttons, etc. Inside the TextBlock, I create a new binding object and give it the name of the public accessor that I want to bind to this column.



The actual ListView control starts down on line 37. Notice the GridView section starting at line 41.  Here is where we define our columns. All we have to do is point to the templates that we created in the Resources section.  You could define them here, but I think that this is cleaner.>



Finally, we need to bind a list to control.  I do that in the code behind for the form:



public partial class Main : Window
{
public Main()
{
List<Item> items = new List<Items>();
items.add(new Item("Item1", "Item1 Description"));
items.add(new Item("Item2", "Item2 Description"));
items.add(new Item("Item3", "Item3 Description"));

lvItems.ItemsSource = profiles;
}
}



It took me forever to figure this out, so I hope that it saves someone some headache and/or chest pains. I know what you are saying, "I only work on web apps."  I understand that this doesn't seem that important right now, but in a recent interview with Redmond Developer News, Scott Guthrie is quoted with:



"When you look at the next public preview of Silverlight that we're doing, all of those features that are core to WPF are built-in, and there's more than just the XAML in common. You can actually take your core UI code, working with controls and databinding and things like that, and use that seamlessly in the Windows app and in the Office app and in the RIA [rich Internet application] app."



How's that for cool?




Wednesday, January 02, 2008

New Year's Resolutions

Happy New Year Kiddies!  Its that time again.  Its time to make a bunch of promises to ourselves in an attempt to justify our shortcomings from the previous year.  That's right, its time to lay down some New Year's Resolutions.  Here are some of mine.  Enjoy!

  1. Gain weight - At least I'm realistic.
  2. Eat at least 2 new animals that I haven't eaten before.
  3. Watch more TV - That one's actually a job requirement.
  4. Learn 2 new programming languages.  Does Linq count?
  5. Build 2 pieces of furniture from scratch.
  6. Project 365 - Take a picture a day for the next year. I set up a Flickr account just for this.
  7. Blog more - Thanks Jeff Atwood.

What empty promises are you making yourself this year?

Thursday, December 06, 2007

XslCompiledTransform - Possible Memory Leak?

I just ran across an issue where the XslCompiledTransform object refused to die.  The code basically had a loop, inside of which a new XslCompiledTransform object was created and "applied" to an xml node.  This meant that for each iteration, I was reading the XSLT into memory. 

You would suspect that the object would go out of scope on the next iteration, or after the completion of the loop, or even after the method returned.  But no!  This wasn't a trivial XSLT file, either, so for every 100 iterations, my application would take on another 300MB of memory.  I was able to crash the app on my 4GB (debatable) machine in a few minutes. 

I know that doing things this way is a definite code smell, and I have learned from my mistake.  The code is now loading the transform in the constructor and using that inside the loop.  Since I'm not having to read in the XSLT all the time, the performance of the app has increased by at least an order of magnitude. 

Maybe Microsoft meant for this to happen, so I wouldn't write crappy code.  Just thought that I would share.  Has anyone else experienced this?

Wednesday, November 28, 2007

DSN Query Analyzer

The new office likes FileMaker...  No, seriously, they actually like it.  And for what they use it for, I don't really blame them. 

It didn't take long before I needed to query some data from one of the FileMaker databases.  Now, there are ways to do this from inside FileMaker, but I just wanted to run a simple query. 

Enter the DSN Query Analyzer.  It is a lightweight query analyzer clone that connects to the DSN connections set up on your machine.  It was written by a guy in the Netherlands.  You can check out his website, if you can speak the language.

One note of importance...  System DSN's do not save login information.  That would be a gigantic security hole.  So when you give the analyzer the name of the DSN to point to, you have to also pass in the login information.  Here is the syntax:

MyDSNName;UIS=username;Pwd=password

Wednesday, November 14, 2007

Sustainable Pace

One of the tenants of Agile development is the concept of "Sustainable Pace".  Let me quote the Agile Manifesto:

"Agile processes promote sustainable development. The sponsors, developers, and users should be able to maintain a constant pace indefinitely."

It turns out that this is just vague enough to leave it open to a wide array of interpretations. 

Many, believe that this means instituting the "40 Hour Work Week", where the team limits the amount of work that it will take on so that no one works more than forty hours per week.  Personally, I think that this is an ideal that is worth working toward, but is usually unachievable in the real world.  Part of "Sustainable Pace" isn't about how much you work, its about the ability to deliver functionality on a regular basis.  Forty hours may not be enough time to pull that off.

I have seen several presenters talk about sprinting and resting.  I like this approach.  Your team would work hard for a few weeks, usually working more than 40 hours in a week, and then have an "off" week.  This doesn't mean that they get a vacation once a month.  It means that they get a week where they aren't 100% committed to the iteration and can spend time on side projects to break the monotony of it all.  Apparently, this works for many teams.  I'd think that you would need a lot of management support for this kind of thing, not to mention the personal discipline to come off the iteration.   It is important that all employees have the time and backing for personal development.  That's the best way for a company to grow in its abilities and increase the value of its employees.

Tuesday, November 13, 2007

Agile Practices That are Usually Valuable

Our team is starting to look at the principles of Agile development and it won't be long before we get into the practices.  So I thought that I would share some of the knowledge that Steve McConnell bestowed upon me in his keynote address at the Microsoft Patterns and Practices Summit last week.

Steve McConnell's company Construx, has generated a report that relays their experiences with Agile practices.  The results not only come from their experience consulting and training clients ("approximately 1000 companies in the past 5 years"), but also from other published industry reports.  Steve presented the report by breaking down the practices into 3 categories:

Agile practices that are usually valuable

  • Short Release Cycles
  • Highly Interactive Release Planning
  • Timebox Development
  • Empowered, Small, Cross-Functional Teams'
  • Involvement of Active Management
  • Coding Standards
  • Frequent Integration and Test
  • Automated Regression Tests
  • Retrospectives at End of Each Release

Agile practices that have been hit or miss

  • Customer-Provided Acceptance Tests
  • Daily Stand-up Meetings
  • Simple Design
  • Test-First Development
  • 40-Hour Work Week

Agile practices that tend to be problematic

  • System Metaphor
  • On-Site Customer
  • Collective Code Ownership
  • Pair Programming
  • Refactoring

I can see at least one practice that my department is trending toward in the "Problematic" list.  This could be "problematic" going forward. :)

Anyway, I encourage you to post your reactions to this list via the comments.  I'd like to know what experiences you guys have had with these practices. Also, if you would like more information about their reasoning for placing a certain practice into a certain category, I'd be happy to oblige.

Monday, November 12, 2007

Microsoft Patterns and Practices Conference - Day Five

The last day of the conference was labeled "Applications".  This, of course, was a pretty loose title.  However, I think that this was one of my favorite days.

Keynote - Scott Hanselman

Hanselman delivers once again.  This wasn't a technology related keynote.  Instead Scott discussed how he came to be employed by Microsoft.  There must have been a lot of money involved. 

Future of patterns & practices - Rick Maguire

Rick is "the man" when it comes to the Pattern's and Practices Group, "the trusted source of application development guidance for the Microsoft platform".  Rick gave a high level overview of where the group was heading in the future.  Here are their goals for the future:

  • Simplify the Microsoft Application Platform
  • Provide solutions/guidance to your problems
  • Help you learn and grow

Evolving Client Architecture - Billy Hollis

Billy Hollis gave an interesting talk on how the types of things that we are developing is changing.  He showed that the move to SOA will force us to become better UI designers.  Right now, if our UI sucks, the users don't have a lot of choice except to use it.  In the future, some one else could build a better one on top of an exposed service.  This was a good set up for his later talk about software complexity.

Fresh Cracked CAB - Ward Bell

Ward reminds me of someone that I used to work with.  It was a good presentation on Microsoft's Composite UI Application Block (CAB), which is a windows smart client technology.  A lot of the of patterns could be converted to ASP.NET with a little work.  Ward basically showed how to use one of Microsoft's application blocks to quickly build and extend a window smart client.

Software Complexity - Billy Hollis

Billy Hollis is my new hero.  He shared some of his "outside the box" thoughts on software complexity and the need for simplicity in an increasingly complex technological landscape.  He boldly asserted that instead of making our lives simpler, Microsoft is killing us with complexity as it releases more and more technologies at a pace that no one can keep up with.  Kudos to the Microsoft employees, who had several chances to tackle him and drag him off the stage, yet some how kept their composure.  The talk can really be summed up by Billy's "Simplicity Manifesto V1.0":

  • Stop adding features
  • Make help helpful
  • Fix the bugs
  • CRUD for free
  • Hide the plumbing
  • Get better names

Thursday, November 08, 2007

Microsoft Patterns and Practices Conference - Day Four

Today's topic was "Software Factories", but it should have been titled "A bunch of stuff that you'll need VSTS to use".

Keynote - Scott Hanselman

Scott delivered a great presentation on the MVC framework that Microsoft is currently working on.  He went over the plusses of using the framework, like how it provides for clean separation of concerns and how it is extensible and pluggable. We even got a chance to see it in action in Visual Studio.  The framework won't require VSTS and will probably become a very handy development tool.

Domain-Specific Development with VS DSL Tools - Gareth Jones

This talk was about how to build a domain specific language using the graphical modeler in Visual Studio.  What it really boils down to is "How to generate a Modeling Language, using the graphical modeling language in VSTS."

Patterns of Software Factories - Wojtek Kozaczynski

Wojtek went through the Software Factories that the Patterns & Practices group has released and reported some of the common patterns that he found.  Kind of dry stuff that I won't be using anytime soon.

Building Services...Service Factory: Modeling Edition - Bob Brumfield, Ade Miller

Here, we were shown how to use a software factory to generate a modeler that will then generate some code.  Once again, this is a VSTS thing.

Web Client Guidance: Web Client Software Factory - Michael Puleio, Chris Tavares & Blaine Wastell

This was a good discussion of the P&P group's Web Client Guidance.  I've not before seen a simpler and easier to understand diagram that showed the difference between the Model View Presenter pattern and the Model View Controller pattern.  You don't need VSTS to use the guidance bits.  Expect more blog posts about this one.

Using Team Factories - David Trowbridge

Yet another Team System oriented talk.

Build your own Software Factory - Wojtek Kozaczynski, Bob Brumfield, Ade Miller

I've got to admit that this talk was way over my head.  From what I gathered, basically went through what it took to generate the software factories that they have released.  I guess there's a reason that they make the big bucks.

Tomorrow is the last day of the conference and will be dedicated to "Applications".  Scott Hanselman will give another keynote.

Wednesday, November 07, 2007

Microsoft Patterns and Practices Conference - Day Three

Today's theme was "Development", but I'm not really sure that was what we talked about for most of the day.  There were some good talks, here's more about them:

Keynote - John Lam

John Lam's presentation, for the most part, centered around IronRuby.  He ran a good code demo inside the ironruby version of irb, on mono, in a linux vm on his mac.  I know, its weird to see a Microsoft employee working off a Mac. But John was not the only presenter doing so.  There was an especially exciting demo of using Ruby to dynamically generate Silverlight objects.  Currently, this is hard to do in C#.  I think that it is really great that IronRuby is a fully open source project that accepts contributions from outside developers.  The team uses Subversion for the code repository and hosts the bits on RubyForge.

The Right Tools for the Right Job - Rocky Lhotka

Rocky started off by reminding us that Object-Oriented Design isn't dead.  He gave a in depth comparison of the strengths and weaknesses of OO, SOA, and Workflow design.  It was really enlightening to see his take that your can see aspects of OOP in all of these design architectures. 

Model Based Design - David Trowbridge

This turned out to be a demonstration of how to use the class builder, and some new modeling interfaces, to generate code.  It's a shame that we will need Team System Architecure edition to actualize any of the examples.  Maybe our team can win the lottery one day.

Dependency Injection Frameworks - Peter Provost, Scott Densmore

Have you ever wanted to know how to roll your own Dependency Injection into your application?  I thought I did.  Sure, it was very interesting.  However, if they were pitching it for my application, I'd have gone out and bought a license for typemock by the second example.  Let's just say there is a lot of work that Typemock(or other mocking frameworks) do for you automatically.

Designing for Workflow - Ted Neward

Once again, Ted delivers a great presentation, full of poignant wit.  Ted makes the argument that Workflow, as we know it in the realm of recent Microsoft tools, hasn't really been around long enough for us to declare any best practices.  Of course he offers his point of view, which left no time for the audience to chime in.

Panel: The Future of Design Patterns - Dragos Manolescu, Wojtek Kozaczynski, Ade Miller, Jason Hogg

This was strange.  They gave the guys on the panel toy guns that shot little foam discs so they could shoot each other when they were in disagreement.  They then discussed the failure of a patterns web site and debated whether we should be generating more documentation and collaboration around patterns or whether we should just build them into development tools.  I like the gun idea, no pattern or practice would truly be complete without firearms.  I think I'll try it out at our next team meeting.

EntLib Devolved - Scott Densmore

EntLib is short for Enterprise Library. Entlib is a collection of general purpose application blocks addressing enterprise scenarios. For example, there is an application block for logging.  Scott Densmore, one of the developers, gave a quick overview of the blocks and elicited feedback from those that had used it.  I have never used it, but it looks cool.

So, tomorrow's theme is "Software Factories" and the keynote is by Scott Hanselman.  It should be a very interesting day! 

Tuesday, November 06, 2007

Microsoft Patterns and Practices Conference - Day Two

Today was dedicated to Agile practices and Methodologies.  Here's a rundown of the talks.

Keynote - Steve McConnell

Steve provided a wonderful overview of the Agile methodology.  He went into a lot of detail about the agile practices and relied on his companies experiences to rate them based on how they work in the real world.  For example, short release cycle tend to work very well, while pair programming tends to be problematic. The jet lag hit me pretty hard this morning and Steve is a soft speaker, but it was really interesting.

Agile is more than monkey-see-monkey-do - Peter Provost

First off, Peter Provost is very engaging speaker that highly encourages audience participation.  I highly recommend watching one of his presentations.  This one started as a comparison of two fictitious companies and how they implemented Agile methodology. One with great success and one with terrible tragedy. It then moved onto how teams can figure out how to implement agile practices.  He also spent a good amount of time discussing how to get a team that has strayed back to the agile path.

Empirical Evidence of Agile Methods - Grigori Melnick

Grigori tried to show that there are actually people out there using agile methods.  Apparently, there isn't must documented evidence.  The topic by its very definition is pretty dry.  That's all I have to say about that.

What's new in Rosario process templates? - Alan Riddlhoover

Alan gave an informative, but extremely slow paced presentation on the new features found in the next version of Visual Studio Team System.
It looks like they have a replacement for Caliber that integrates with MS Project.  Our team doesn't have VSTS, so a lot of the stuff that was demo'd won't really matter.

Lessons Learned in Unit Testing - Jim Newkirk

Now this was a good talk.  Jim is one of the original authors of NUnit and has now moved on to run Codeplex. In his talk, Jim relays 7 lessons that he has learned over his 8+ years of doing unit testing.  The lessons are listed below. 

Lesson #1 - Just Do It
Lesson #2 - Write Tests using the 3A Pattern(Arrange, Act, Assert)
Lesson #3 - Keep your tests close
Lesson #4 - Use Alternatives to ExpectedException
Lesson #5 - Small Fixtures
Lesson #6 - Don't use Setup and TearDown
Lesson #7 - Improve Testability with Inversion of Control

Some of the stuff he was talking about seems to go against what I've been learning from the internet and architecture.  I'm hoping to talk with Jim tomorrow to get some more insight.  Expect more in the future.

The Agile Security Development Lifecycle - David LeBlanc

David stressed the importance of considering security from the beginning of a project's SDLC.  He stressed that developers on an agile team need to be educated about security. "If they understand what a security mistake looks like, they are less likely to put it into the code."  He also pointed out how some of the agile practices enhance security.  For example, Peer Programming is not only effective for finding bugs but also for finding security issues.

"Yet Another Agile Talk on Agility" - Peter Provost

Peter ran this talk like an agile project.  There were 4, fifteen minute iterations where the first five minutes where used to gather issues about Agile that the audience was interested in and prioritize them.  The next ten minutes where dedicated to tackling the issues/questions based on their priority.  When the next iteration came around, we were given the ability to add new questions and re-prioritize them with the rest of the open questions.  Peter kept a count down timer running on the big screen to make sure that we stuck to the schedule.  It really drew you into the conversation and was a lot of fun.

 

Tomorrow looks like a good day.  It will be dedicated to development and the keynote speaker will be John Lam of IronPython fame.  Night, night for now kiddies.

Monday, November 05, 2007

Microsoft Patterns and Practices Conference - Day One

All this week, I and a few of my cohorts are attending a Patterns & Practices summit in Redmond.  I'll be giving a breakdown of the sessions this week and will go into more detail in future posts about the topics that I find most interesting.

Here is a quick breakdown of the topics and speakers, each followed by a brief description.

Keynote - Anders Hejlsberg

This wasn't as much a keynote address as it was a LINQ demo.  Anders is awesome and gave a great and detailed demonstration.  You can expect a lot more about this one in future posts.

A Software Patterns Study - Dragos Manolescu

This wasn't what I expected.  Apparently this guy did a survey about Patterns and how much they were used in current enterprises.  It turned out to be a plea for help from the community to help build a modern platform for collaboration on patterns.

Architecture of the Microsoft ESB Guidance - Marty Masznicky

I didn't get a lot from this talk because it was all about extensions for BizTalk, which I have zero experience with.  However, I will give the speaker credit for giving an hour long presentation with gauze stuffed into one of his cheeks.  Don't ask.  Sadly, I couldn't conjecture what ESB stood for until halfway through the presentation when the guy in front of me Googled it.  ESB stands for Enterprise Service Bus and provides a way to do a lot of stuff that should have been integrated into Biztalk by default.

Pragmatic Architecture - Ted Neward

Ted is a excellent speaker with a great sense of humor.  He spoke about our need to be able to determine the best architecture for our solutions.  Apparently, not every architecture solution is right for all applications.

Architecting a Scalable Platform - Chris Brown

This was an interesting look at building globally scalable applications.  We're talking things like Amazon.com.  Global level scalability relies on horizontal scaling. 

Grid Security - Jason Hogg

Jason gave a great talk about the Security Policy Assertion Language (SecPAL).  SecPAL was designed to address security for large scale applications, such as computing grids.  The security rules are easily read as English sentences with a restricted grammar.  You can find out more here.

Moving Beyond Industrial Software - Harry Pierson

Harry talked about the Industrial age's influence on modern programming.  Just as the Industrial age has given way to a new information age, so our programming methodologies must give way to something more practical.  The main point of his talk was that things that are simple and empower the users will be the applications of the future.

Well kids, that's all for now.  See you tomorrow.

Friday, September 07, 2007

Being a better developer

I know what you're saying, "Yo Mack!, why you no post?"  Well, that's a tough one to answer.  Let's just say that I'm lazy. 

Today I'll be responding to the uber blog meme on what I will do over the next 6 months to become a better programmer.  I know a lot of folks don't like "list" posts.  To them I say, just be glad I'm not numbering them.

Pick up a new OS - I feel that this is very important as more and more of our user base is moving from Windows to something else.  I have chosen Linux, Ubuntu specifically.  I chose this over a Mac for several reasons.  It's more accessible to me, it appeals more to my techy/nerdy side, and we all know what happened to Mac at the end of Jeepers Creepers

Learn a cross platform language - Once again with the cross platform thing. Here I'm going with Ruby. It is elegant and has a lot of great features.  Microsoft if also writing a .Net version, IronRuby, that will be useful in Silverlight development.  I'm hoping to create a few cross platform applications, not web apps, that will actually be useful.  I'll let you know how it goes.

Linq, Linq, Linq - Seriously folks, this is where its at.  I've been taking the LinqPad Challenge for the last couple of weeks and plan to continue for the next few months. It's great, I'm actually getting a handle on Linq to SQL queries.  Let's take the challenge together, shall we?

Presentations - I am admittedly the worst presenter/public speaker that I can imagine.  Miss South Carolina has me beat, hands down.  However, I find a way to do it anyway.  Presenting increases your communication skills, boosts your confidence and is a great way to trick your peers into thinking that you actually know what you're doing.  I'm planning on doing some research on presenting skills and applying them more often. I'm even looking into doing a screencast or two.

GTD - I'm a big proponent of Life Hacking.  So I'm going to continue finding great ways to save time.  I can tell you from personal experience that hacks like Merlin Mann's Inbox Zero can really save you time and peace of mind.

This isn't a comprehensive list, but it is stuff that I think is important.  What things will you be doing to become a better developer over the next few months?  I'll check in with you next year.

Friday, June 01, 2007

Spell Check in PowerShell

If you are like me, you do a lot of work in simple text editors. I'd take a sleek, versatile and fast Notepad2 over a bulky Word instance any day. So have you ever typed in a word and it looked funny? Did you spell that correctly? Well, you could open up Word and wait for it to come up and then use it's spell checker. Or, you could bring up a browser and use one of many sites that will check. My machine runs at a speed somewhere between sloth and slug. So if I don't already have one of those apps open, I'll use up my squirrel sized attention span and forget why I opened them in the first place.

I always have a PowerShell instance running. Wouldn't it be cool to test my funny looking word with a script. I'd used the NETSpell library on one of my previous projects and thought that it would be easier to access than Google's api. So what I ended up with was a good example of how to wrap a PowerShell script around an existing class library.

Here's the script:

###############################################################
###
### Spell.ps1 - Allen Mack 6/1/2007
###
### This script takes the first argument passed to it and
### runs it through the NETSpell spell checker.
###
###############################################################

[System.Reflection.Assembly]::loadfrom("c:\Program Files\NetSpell\bin\NetSpell.SpellChecker.DLL") Out-Null

$checker = New-Object NetSpell.SpellChecker.Spelling
$checker.Dictionary.DictionaryFolder = "c:\PowershellScripts"

$word = $args[0]

$result = $checker.TestWord($word)

if($result -eq $true)
{
Write-Output("`"" + $word + "`" is spelled correctly.")
}
else
{
Write-Output("`"" + $word + "`" is spelled incorrectly.")
Write-Output("Maybe you meant:")
$checker.Suggest($word)
$checker.Suggestions
}



The first thing to do is load the dll into memory. Next we create a Spelling object and point it to the directory where our dictionary lives. I copied the dictionary file to the same directory as the script. You could point it to the NETSpell installation directory. If the word is spelled correctly, I print out a message saying so. If the word is spelled incorrectly, I display the array of suggestions generated by the Spelling object.

Friday, March 02, 2007

Powershell FizzBuzz One-liner

I know, I know, the FizzBuzz problem isn't about the implementation. However, I've seen implementations in C#, Java, Python, Perl, Ruby, yada, yada, yada. Well, I haven't seen one in Powershell, so I'm posting it here. Not for implementation's sake, because I'm sure that there is a better way to implement it. I'm putting it here for the sake of fairness.

1..100 ForEach-Object { $str = ""; if($_ % 3 -eq 0) { $str += "Fizz" }; if($_ % 5 -eq 0) { $str += "Buzz" }; if(($_ % 3 -ne 0) -and ($_ % 5 -ne 0)) { $str += $_ }; Write-Output $str }

3/8/2008 - Thanks to Scott for pointing out a typo in the script. It's fixed now.