September 2003 - Posts

Filter Feedgregator Feeds by keywords

I almost forgot to mention that you can filter the items that are included in an aggregated feed by adding a <keywords>Whidbey, Avalon</keywords> tag to the Feedgregator config file.  Feedgregator will look for the string in the title and description of the Rss Item and if found the item will be included in the final feed.

Feedgregator Beta

If anyone is interested in trying out Feedgregator you can grab the install for it at:

www.emxtechnologies.com/feedgregator/feedgregatorsetup.msi

The setup installs the Feedgregator core dll's, the Feedgregator Service, as well as the Feedgregator Console application.  Feedgregator uses a slightly modified version of the Rss.NET components as well as log4net.  The feedgregator.config file has one entry for the blogs.gotdotnet.com feed so if you want to add additional “feedgregator feeds” just add another entry to the config file.  I think the properties specified in the config file are pretty self explanatory but in case not below is a brief overview:

opmlPath - The path to the opml file containing all the feed to aggregate into the single Feedgregator Feed.
title - The title for the aggregated feed.
link - The value for the link file in the generated Rss.
numberOfItems - The number of items to include in the feed.
outputFile - The location the generated feed should be output.
updateInterval - The number of seconds between updates.

<feedgregator>
    <feedgregatorFeeds>
        <feedgregatorFeed>
          <opmlPath>http://blogs.gotdotnet.com/blogs.opml</opmlPath>
          <title>Blogs@GotDotNet Unofficial Feed</title>
          <link>http://www.emxtechnologies.com/gotdotnetblogs/mainfeed.xml</link>
          <numberOfItems>50</numberOfItems>
         <outputFile>c:\Inetpub\wwwroot\gotdotnet-feed.xml</outputFile>
          <updateInterval>30</updateInterval> <!-- in seconds -->
       </feedgregatorFeed>
    </feedgregatorFeeds>
</
feedgregator>

If you have any questions, comments, or suggestions please leave them in the comments.  For a little more background on Feedgregator check out my original entry on Feedgregator.

Specifying a prefix for a [XmlElementAttribute]

I received a number of requests for the addition of the dc:creator tag to the items in the unofficial blogs.gotdotnet.com main feed.  To create the main feed I'm leveraging the classes Chris Anderson wrote for BlogX.  To add the dc:creator tag to the main feed I tried adding a Creator property in the RssItem class with a [XmlElement(“dc:creator“)] attribute.  Well I quickly found out the Xml Serializer does not like a colon in the element name.  Rather then spend the time figuring out why the serializer doesn't like the colon I changed the dc:creator to author.   Please ignore my ignorance in regards to the Rss spec, but, what is the difference between dc:creator and author?  Is there a reason to use one over the other?  SharpReader doesn't seem to care so at this point neither do I.

I'll be looking a little more into why the colon in the XmlElement attribute causes problems as well as some possible workardounds to other ways in which one can have a prefix on a serialized property via the [XmlElementAttribute].  If anyone has any  insight please share! 

In summary...

  • The unofficial blogs.gotdotnet.com main feed now has the author specified for the items
  • The Xml Serializer doesn't like a colon in the element name of the XmlElement attribute. Reasons and workarounds will hopefully be provided in a later post OR by one of you ;-)

Encrypting connection strings, continued...

This past week I added support for encrypted connection strings to one of the .NET apps I've been working on.  We recieved a set of requriements from the client that said something like this:

  • The connection string needed to be encryped using a particular type of encryption.
  • The encrypted connection string needed to be stored in a file located in a common system location (ex: C:\WinNT\System32)
  • The location of the file, as well as the passphrase for encrypting/decrypting the connection string has to be hard coded into an assembly.

To implement this functionality I created a couple of simple encryption classes as well as an Encrypted File class.  The Encrypted File class exposed a Read and Write method for reading and writing the contents of the file and performing the necessary encryption and decryption (imagine that!).

The application is currently running in 10 or so environments with 5 different database servers.  To allow us (and the client) to easily update the encrypted connection string, as well as the assembly containing the path to the file and passphrase, I created a simple WinForms application.  The WinForms app prompts the user for the final destination for the encrypted file, the name for the generated assembly, the connection string, and finally the passphrase for encrypting the string.  After the user enters the required information the WinForms app generates the file along with the assembly for reading the connection string.  The file is dropped in its final resting place, and the assembly is dropped into the web applications bin directory and away we go.

