No Fluff Just Stuff: Testing with Selenium with Neal Ford – level 200

On the 3rd day of NFJS, Neal gave a talk about
testing with Selenium.  Selenium is a
end-to-end testing solution for web applications.  This is testing on the customer acceptance
level and not the unit-testing level.


Selenium was developed by ThoughtWorks to test an
application they were working on.  It
grew out of an actual need.  The testing
framework was good enough to open-source it. 
They named it Selenium because it is the key mineral that protects the
body from mercury poisoning (if you recall Mercury testing tools).


With Selenium, tests run directly in the browser.  It supports most common browsers that are in
existence today.  The test engine itself
is written in JavaScript and runs directly in the browser.  It creates a compatibility layer across
browsers.  Calling an API in Selenium
will map to the right API in the current browser.


It deploys a browser bot that runs alongside your
application.  This bot can accept
commands.  The bot is embedded in an
IFrame.  Consequently, it will work with
any javascript-enabled browser.  To use
selenium, you must take the selenium folder and deploy it alongside the
application.  This will be in a
non-production environment, of course.


There are two modes for Selenium:  TestRunner mode and Driven mode.  In TestRunner mode, the browser is driven
inside the process.  In Driven mode, the
Selenium can be driven from another process remotely.


With TestRunner mode, Selenium is alongside the
application.  The user can launch it and
click the “Run Tests” button to run tests. 


Selenium test case is a simple html table.  The first row is a title and can be
ignored.  The next rows are the commands.  By default, it looks for


You can run Selenium tests directly in a browser and watch
it exercise your application at full speed or “walk” speed.  You can also step through.  If you need to run it from another process, you
can use Driven mode to run it from Ant, Nant, Maven, CruiseControl or anywhere.  Once you have a big suite of tests, you’ll
want to have it integrated with your normal build process.


There is a Selenium IDE that can be used to record
tests.  The IDE is an extension for
FireFox at  Selenium can test regular web applications as
well as AJAX web applications.

NFJS: Cleaning up your code with Neal Ford – level 200

Neal gave some great tips on improving code.  Here’s the rundown.  These are thoughts directly from Neal:

Coding standards aren’t necessary.  They are just preferences that folks in
charge force on underlings.  There are
more important things than coding standards. 
Tools can reformat code to some sort of standard.

#1:  Naming
things:  Use verbose variable names.  Don’t worry about having to type.  Modern IDEs give you these in a drop-down
list, so you only have to type them once. 
IntelliJ and Resharper will guess, and you don’t have to even type them

#2:  Composed
Method:  Comments.  Xml comments are sometimes useful if you need
to generate documentation.  Intra-code
comments are not necessary most of the time. 
No one ever reads them, they smell, and they lie when the code around
them changes (because no one updates them). 
There is nothing that anchor line comments to the code they are supposed
to describe.  At least Xml comments are
anchored to the method.  So, if comments
in code don’t help as much as we’d like, what can we do?  Make the method name be a long, description
of what the method does, and no method should be longer than 5-15 lines of
code.  All public methods should read as
an outline of things that need to be done (and call private methods to get
these things done).

  • Benefits
    of compose method
    • Stack
      traces become easier to read
    • Debugging
      is easer.  Instead of stepping over
      lines of code, you step over private methods that are little chunks of
    • It
      makes writing unit tests easier because you can fake out any step.
    • It
      makes it easier to identify generic methods that can be pushed up the
      inheritance hierarchy.
    • Once
      the method reads easier, line comments become redundant and unnecessary.

#3:  Apply the Unix
Philosophies:  By applying unix
principles to software will make it better. 

  • Write
    simple parts connected by clean interfaces.
  • Clarity
    is better than cleverness.
  • Design
    programs to be connected to other programs
  • Separate
    policy from mechanism; separate interfaces from engines.
  • Design
    for simplicity; add complexity only where you must
  • Write
    a big program only when it is clear by demonstration that nothing else
    will do.
  • Design
    for visibility to make inspection and debugging easier.
  • Robustness
    is the child of transparency and simplicity.
  • Fold
    knowledge into data so program logic can be stupid and robust.
  • In
    interface design always do the lease surprising thing.
  • When a
    program has nothing surprising to say, it should say nothing.
  • When
    you must fail, fail noisily and as soon as possible.  (Don’t return null if something really
    bad happens).
  • Programmer
    time is expensive; conserve it in preference to machine time.
  • Avoid
    hand-hacking: write programs to write programs when you can.
  • Prototype
    before polishing. Get it working before you optimize it.
  • Distrust
    all claims for the “one true way”.
  • Design
    for the future because it will be here sooner than you think.

