The Artima Developer Community
Sponsored Link

.NET Buzz Forum
OpenPGP.NET - Part 3 - Refactoring

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Peter G Provost

Posts: 849
Nickname: pprovost
Registered: Aug, 2003

Peter G Provost is a Solution Architect for Interlink Group in Denver, CO.
OpenPGP.NET - Part 3 - Refactoring Posted: Sep 19, 2003 2:27 PM
Reply to this message Reply

This post originated from an RSS feed registered with .NET Buzz by Peter G Provost.
Original Post: OpenPGP.NET - Part 3 - Refactoring
Feed Title: Peter Provost's Geek Noise
Feed URL: /error.aspx?aspxerrorpath=/Rss.aspx
Feed Description: Technology news, development articles, Microsoft .NET, and other stuff...
Latest .NET Buzz Posts
Latest .NET Buzz Posts by Peter G Provost
Latest Posts From Peter Provost's Geek Noise

Advertisement

Next up on my list was to implement Literal Data Packet (I know I said Literal Message but I can't do messages until I have packets done).

So as not to bore you all I'll just say that I did exactly what I did last time, but this time I followed the RFC spec for Literal Data Packet instead of User ID Packet.

Everything worked out just fine. But, as I'm sure you expect, I ended up with a lot of duplication in my code for the ParsePacket methods.

In fact the only significant difference between the two implementations was where and how the content from the packet body gets stored. This only makes sense, of course, because there is a common packet header structure here. But since I'm following TDD here, and since I also am a strong believer in the DRY principle (Don't Repeat Yourself), I waited until I had working tested code before refactoring out the duplication.

Now I also am an experienced developer who has been around the block before. I also happen to have a spec in front of me that I know isn't changing. So I can take a wee look into the future to see what I will need.

I decided that it would be useful to have a class called PacketReader that knows about the structure of a generic packet and how to read it from a Stream. So I dropped back into TDD mode and wrote a test class called PacketReaderTests. By working my way through the TDD green light, yellow light, red light routine I was able to get a simple class working that understood how to read the header of a stream and how to translate the body using UTF-8 encoding.

Next I removed all of that code from my UserIdPacket and LiteralDataPacket classes and ran all of the tests again. Green bar! Woo hoo... refactoring complete.

PS. I know I went fast through this but I figured another detailed discussion of TDD was unneccessary.

Read: OpenPGP.NET - Part 3 - Refactoring

Topic: Mono starts playing the WSA/WSE blues Previous Topic   Next Topic Topic: Gartner: Don't Rely on Anti-Virus Support from Microsoft

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use