If the client had not provided such clear requirements for where and how they wanted the connection string stored I probably would have taken another route, however, it ended up being a decent solution.

I thought of a couple enhancements while implementing the feature that could be useful outside of this specific application:

  • Enhance the WinForms app to allow a set of key/value pairs to be entered so multiple settings could be provided in a single file.
  • Provide support for encrypting .config files.
  • Provide a plugin architecture using some of Roy's code so that new settings could be dropped in.

NOTE: Does anyone know if there's a way to obfuscate an assembly generated with CodeDOM using code? 

Encrypting connection strings, continued...

This past week I added support for encrypted connection strings to one of the .NET apps I've been working on.  We recieved a set of requriements from the client that said something like this:

  • The connection string needed to be encryped using a particular type of encryption.
  • The encrypted connection string needed to be stored in a file located in a common system location (ex: C:\WinNT\System32)
  • The location of the file, as well as the passphrase for encrypting/decrypting the connection string has to be hard coded into an assembly.

To implement this functionality I created a couple of simple encryption classes as well as an Encrypted File class.  The Encrypted File class exposed a Read and Write method for reading and writing the contents of the file and performing the necessary encryption and decryption (imagine that!).

The application is currently running in 10 or so environments with 5 different database servers.  To allow us (and the client) to easily update the encrypted connection string, as well as the assembly containing the path to the file and passphrase, I created a simple WinForms application.  The WinForms app prompts the user for the final destination for the encrypted file, the name for the generated assembly, the connection string, and finally the passphrase for encrypting the string.  After the user enters the required information the WinForms app generates the file along with the assembly for reading the connection string.  The file is dropped in its final resting place, and the assembly is dropped into the web applications bin directory and away we go.

If the client had not provided such clear requirements for where and how they wanted the connection string stored I probably would have taken another route, however, it ended up being a decent solution.

I thought of a couple enhancements while implementing the feature that could be useful outside of this specific application:

  • Enhance the WinForms app to allow a set of key/value pairs to be entered so multiple settings could be provided in a single file.
  • Provide support for encrypting .config files.
  • Provide a plugin architecture using some of Roy's code so that new settings could be dropped in.

NOTE: Does anyone know if there's a way to obfuscate an assembly generated with CodeDOM using code? 

The Skeptics View of Agile

UPDATE: Darrell Norton has provided a very in depth response to each of the concerns in his Agile conerns with responses post.  Thanks Darrell!!

Darrell asked for some of the viewpoints from the skeptics so here's some of what was said yesterday from the Waterfall side of the “room“.  Keep in mind this was meant to be a debate so being in between wasn't really allowed.  As you can see it made for some interesting comments and concerns.

  • Too disorganized
  • How does the customer really make out any better?
  • Won't it cost the customer more?
  • How can we really control and manage changes in this environment?  Won't we just be going back over and over to change what we've already done?
  • Do you need to have Attention Deficit Disorder (ADD) to be a fit with agile?
  • It's too difficult to sell that type of process to clients. 
  • Our clients won't want to have that level of responsibility, they just want to hand us a document describing what they want and have us come back in 3 months with a finished “product”.
  • Our clients our too busy with other things, they won't be able to give us the time and energy needed.
  • So what happens to our QA staff?
  • So if a client has the ability to end a project after an iteration how do we schedule resources and forcast revenues?  Doesn't that add a lot of risk and uncertainty?
  • Sounds too risky?  Waterfall is much more conservative and stable, I like stability.
  • Don't resources need to be able to do everything?  Isn't it hard to find people like that?
  • How do you know when your done?
  • How do you handle changes in scope?  I know its embraced but how do you actually manage all the changes? 
  • Customers will want more documentation.

Working software over pretty diagrams

You just gotta love this quote!

Ultimately, I am a pragmatist. I would much rather construct working software than pretty diagrams.
http://christiansepulveda.com/blog/archives/000031.html

Waterfall vs. Agile Methodologies

Today in our weekly tech meeting we had a debate on classical waterfall vs. agile development methodologies.  I provided the topic for debate so I obviously have some strong feelings on the subject. 

Let me start with a little background.  Almost all of the development work that we currently do follows a slightly modified waterfall methodology.  The project is broken down into discrete phases and once a phase is complete there isn't much going back.  On the whole we've actually made out pretty good following this methodology.  Generally our clients are pretty darn happy with us (as can be seen by the amount of repeat business we do)!  Now with that said, I think we can do better.

