Archive for the ‘Programming’ category

New Types in .Net 4.0

October 29th, 2009

A lot of the hype around .Net 4.0 is surrounding new features such as the Dynamic Language Runtime (DLR), and C# 4.0 features such as the dynamic type and co/contra-variance.  Something not getting as much press, but in many ways more helpful is the inclusion of many new, useful types included in 4.0.  The BCL team has a blog article about many of these types.  Here are a couple of my favorites:

  • Enum.HasFlag(Enum enum)
    I have written this code a couple of times before.  It detects whether a bit is set in an enum Flag value.
  • Enum.TryParse<EnumType>(string value, out EnumType result)
    I have also had to write this.  I think every core value-type should have a TryParse, which leads to:
  • Guid.TryParse(string value, out Guid result)
  • String.Join and String.Concat now take IEnumerable<T>!  I have written string.Join(“,”, values.Select(v=>v.ToString()).ToArray()) more that a few times.

I am really looking forward to .Net 4.0.  If you want to get your hands on it now .Net 4.0 and Visual Studio 2010 are available for download here.

Google Wave Authors

October 27th, 2009

CNN is running a story about the two guys most responsible for Google Wave.  These are the brothers that built Google Maps.  If you haven’t seen Google Wave, here is a rather long video that goes into some detail:

Unit Testing in Silverlight

October 26th, 2009

Something I am a really big fan of is Unit Testing.  I was a big evangelist of unit testing at my last company.  The code my team wrote unit tests for was, on average, much better code than code that was written without unit testing.  Code-testing coverage via unit testing creates solid code.  It allows developers to thoroughly test their code in an automated fashion.  Unit tests give the developer confidence that they have introduced few or no regressions with new functionality added to old code.  All one needs to do is re-run the old unit tests to ensure everything still works.  Unit tests are a great form of documentation.  When a developer maintains code written by another they can inspect unit tests to see how the code is used, and can run these unit tests to ensure they aren’t breaking functionality they may not understand.  Ultimately unit tests act like a code specification.  In fact there is a style of coding called Test Driven Development (or its sexy new name, Behavior Drive Developer) that mandates that the tests be written first, and then the code is not considered complete until it satisfies the tests.  And even when unit testing is not take to that extreme, developing code that works well with unit tests usually ensures well-designed code from an object-oriented standpoint.  Code that is easily tested by a unit test is usually adequately decoupled and uses OO principles like inheritance, encapsulation and polymorphism in the right way.  Finally, writing code with unit tests can be faster.  Running tests can take less time than standing up an application and entering in the correct criteria to test the code in question.

At my current employer I have found myself working with a very mature (and very good) code-base that does not lend itself to unit testing.  It has probably been a year since I have written a unit test at work.  So when I started diving back into Silverlight I made it a goal to write our new framework to be as compatible with unit testing as possible.  This will help lesson the burden on our QA team, which has already written a lot of UI testing for our current ASP.Net web application.  We will also receive all the benefits mentioned above.

To start off I needed a unit testing framework.  NUnit is my old unit-testing friend and was my first thought.  However, NUnit and other unit testing frameworks don’t work in Silverlight-land, since Silverlight relies on a slightly different set of core .Net assemblies.  I did discover that there is a Silverlight version of NUnit and I considered it.  I also found the Silverlight Unit Testing Framework from Microsoft thanks to a post over on Scott Gu’s website.  The Silverlight Unit Testing Framework is based on the Microsoft library for normal .Net (which is also based on NUnit) but runs in Silverlight, in the browser.

Ultimately I chose the Microsoft library for a couple of important reasons.  First, there seems to be more acceptance and more example of the Microsoft library.  Second, the Silverlight Unit Testing Framework does one thing that is very unique compared to other unit testing frameworks: it runs the tests in the UI thread.  Jeff Wilcox, one of the authors of the framework, has an excellent post here about why Microsoft chose to do this, and it really makes sense.  Silverlight is a graphical library, and bugs will best be found if testing is written from a user-interaction standpoint.  Many things run on the UI thread, or are marshaled back and forth.  The Microsoft Silverlight Unit Testing Framework can work both as a unit testing framework and as a kind of integration testing framework.  The framework makes it very easy to test off the UI thread, and test asynchronously.  I found this excellent post on using the async features of the Silverlight Unit Testing Framework.  It really boils down to the testing environment being the same as the real run-time.  I have run across enough idiosyncrasies in the way Silverlight handles UI thread interaction to know that testing without it will miss a lot of bugs.

I have developed some “test” tests on business objects.  I also tested a thread manager I wrote using the built-in async functionality.  With the experience so far, I feel happy with the results.  My next step is to look at pluging in the unit tests into the automated build at work…

Microsoft WebsiteSpark Program

September 24th, 2009