#4:  Syntactic

  • If a
    constant is tied to a particular class, it should be defined within the
  • If a
    constant is not tied to a class, it should be tied to an interface.  Don’t implement a class for the
    constant.  You should use the
    constant through the interface name.
  • In
    Java, you can use the javax.print.attribute package and inherit from the
    EnumSyntax class.  Java 5 has native
    support for Enums as does .Net, but safe enumerations that are
    ranged-checked are important.
  • How to
    implement equals()
    • Use
      == to see if you have been passed yourself.
    • Use
      instanceOf to check the lineage of the object.
    • Check
      the equality of each field in your class. 
      If any test fails, return false.
  • Any
    time you override equals(), you should override GetHashCode(). 
    • If
      two objects are equal, they must return the same hash code. 
    • It’s
      not required that two unequal objects return different hash codes, but
      collection performance could suffer.
    • IntelliJ
      is smart enough to generate good equals() and hashCode() methods.  I’ll have to check to see if Resharper
      will do this.

#5:  Orthogonality:
the absence of side-effects.

  • Command/query
    separation:  You should not do two
    things under the guise of one. 
    Don’t calculate something if you name it “get”.
  • For
    example, in a Stack class, if you call “pop”, you remove something just to
    read it.  If an error happens, you’ve
    lost the object.  A more orthogonal
    approach would use a “top” method and “removeTop” method.

#6:  Don’t repeat

DRY principle. 
Every piece of information should have one authoritative representation.

If you have an NHibernate mapping, you could
generate it from the database schema (if you have a 1-1 mapping). 

If you want documentation of your system, you
should find a way to generate the documentation from the code.

o       yDoc
is a commercial documentation product that generates UML.

#7:  The Methodology

Don’t live with broken windows:  If you have a broken window, it indicates
that nobody cares.  If you leave it
there, your source code is fragile.  Your
code will get stronger over time if you are adamant about automated testing and
fixing broken windows.

From Agile Best Practices:

o       YAGNI
– You ain’t gonna need it.  If you aren’t
absolutely sure you need it right now, defer it until later.
o       Embrace
changing requirements by:

Refactoring mercilessly

Set aside time every day to refactor code.

Refactoring is fun, and it is different from
“regular” coding.

Automated testing.

Test coverage gives confidence that you have
changed some code, and you haven’t broken anything.

Testing is a frame of mind, not a tool set.

Who cares if the test was written first or last
as long as the code and test are written close together.

Applications tend to grow from the bottom up
with small, little units of verified code. 
The alternative is writing top down (which is hard).

Generate code coverage reports on your tests.

#8:  Template method
design pattern.

  • If you
    know what the algorithm should look like but don’t know the details, you
    can write the outline and defer the details to child objects.
  • It
    encourages your to define the general order of operations for some process
    in an abstract parent, then implement the details in child classes.
  • This
    works best when the code is small, cohesive, and discrete.
  • You
    should aggressively pull methods up the hierarchy and look for definable

#9: Bad Inheritance.

  • Inheritance
    is hard, so use composition instead of inheritance.  Encapsulate the type you were going to
    override and forward calls to it.
  • Inheritance
    is only applicable when the child “is-a” type of the parent in EVERY case.

#10:  Use interfaces
for decoupling

  • Whenever
    possible, define types and member variables as interfaces.
  • If you
    have a class that needs to act as two things, you can implement two
  • Objects
    are more flexible because they can be treated as either a base class or an
    interface that’s implemented.
  • This
    allows libraries to be written that are not bound to specific classes.

The result of all this is framework code and
configuration.  Framework code is common
code that’s pulled up.  The code with the
details is configuration.  The end result
is a domain specific language that comes out of the APIs that result.

Neal’s final point is that code is the most important
artifact we create.  If you create the
most brilliant piece of software with not documentation and not bugs, you’ll be
a hero.  If you create beautiful
documentation without good software, you won’t be worth anything.

No Fluff Just Stuff comes to Austin – level 000

This past weekend, the NFJS conference came to Austin, TX,
and I’m glad it did.  Folks involved with
a user group of some type got a good discount, so we spread the word.  This conference focuses on Java, Ruby, and
Agility.  I was able to meet some great
folks (list names).

Saturday night I went to the speakers party at Bruce Tate’s
house, and it was a great time.  Scott
commented that Ted Neward looked like Jesus with his hair wet playing
with the kids in the swimming pool.  I
enjoyed talking with David Hussman about how to drive efficient software
development into organizations.  David
consults for companies and helps them improve their development practices.

No Fluff Just Stuff is a small, local conference that has a
better attendee to speaker ratio that other conferences, which have thousands of
attendees.  This conference has about 250

I’m going to post some more about the sessions I attended.

I don’t know how Franklin comes up with these ideas – level 000