Our clients are happy but it is often at the expense of our profits and employees.  Requirements change as they always will and we often times end up eating the cost of the change to make sure we delight the client.  At times we do use Change Orders to ensure we don't eat too much of the cost for the client changing their mind and we do at times come out better then expected.  I'm not interested in doing it at times. 

Moving to an agile approach is something that I'm trying to move toward both in my personal development efforts as well as overall in the department.  I've *blogged* about many of the the agile approaches I've been advocating internally.  NUnit is now something everybody knows about, Nant is almost there, and hopefully CruiseControl.NET won't be far behind.  These agile “tools” along with the practices that they foster are generally accepted within the department.  What I came to find out today is that many of the agile methodologies which are used to drive agile projects will take some more convincing.  Many of the individuals in the department where hearing about how an agile software development projects works for the first time, and as expected they were pretty skeptical.

As I've stated many times before I still have some concerns and questions of my own.  Agile methodologies are not a silver bullet.  Projects can still go terribly wrong.  I'm hoping that moving to an agile approach will result in our clients being even more delighted, as well as our employees! 

Individuals and interactions over processes and tools
Working software over comprehensive documentation
Customer collaboration over contract negotiation
Responding to change over following a plan

CodeDOM + Reflection does indeed ROCK!

Jan Tielens' post entitled Being flexible: CodeDom + Reflection = Killer Combo provides another nice example of the power that CodeDOM/Reflection.Emit and Reflection can provide.  I'm using the combo all over the place in my entity framework.  Just to shed some light on some other places that Reflection and CodeDOM could be used let me share some examples of how and where I'm using it:

  • Persisting entity objects to the data store - Each property of an entity object that needs to be persisted gets marked with a [Persist] attribute.  When the .Save() method is called on an entity object the framework checks to see if it has an object that knows how to save the particular type of object in its “Assembly Cache“.  If it doesn't it generates an assembly by reflecting on all the properties of the object.  Each property that has the [Persist] attribute defined has the necessary code included in the generated assembly for it to be persisted.
  • Loading entity objects from the data store - When entity objects are loaded from the data store the framework uses a similar technique as described above.  By default all properties are loaded, so unless a property is marked with a [NonLoaded] attribute the dynamically generated EntityLoader object will include it in the load.  The framework checks to see if an object for loading the particular type of object is in its Assembly Cache, and if not is uses reflection to generate the code to read the data out of the data source and into the entity object.
  • Validating entity objects - Custom attributes defining validation rules for the entity object can be applied to the properties of an object.  The framework then reflects on the properties of an object looking for ValidatorAttribute's.  The framework then uses the meta data provided by the attribute to generate an assembly to check that an entity object is valid.

public class Customer {
     // private vars defined ....
     [Persist, Required, MaxLength(50)]
     property string CustomerName
     {
            get {...  }
            set { ... }
     }
}

 

public Customer GetByCustomerCode(string customerCode)
{
    return (Customer) FindByPropertyValue("CustomerCode", customerCode);
}

When the FindByPropertyValue method is called it searches in the assembly cache for an assembly that can be used to perform the “Find”.  If it can't be found it goes out and creates it.

Overall I love the power and flexibility that Reflection, CodeDOM,  and .NET provides.  I'm able to create “assembly generators” once for all my objects rather then being forced to write the same repetitive code over and over for every type of object.

Where has the coding gone?

Over the past couple of weeks I've been on a lot of “cleanup” and “maintenance” projects.  The tasks on these types of projects tend to be pretty lame.  QA finds a bug and assigns it to you.  You go find it in the code, laugh at the ridiculous way the original developer implemented it (most of the time you), and then refactor the code to fix the error and clean up the original mess.  Then you do a little documentation on the error, assign it back to QA and hope it gets closed.  Then onto the next bug!  Oh the excitement!  Oh the glory! 

What I've missed most during the last couple of weeks is the process of actually coding.  Sure I've written code, but its that boring kind of code that everyone hates to write.  Unfortuntely for me I don't see a lot of exciting coding opportunities coming up in the next couple of weeks at work.  On the brighter side I do have lots of side projects that I've been wanting to get started on. 

Deleting lots and lots and lots of data from a Sql Server table