Scott Guthrie just announced a new program that Microsoft is offering, for free: Microsoft WebSiteSpark Program.  It looks like there are giving away some free software and services to help small business develop with Microsoft.  It looks pretty smart, and pretty cool.

WebSiteSpark

CodeRush Xpress for Visual Studio 2008

September 10th, 2009

After watching this video about CodeRush XPress I decided to try it for myself.  I downloaded it on Tuesday morning and have been using it all week.  While I haven’t used all of the features, I have been impressed with several of the things with this free version of the product.  Two things I particularly like are the code snippet refactoring and the ability to auto-gen a class or function simply by writing the calling code then using the appropriate hot keys.  It saves a lot of typing.

As I mentioned, this is a free version.  The full version, which has a number of additional Visual Studio enhancements, is $249.  These types of tools are nice, but way overpriced.  I think they would make a lot more money if they sold it for a reasonable price.  Trying to get an employer to by software is like trying to pull teeth.  This free version adds a number of nice features to Visual Studio.  If you spend any real time in C# or VB.Net you should try it.

UK: We are sorry Turing

September 10th, 2009

I have written about Alan Turing before.  Today The Prime Minister of the UK apologized for the disgusting treatment of Turing in the 1950s.  It was long overdue.

Turing Home

Visual Studio 2010

September 1st, 2009

Scott Guthrie has a very informative series about Visual Studio 2010 over on his web site.  Today’s article is about enhanced multi-monitor support in VS 2010.  I have only had a chance to use VS 2010 in a virtual machine, and have not had a chance to take the multi-monitor stuff mentioned in his article for a test drive.  It does look very cool.

Something I am particularly interested in is support for varying numbers of monitors.  At work I have a dual 19″ monitor display rig.  At home I remote into my desktop from my single-monitor 17″ laptop.  I occasionally have trouble with windows displaying correctly when I remote in. particularly using Visual Studio 2008 with tool boxes that are on the second monitor.  In VS 2010, window settings are kept in the local user file for the project, so if nothing else one should be able to move off-screen windows on-screen with a little text editing.  I am interested to see what kind of built-in support VS 2010 will have to detect that the second monitor is not present in this type of situation.  If it doesn’t auto-detect, it might now be easy to build a tool to edit the user file, or swap out user files.

Quality, Quality Assurance

August 25th, 2009

I started writing software professionally late in 1997, if you consider the first real web site for which I was paid.  There really wasn’t a lot of architecture or process that went into that first site.  I had been reading on Perl and Javascript and wrote some very simple email forms, picture slide-shows, and did some Photoshop work.

I got going in earnest in the spring of 1998 when I was hired on as a web developer at a local Internet Service Provider.  At first what I did was more hacking that software engineering.  Maintaining Perl scripts written before my time (that had not been that well thought through to start with) and writing Classic ASP (we just called it ASP back then) that was more about getting it to work than getting it to work well.  But I had a background in computer science, and I soon started buying books to gain the Microsoft Certified Solution Developer credential.  This is where I was introduced to software engineering as a profession.  I distinctly remember reading about the roles Microsoft used for software development, and a matrix about who could wear multiple hats.  For example, a manager might also be a lead programmer, a designer might also be a developer.  But a developer could not also wear the hat of tester.  Microsoft was very, very clear on this point.

Of course we did not have a Quality Assurance department at our little ISP.  Hell, the web development department wasn’t even profitable the first year I was there so we weren’t about to spend money on someone just to test our stuff.  And we really didn’t need it at the scale we were at.  I had, at most, two or three other developers on my team during my tenure.  These were mostly part time; we simply weren’t building huge web applications.  Software engineering for me at this point didn’t include a lot of process; what I was doing really should not be called software engineering and I certainly wasn’t calling it that then.

After getting my MCSD and realizing that the entire software industry was booming I took a job with the State of Wyoming making the big cash.  The first big project I worked on had about 40 developers; there was no QA.  We tested our own stuff and occasionally each others stuff.  In hindsight this is surprising because Anderson Consulting (now Accenture) was running the project.  There were several individuals, including the manager, that had over 10 years of experience.  They should have known better.  I know I didn’t at the time.

Over the next couple of years I did a lot of contracting.  There was never any QA.  During this time I was really beefing up on .Net and my programming skills in general.  I noticed my skills increasing sometimes week by week, and definitely month by month.  I was optimistic, but I was still inexperienced.  I thought that quality programming was all that was needed to create quality software.  This myth had started for me in my early programming days, and had solidified at Wyoming, and was reinforced by the fact that I seemed to be writing better and better software and didn’t seem to need QA to do it.  However, I was also digesting a lot of books at this time that said the exact opposite of what I was thinking.