I don’t know how he comes up with these ideas.  If you aren’t familiar with Carl Franklin, you should be.  .Net Rocks was a podcast before anyone knew what a podcast was.  If you stopped listening to DNR when they had the non-technical spots like Google wierdos, and the like, they’ve come full circle.  It all content now.  It’s great for a commute or any time you might otherwise be listening to the radio.


Here’s the picture Carl got of me at Tech Ed (my funny face).


Blogging from Tech Ed 2006 – Brian Button on how to write frameworks – level 300

Brian Button from the patterns and practices team gave a session bright and early Friday morning that was great.  He covered how to write frameworks.  What’s interesting is that he focused on writing frameworks as a non-technical problem since he’s seen too many frameworks that solve the wrong problem very well. J


  • Rules for Framework development

    • Clients come before frameworks.

    • Be sure that you are solving the right problem.

    • Quality, quality, quality.

    • Be an enabler:  You can’t solve every problem, so solve many problems but allow for extensibility points.

    • Creating frameworks is a people problem.


Brian stress that it’s impossible to write a good framework without a real application using it.  It will end up missing the mark.  He suggests, instead, writing several applications and harvest a framework from the common parts of the application.  This resonates with me because I believe it’s very difficult to write code that’s intended for reuse.  I write code for use, and if it needs to be used elsewhere, I’ll harvest it into a shared library.


Brian was very bold at this Microsoft conference, and I applaud him for this.  He stressed automated testing, and he said that here and now there is NO EXCUSE for not writing automated tests.  Bravo!  Brian contends that functional testing is a waste of a tester’s time.  The thought is that testers are too valuable for functional testing that could be covered with automated testing.  Testers should be testing the harder things.


Brian shares my frustration about sealed classes in the .Net Framework.  He has encountered parts of the framework that are sealed, and when he needs to extend them, he can’t.  Sealed classes are hard to write testable code against.  He made a good point that I hadn’t thought of before:  If you seal a class, you are saying “I can predict the future, and this is all that this class will ever need to do.”


Finally, Brian advocates these in creating a framework.

  • Do open planning.

  • Practice open prioritization.

  • Show visible progress.

  • Don’t allow surprises.


Brian recommends

  • Resist the urge to create something new.  Harvest frameworks from existing applications.

  • Encourage quality throughout the project.  Lead by example and testers rule!




Blogging from Tech Ed 2006 – Party with Palermo – level 000

Party with Palermo was a big, fun success.  We had about 30 folks at the hotel bar, and the beer was flowing.  Everyone had a great time talking about all sorts of geeky things, and we finally called it quits at 12:30 am.

You can see some pictures here: (only works with IE)

Blogging from Tech Ed 2006 – Stefan Shakow on ASP.NET – level 400


Stefan Shakow


  • 2.0 Framework assemblies have been NGENed to reduce JIT compilation.  This helps with memory usage when running multiple AppDomains in a single process (multiple applications on a single web server).
  • Another new feature new in ASP.NET 2.0 is the AppDomain unloader.  This is configurable by time of inactivity.  If an application is idle for that amount of time, the AppDomain is unloaded to free up memory.  This is configurable in the <hostingEnvironment /> element (idleTimeout setting).  He demonstrated this feature by attaching the EventLog with the health monitoring feature to write an event when the AppDomain unloads.  This feature is great for hosters because it will allow them to serve more customers on a single server (customers who have a small application with light traffic).
  • Small assemblies still take up 64k of memory.  Some customers run into problems when loading many, many (hundreds) of small assemblies in a worker process.  This leads to memory waste because there will be unused space lost between assemblies.  This situation is when someone has an application with way too many assemblies.  The real solution is to refactor the solution to collapse code into fewer assemblies, but hosters can’t always compel their customers to do that, so Microsoft is providing a mitigating solution for this scenario. 
    • This scenario could also happen with applications that use the App_Code directory many small assemblies are created at runtime.
    • SGEN is a new utility to combine assemblies into a fewer number.
    • Using Web Application Projects avoid this problem scenario because developer will decide how many assemblies their application needs.
  • Large directory structures:  ASP.NET relies on file change notifications.  This can hiccup with large directory structures.  This problem is expanded when the files are on a network share or network-area storage. 
    • One thing we can do is change the registry to configure FCN (file-change notifications) to “1”.  This will stop ASP.NET from spamming the network share with FCNs.  A side-effect is that changing the web.config won’t cause an AppDomain recycle automatically.  This is a solution to allowing the application file to be on a network share, but it’s a change to operational behavior.  No longer would the website be recycled, but when changing files, the recycle would have to be done manually.
    • For most of us, this problem will never come up, but it does occur with very large directory structures.
    • ASP.NET also recycles AppDomains when too many directory changes occur or too many file changes occur.
  • Other file-system changes:
    • New in ASP.NET 2.0, a directory deletion now causes an app-domain recycle.  Being aware of this can be beneficial if needing to delete directories.
      • A workaround for this is to make a directory junction using linkd.  This makes a virtual folder node.  File-change notifications don’t flow over virtual folders, so ASP.NET won’t receive the event, and the app-domain won’t be recycled.
  • Asynchronous page processing:  If a page has a long-running task (like calling a web-service of a 3rd party vendor), the page can set this to run asynchronously.  This releases the current thread back to the threadpool while the long-running call happens.  When the long-running call finishes, the request will grab a thread again and complete.  The allows the thread to be available in the threadpool for other requests when, otherwise, it would be sitting there doing nothing.  This helps application performance on a fewer number of threads.
  • Unhandled exception behavior: 
    • ASP.NET 1.1 suppressed unhandled exceptions on child threads.
    • ASP.NET 2.0:  The process is terminated.  This is a big change.
      • If this is a real problem for you:  go to the aspnet.config (in the framework directory) file and set <legacyUnhandledExceptionPolicy enabled=”true” />
      • To track down the error, you can trap the unhandled exceptioin event and log what happened before the process shuts down.
  • Caching
    • ASP.NET sets a limit of cache per process.  This is a problem if you try to shove 1GB of stuff into the cache.  Cache scavenging starts at 90% usage of cache.
    • We can use the perf counter to track:  ASP.NET Apps v2.0.50727 – Cache Total Entries.  What might happen is shoving a lot of stuff into the cache, and the system immediately starts to clean it up.  We can also avoid sliding expirations because it can cause stuff to never drop out of the cache.
    • Cache limits:  800MB is a normal limit for cache.  As an ASP.NET application is running over many days, virtual memory can become fragmented.  For a 32bit box with 2GB of memory, 800MB is safe for fragmentation.  X64 architecture makes this limit go away.
    • You can go into application pool settings for IIS and change the limits.  There is also a new <caching /> config section that can be used.


 [tags: TechEd]