We just had an interesting discussion among our team regarding the best way to remove a very large number of rows from a database without having the transaction log grow out of control.  The scenario is something like this:

  1. Need to delete 50 billion rows from a table
  2. Need to do it when there is only 4 G of hard drive space on the server
  3. Cannot turn off logging for the entire database

At this point the only option that we've come up with is creating a stored procedure that deletes a range of records and then shrinks the database, as well as the transaction log.  The execution of the stored procedure would delete approximately 250,000 records at a time. 

Unfortuntely when posed with the question of how to best accomplish this feat this is all I (as well as others) could come up with.  Is there a better way?

Updated reading list

Its been a while since I've seen anyone post their reading list so I figured I'd start the madness...

  1. Surviving Object Oriented Projects
  2. The Mythical Man Month
  3. Agile Software Development - round 2
  4. Dynamics of Software Development
  5. Programming .NET Components
  6. Good to Great

I think I need to stop buying books for a while until I catch up!

Commenting out unused code

Whats the point of commenting out unused code?  I can understand, and even advocate, doing it while updating peices of logic within a class, however, there is a point when you should clean up all the obsolete code and make sure your “broken windows” don't lead to even more broken windows.  The past week or so I've been helping out with some bug fixes on a project and ran into an unbelievable amount of commented out code.  Now, we are using source control on the project aren't we?  Isn't that the job of the version control system?  Rather then comment out code that is no longer needed just take the plunge and delete it.  The old code will always be safely stored away in the history of your source control system.

Continuous Integration server for .NET

CruiseControl.NET is an automated Continuous Integration server for the Microsoft .NET platform. It is a functional port of the Java-based CruiseControl to the .NET platform. -  http://continuousintegration.org/

I had a little free time last night and decided to spend it investigating CruiseControl.NET.  Overall it looks awesome.  CC.NET monitors your source code repository and kicks off a new build when modifications are made.  The web front end allows you to view the results of builds, associated tests, and any resulting warnings/errors.  I will most certainly be using this on my next project to further improve our continuous integration process.  Anybody know when ThoughtWorks will be opening an office in Philly? :-)

Continuous Integration server for .NET

CruiseControl.NET is an automated Continuous Integration server for the Microsoft .NET platform. It is a functional port of the Java-based CruiseControl to the .NET platform. -  http://continuousintegration.org/

I had a little free time last night and decided to spend it investigating CruiseControl.NET.  Overall it looks awesome.  CC.NET monitors your source code repository and kicks off a new build when modifications are made.  The web front end allows you to view the results of builds, associated tests, and any resulting warnings/errors.  I will most certainly be using this on my next project to further improve our continuous integration process.  Anybody know when ThoughtWorks will be opening an office in Philly? :-)

Encrypting information in .config files

One of the features that I've been meaning to add to my reusable entity framework is support for encrypted key/value pairs in .config files.  A couple of weeks ago I came across CipherLite.NET™ that looks to provide a pretty good solution to storing configuration data in encryted form.  Another option I've considered is implementing something similar to the ASP.NET Impersonation functionality that allows you to store an encrypted username/password in the registry.

Encrypting information in .config files

One of the features that I've been meaning to add to my reusable entity framework is support for encrypted key/value pairs in .config files.  A couple of weeks ago I came across CipherLite.NET™ that looks to provide a pretty good solution to storing configuration data in encryted form.  Another option I've considered is implementing something similar to the ASP.NET Impersonation functionality that allows you to store an encrypted username/password in the registry.

Don't Live with Broken Windows

More from The Pragmatic Programmers:

“That is a true story. A former accountant of mine in Connecticut lived in a very up-scale, wealthy section of town. This guy lived in a super mansion. He had a tapestry hanging on his wall a little too close to his fireplace, and one day it caught fire. The fire department rolled in. The fire was blazing. The house was about to go up in flames. But the fire department did not simply come charging in the front door. They opened the front door, and they rolled out a little carpet. Then they brought their filthy dirty hoses on their carpet and put the fire out. They rolled their carpet back up and said, thank you very much.

Even with the fire raging, the fire department took the care to put down the carpet and keep their hoses on it. They took extra special care not to mess up this guy's expensive mansion. It was a crisis, but they didn't panic. They maintained some level of cleanliness and orderliness while they took care of the problem. That's the kind of attitude you want to foster on a project, because crises do happen. Stuff bursts into flame and starts to burn up. You don't want to go running around crazy and causing more damage trying to fix it. Roll out the carpet. Do it right.”
- http://www.artima.com/intv/fixit.html