CodeBetter.Com
CodeBetter.Com
RSS 2.0 via Feedburner
           Do you Twitter? Follow us @CodeBetter

Darrell Norton's Blog [MVP]

Fill in description here...

May 2005 - Posts

  • How to Use Design Patterns

    Bill Venners just posted Part 1 of an interview with Erich Gamma called How to Use Design Patterns. So why should developers learn patterns?

    "I think patterns as a whole can help people learn object-oriented thinking: how you can leverage polymorphism, design for composition, delegation, balance responsibilities, and provide pluggable behavior. Patterns go beyond applying objects to some graphical shape example, with a shape class hierarchy and some polymorphic draw method. You really learn about polymorphism when you've understood the patterns. So patterns are good for learning OO and design in general."

    Learning about patterns is also learning about Object Orientation, since patterns are OO applied to certain types of problems. Erich really liked the Head First Design Patterns book as a resource for learning patterns.

    Developers just starting to learn design patterns often suffer from design pattern-itis, that is, they think "I need a new object, so I'll use an Abstract Factory." But don't start your application with patterns:

    "Do not start immediately throwing patterns into a design, but use them as you go and understand more of the problem. Because of this I really like to use patterns after the fact, refactoring to patterns."

    That is why Joshua Kerievsky's book Refactoring to Patterns is such a crucial book. (I haven't studied it extensively yet, but I've read parts of it and it's excellent.) Not starting with patterns allows the architecture to emerge around an application's abstractions:

    "That's something you can often observe in mature designs. There are some key abstractions you often see as a design center, and around those key abstractions you want to achieve various things. So you see patterns growing out of such a center."

    Posted May 26 2005, 07:36 AM by darrell with 9 comment(s)
    Filed under: ,
  • Monoppix 1.0.6 is out

    Monoppix is a bootable Linux CD that runs .NET applications on the Mono framework. It makes it easy to see your .NET code running on Linux without installing a thing.

    Release Information

    This is mostly a stack upgrade release. Here's what's included in Monoppix 1.0.6:

    • Monodoc, mcs, Mono, libgdiplus, gtk-sharp 1.06
    • Xsp 1.0.8
    • Monodevelop 0.51
    • Cairo 0.2
    • (continued support of MySQL 4.1.7)
    • Included .Net in Samples book (HTML format)
    • Improved desktop links
    • Monodevelop bug fixes
      • Application execution directly from monodevelop is now fixed
      • The project type images are now properly displayed

    [via Jon Galloway]

    Posted May 25 2005, 07:41 AM by darrell with 5 comment(s)
    Filed under:
  • Working with Enums

    Geoff wrote a whole bunch of code for dealing with Enums. Enums are annoying because you can cast any integer to an Enum type and you will not get an exception message (at least in version 1.0 and 1.1). Geoff's solution uses the IsDefined static method on Enum, but using the IsDefined method really sucks.

    If I had a Flags enum, I'd write something like this (the one assumption I make is that the Flags enum is written with values in ascending order):

    .cf { font-family: Lucida Console; font-size: 10pt; color: black; background: white; border-top: windowtext 1pt solid; padding-top: 0pt; border-left: windowtext 1pt solid; padding-left: 0pt; border-right: windowtext 1pt solid; padding-right: 0pt; border-bottom: windowtext 1pt solid; padding-bottom: 0pt; } .cln { color: teal; } .cb1 { color: blue; } .cb2 { color: maroon; }
     1 Module Module1
     2  
     3   Sub Main()
     4     For i As Integer = 1 To 20
     5       Console.WriteLine("Number: " + i.ToString() + "  " + IsValid(i).ToString())
     6     Next
     7   End Sub
     8  
     9   <Flags()> _
    10   Public Enum MyEnum
    11     Val0 = 0
    12     Val1 = 1
    13     Val2 = 2
    14     Val3 = 4
    15     Val4 = 8
    16   End Enum
    17  
    18   Public Function IsValid(ByVal val As Integer) As Boolean
    19     Dim values As Integer() = System.Enum.GetValues(GetType(MyEnum))
    20     Return val < (values(values.GetLength(0) - 1) * 2)
    21   End Function
    22  
    23 End Module
    
    Posted May 25 2005, 07:37 AM by darrell with 2 comment(s)
    Filed under:
  • Visual Studio Hacks excerpts available

    5 hacks from James Avery's book Visual Studio Hacks are available on OnDotnet. Note that I am not an impartial commentator, since I wrote hack #5. 

    Posted May 24 2005, 10:57 AM by darrell with no comments
    Filed under:
  • Head First .NET code samples updated to use delegates

    I left a comment yesterday that Mark McFadden's code samples for the Head First Design Patterns book didn't use delegates. This morning I check my email and note that he's already finished a new code sample. Great job, Mark!

    Posted May 24 2005, 10:49 AM by darrell with no comments
    Filed under:
  • TechEd 2005: Party with Palermo on Saturday

    Are you going to TechEd? Are you arriving on Saturday?

    If so, then you need to Party with Palermo!

    We're meeting at the Peabody Hotel right across the street from the conference center. The itinerary is:

    4:00PM - Arrival begins.  meet and greet.  Discuss conference sessions, etc.  Networking.
    6:00PM - Geek Dinner.  Jeff has reserved for 20, but will adjust the reservation as necessary.
    7:30PM - Drinks and conversation at the hotel bar.
    Depart whenever.

    Sign up here!

  • VCU wins Imagine Cup

    Right in my backyard, VCU students win US Imagine Cup. Congrats, fellas!

    Jeesh, VCU is literally less than a block from where I work (when I'm not on the road, anyway). Time to crank up the recruiting!

    Posted May 23 2005, 01:54 PM by darrell with 1 comment(s)
    Filed under:
  • Free project management tools

    Posted May 20 2005, 01:50 PM by darrell with 1 comment(s)
    Filed under:
  • Head First Design Patterns book now has C# code samples available

    Mark McFadden has made the excellent Head First Design Patterns book's code samples available in C# here. He even uses NUnit instead of Console.Writelines. Great job, Mark!

    Posted May 18 2005, 09:00 AM by darrell with 5 comment(s)
    Filed under: ,
  • Star Wars Merchandising

    With everyone getting all hyped up about Star Wars III, I thought this would be appropriate (a parody of the "wear sunscreen" column). Just change Episode I to Episode III. [see the original article]

    If I could offer you only one tip for the future, Star Wars Episode 1 Merchandising would be it.

    The long term profits from buying Star Wars merchandising have been consistently stated by collectors, who's "Wookie with bowcaster still in its original box" is now worth enough to put all their kids through college, whereas the rest of my advice has no basis more reliable than my own meandering experience. I will dispense this advice now.

    Enjoy the power and beauty of your Death Star. Oh, never mind. You will not understand the power and beauty of your Death Star until its been blown up, twice.

    But trust me, as you tumble down the shaft towards the main reactor you'll look back and realize that putting a lid on that exhaust port would have solved this whole problem in the first place.

    You are not a Jedi yet, young Skywalker.

    Don't worry about the fact that young Anakin and Queen Amidala are supposed to do-it in the next film. Or worry, but know that worrying is about as effective as the world and his dog telling Lucas the Jar Jar sucks.

    The real troubles in the next film are likely to be plot and casting choices that you'd have never made yourself in a drunken fit.

    Go and see the film once a day until it bores you.

    Sing along with the theme tune.

    Quit moaning about how certain aliens sound like Japanese or Jamaicans. Don't put up with people who can't quit moaning about it.

    Do or do not, there is no try.

    Don't waste your time betting on Sebulba.

    Sometimes Anakin was ahead and sometimes he was behind. The race was long, but you knew, in the end, he had to win it.

    Keep the good bits of the films and edit out the mindless dross. If you succeed in doing this, please send me a copy.

    Keep your old film posters. Throw away your old cinema tickets.

    Trust in the force.

    Don't feel guilty if you don't know when you're going to grow up and get a life. The most interesting people I know were having lightsaber battles with their friends at 22. And at age 50, George Lucas owns half of California.

    If you're a stormtrooper, get plenty of your mates before trying ANYTHING!

    Learn to speak over 3000 languages yourself and shoot your protocol droid. Believe me, you won't miss it when it's gone.

    Maybe you'll finish what you've begun, maybe you wont Maybe you'll become a Jedi, maybe you wont.

    Maybe you'll reach your 800th birthday, but look this good you will not.

    Whatever you do, don't congratulate yourself too much or berate yourself too harshly. Your choices are half guided by the force and so are everybody else's.

    Enjoy the force. Stretch out with your feelings. Don't be afraid of what some burnt out old smuggler who can do the Kessle run in under 3 parsecs might think of you. He's just jealous.

    Dance, even if you have nowhere else to do it than at the end of a long chain in Jabba's palace.

    Ignore the person who has a bad feeling about this, everybody else does.

    Don't ever read the reviews in film magazines. They'll only tell you what some bitter old has-been film critic thought.

    Get to know your family. Or run the risk that the girl you're trying to score and your arch enemy will turn out to be your sister and your father.

    Be nice to wookies. They're seven feet tall, bad tempered and you never know when they might rip off your arms and beat you to death with the wet bit.

    Understand that blockbusters come and go, but with a precious few flics you should hold on. Work hard to bridge the gaps of credibility and consistency, because the older you get, the more you're going to think that everything they release these days is crap.

    Live on Alderan once, but leave before it gets blown to smithereens. Live on Tatooine once, but leave before you become a moisture farmer.

    Drool at the special effects.

    Accept certain inalienable truths: plots will have inconsistencies, special effects will take priority over script, and the comic sidekick will annoy the hell out of you. And when he does, you will fantasize that when you were young, plots were always consistent, the scripts were so sharp you could cut yourself and the comic sidekicks were NEVER as bad as Jar Jar.

    Worship Bobba Fett.

    Don't expect to beat the rebel alliance. Maybe you'll have 20 of your best legions on the surface Endor moon. Maybe you'll have the entire star fleet and a frikin Death Star in orbit around it. But you never know when 200 furry Muppets and a fleet of space gypsies are going to blow you all to hell.

    Don't mess with Obi-Wan Kenobi, or by the time your 40, you'll sound like someone who breaths with the aid of a dustbuster.

    Be careful which films you buy the directors cut of, but be patient with the directors that supply them. Releasing a directors cut, wide-screen, remastered edition is a form of rip-off. Dispensing it is a way of taking the same move, adding in 30 seconds of extra footage and selling it to the same bunch of spineless zombies that bought the last 5 editions.

    But trust me on the merchandising...

    by Cathal O' Siochru
    (with thanks to Baz Lurman and George Lucas)

  • Keeping NUnit config files in sync

    When doing Test-Driven Development with NUnit, you can add an application config file by adding a file called AssemblyName.dll.config to the executing directory. In VB it's not a problem since the bin directory is it (you could just add the config file to the bin directory and "include in project"), but in C# there is a Debug and a Release subdirectory under bin depending on the Visual Studio solution configuration.

    The problem is getting your NUnit config file into those directories without having to maintain two copies. The answer is Build Events, specifically post-build events.

    First, add an App.config file to your unit test project. Copy everything from your current AssemblyName.dll.config file into the App.config file. The problem is if your project is a class library, Visual Studio won't rename the file and copy it to the output directory like it does with a Windows Forms project.

    Now right-click on the unit test project, select Properties, and select Build Events. Click the ellipses (...) next to Post-build Event Command Line. This will open up a batch file editor. Click the Macros >> button to see which macros are available to you. It even shows you the values you can expect given your current project configuration.

    That was just handy information for your benefit. Here is the post-build event you would use to copy your App.config to the output directory and rename it to AssemblyName.dll.config (copy and paste):

    copy /Y "$(ProjectDir)App.config" "$(TargetDir)$(TargetFileName).config"

    Now when you rebuild your project, the App.config file will be renamed to AssemblyName.dll.config and copied to the output directory so that NUnit can access it for configuration information. Note that this should work for VB too, in case you want to keep source-controlled files out of your bin directory. Simple!

    Posted May 13 2005, 08:39 AM by darrell with 16 comment(s)
    Filed under:
  • WeProgram.NET Meeting Thurs, May 12

    Don't forget the WeProgram.NET user group meeting tonight! I'll be giving my Using Test Driven Development with Database Applications presentation. Of course there will be plenty of free swag just for showing up!

    Get directions and show up, no need to RSVP. I hope to see you there!

    Posted May 12 2005, 12:38 PM by darrell with 2 comment(s)
    Filed under:
  • Test Driven Development with a Database

    My slides, code, and SQL scripts for the TDD with a Database session are now available from the MAD Code Camp web site.
    Posted May 10 2005, 07:48 AM by darrell with 3 comment(s)
    Filed under: ,
  • Extreme Programming Explained: 2nd ed - Part 4

    Last time we looked at the various members of the XP team. Now let's take a look at one of XP's hardest disciplines, that of simple design. Here is the criteria for simple designs (from chapter 14):

    1. Appropriate for the intended audience. It doesn't matter how brilliant and elegant a piece of design is; if the people who need to work with it don't understand it, it isn't simple for them.

    2. Communicative. Every idea that needs to be communicated is represented in the system. Like words in a vocabulary, the elements of the system communicate to future readers.

    3. Factored. Duplication of logic or structure makes code hard to understand and modify.

    4. Minimal. Within the above three constraints, the system should have the fewest elements possible. Fewer elements means less to test, document, and communicate.

    In XP, programmers always try to write the simplest code that could possibly work. This does not mean that there is no design, it's just not done all up-front. This is where the construction metaphor, that software development is like building a bridge or a skyscraper, is harmful and limiting to our profession. Software is just that, soft. Keeping the design simple postpones the decision on how to design something until the last responsible moment. This gives the design as much time to learn from experience and evolving requirements as possible without unduly damaging the design by waiting too long to implement it (waiting too long would be past the last responsible moment). Keeping the design simple also enables XP teams to move faster since they have less baggage to lug around (code to maintain).

    You can argue that both construction and software development can postpone decisions until the last responsible moment. That is true, however, in programming the code is the design and the last responsible moment can occur much later in the process than in construction. Take a house for example. You can make changes to the architectural blueprints all you want for free, but after the foundation of your house is poured if you want to add 10 feet extra to the back of the room, that's going to cost you a lot. In software, if the design has been developed properly with time-proven OO techniques, adding an extension to the system can as simple as adding a class.

    The most important point to remember is that just like agile methodologies are planning-driven not plan-driven, XP is designing-driven not design-driven.

    From Extreme Programming Explained: 2nd ed

    Posted May 10 2005, 07:44 AM by darrell with 4 comment(s)
    Filed under:
  • MAD Code Camp review

    The MAD Code Camp was great! Like Sahil said, if you missed it, what were you thinking?!

    It was great meeting Julie Lerman, K Scott Allen, Jonathan Cogley, Wally McClure, Eric Kepes, Brian Noyes, Vishwas Lele (Microsoft Regional Director in Virginia) and of course fellow CodeBetter blogger Sahil Malik.

    Andrew Duthie did a great job. Many thanks go out to him for organizing the whole thing, and thanks to all the volunteers that made it happen, especially Robin Edwards (Roanoke Valley .NET user group President) who organized the MULTIPLE feedings. There were lots of book giveaways in addition to the code and knowledge sharing!

    One of the things Andrew unveiled is the Mid-Atlantic .net User Group Portal. At this site all of the Virginia, Maryland, DC, and West Virginia user groups can share info/speakers, user group members can see a unified district speaker schedule, find the closest user group, etc. If you are a user group leader, add/update your user group info, and if you're a member, check it out for some interesting semi-local events you may not know about.

    Posted May 09 2005, 10:15 AM by darrell with 3 comment(s)
    Filed under:
More Posts Next page »

Our Sponsors