Tech Ed 2006 Digital Photo Foldershare – Contribute your pictures – level 100

I’ve started a Tech Ed Foldershare for digital pictures.  Check
out if you don’t know how it works.  I’ve started
it off with some pictures of Party with Palermo.  I’ll make
everyone interested a contributor.

The end result of this is that for everyone who participates, we’ll all
get each others’ pictures.  Whatever pictures you contribute will
be passed around to all who sync up.

To get started, send me your email address, and I’ll invite you to the photo share. 

You can email me through my blog, and
I’ll send you a personal invite.  This can be really cool if we
have a handful of contributors.  This will also work if you just
want to get all the pictures but don’t have any to contribute. 
The main repository is on my personal server, so it’s online all the

[tags: TechEd]

Join the Chat Backchannels at Tech Ed 2006!! – level 100

I’m organizing some Chat Backchannels for the breakout sessions at Tech Ed.  Currently, a session is a speaker and a sea of people watching.  Chat Backchannels have been very successful in other events.  This is how it works.  Attendees who have laptops open up the chat screen during the session.  Participants can post questions and answers.  The bandwidth for communication and learning grows with the number of participants.  Perhaps someone wasn’t clear of the last point of the presentation.  Another attendee can help clarify, and it can have a pretty good debate as well!

Here is how it will work:

When you attend your session, log into MSN chat.  Go to a chat room with the name of the room you are in.  For instance, if you are in room 109 AB, go to room “teched109ab”.  Start the name with “teched” and finish it with the room name.  No spaces and all lowercase.  I’ve created some already, but if a room doesn’t already exist, create it.  You are the first one connected.  Other people will then connect, and the chat will begin.  Here are some links to some rooms:

When creating a room (if you have to), when you type in the name, make sure you munge it together and make it all lowercase so that others will find it when typing it in.

Pass the word.  This is a grass roots movement that I will be asking the speakers to support.  Please blog about this to pass the word.  If you know any speakers, encourage them to announce this at the beginning of their session to kick start the chats.

Party with Palermo (pre-Tech Ed party) final announcement – level 000

I posted earlier about the details of Party with Palermo 2006.  You can read the original post here.  Since the announcement, I’ve received tons of emails from folks who are planning to party with Palermo.  If you are coming to Tech Ed a day early, this is the place to be Saturday night.

Here are the details again.
Date/Time:  Saturday, June 10th @ 7:30PM until late, late, late
Location:  Millennium Bostonian Hotel’s Atrium Lounge (collared shirt required)
Who’s Invited:  Anyone who reads this.  Tell your friends.  Invite anyone and everyone.  Blog that  you will be attending.

the Atrium Lounge, we’ll have plenty of drinks, and they have a light
supper menu if you would like to grab something to eat as well.  The
lounge looks on to the Faneuil Hall market place as well, so the hotel is right in the heart of where everything is happening in Boston.

The Atrium Lounge has free WiFi Internet, so pictures could be uploaded in realtime.