In 2003 we moved to Austin, and I started a full-time job with a local medical software company.  I had come a long way in the 6 years I had been in the field.  I was now convinced of the need for QA, for unit testing, and for other, industry proven methodologies.  I was fortunate to find a job quickly in a down economy.  I was unfortunate to go to work for a friendly, but completely incompetent manager.  She basically ran a cowboy coding shop.  There were no formal requirements to look at, there were no processes in place.  Even though we had a relatively small team information was poorly distributed.  We had no QA, and unit testing was downright discouraged.  I was beginning to think that QA was a myth; no one seemed to actually do it.  Was I wrong?  Had I been right earlier in my career?

During this time I continued reading about process; in the I realized that what we were doing was very wrong.  For the first time in my career the software was complex enough that the lack of QA was obvious in the final quality.  Here I had the proof in front of me. Although it could have been all the other things we were doing wrong – I am sure  When I had a chance to leave the company when even worse management took over I did.  And I found some QA.

I went to work at a second medical software company in Austin about 3 years ago.  There was an entire, dedicated Quality Assurance Department with Quality Assurance Engineers.  I was excited.  I thought I had finally found someplace with individuals that understood software development methodology and applied it to testing of software.  Boy was I wrong.  As the weeks and months rolled by I was moved from my initial R&D role doing framework development (no real QA interaction) to one doing production software (lots of QA interaction).  I soon learned that the vast majority of our QA “Engineers” really didn’t have any clue about software development.  In fact, they really didn’t know a lot about computers.  There were a few bright spots, and a few bright people.  There were definitely some hard working people.  But no real methodology was employed, and leadership in the QA department was horrible from the top down.

My first real experience with dedicated QA showed me a QA effort that only hindered the development of quality software.  Now I really reconsidered my stance.  Was I really, really right early in my career?  Is this why so many shops lacked QA, because QA just got in the way?  I had a hard time believing that.  There were a couple of stand-out QA people that did catch a lot of bugs and did help produce better software.  Most of these stand-outs lacked a background in software, and they all lacked any real empowerment from their management.  What would it be like to have a QA department with smart people that used good process and good management?  What would quality, Quality Assurance be like?

I got the answer last spring when I was laid off and quickly found a job with my current employer.  I ran into my second, real QA department in my career.  And this time I ran into the real deal.   We have engineers that all have a significant background in software development or IT.  I can think of at least three QA engineers at my job that know much more about networking and servers than I do.  I think they all know more about the product that I do.

Over the last year and a half I have come to the startling conclusion that not only is good QA important, but it might be the most important thing in software development of any significant complexity.  It is Quality Assurance Engineers, not Software Engineers, that have the most significant impact on Quality Software.  When this dawned on me a few weeks ago, I felt a bit lost.  The control had been taken out of my hands.  As a software engineer I realized I was not necessarily the most important portion of the product development.  It is the QA engineer that keeps me honest.  It is the QA engineer that tests my software in ways I would never have thought to test it.  It is the QA engineer, writing automation tests that pushes my software far past anything I could simulate.  At my current employer, our QA engineers vastly improve the quality of our software.

I continue to strive to learn new skills and to become a better software engineer.  But something I know is that I will never be a good QA engineer for myself, and am thankful for the people we have.  I think back on all those previous experiences.  I think of those managers at previous jobs that were hopelessly lost.  This is just one more lesson for me.  Trust the experts.  Trust your instincts.  And quality, Quality Assurance is really important.

First Impressions of IronPython

July 31st, 2009

I stumbled across a book sale a few days ago and bought a few programming books. One of them was IronPython in Action.  I had played with Python a number of years ago; I believe I was first introduced to the language in late 2001.  I evaluated it as a language for a local Unix shop to use to replace a couple of proprietary languages.  I found it quite appealing at the time and we ended up recommending it over Perl, Ruby and Tcl.  And then I proceeded to not use Python for anything over the last 8 years.  Its kinda like the time I learned Pascal just so I could help a girl that I liked that was in a Pascal class, but that is a different story and it didn’t work out anyway.

IronPython, as you may or may not know, is an implementation of Python built on top of the .Net Common Language Runtime.  The level of integration I have found between Python and the .Net Framework is uncanny.  I had a Windows Forms window with controls up on the screen in 5 minutes of programming.  On top of the actual .Net integration, the Visual Studio integration is also quite good.  Designing a Windows Form is about the same as it would be for a C# or VB.Net application.

I am only a couple of chapters into the book, but so far I have found IronPython to be a join to work with and I am already looking forward to a chance to use it professionally.  I will post a book review when I am finished.

Google Web Elements add Google goodness to your web site

May 27th, 2009

Google has a number of awesome products, ranging from its traditional search to its mapping to its online office replacement.  They have now packaged several of their products as free widgets that can be embedded into a web site with ease.  They are calling this Google Web Elements.

Maps

News Videos

Search JasonJackson.com

Loading


Pretty cool stuff.