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

Jeffrey Palermo (.com)

Blog moved to www.jeffreypalermo.com

April 2005 - Posts

  • Great VS add-in for doing TDD - TestRunner from MailFrame.net - level 200

    Anyone who is doing TDD with .Net _must_ check out TestRunner from MailFrame.net!  It brings the hierarchy of tests into a VS pane and allows you to select and run tests just like NUnit, but from within VS.  It uses the NUnit core and frameworks internally.  It's free for personal use, but only $49 for commercial use!  Here is a screenshot:

     

  • My "Agile Methodologies with .Net" Birds of a Feather session accepted for Tech Ed. - level 300

    I excited to announce that my “Agile Methodologies with .Net” Birds of a Feather session was accepted for Tech Ed 2005!  Thanks to all who voted for it, but more importantly, I'm excited that there are many people interested in doing Agile development with .Net.

    Here is a quote from the email I received:

    “We’ve heard the feedback loud and clear from previous conferences: a Birds of a Feather session is a discussion; it is not a presentation, lecture or breakout session. Birds of a Feather sessions fill a niche in the conference – it is an opportunity for attendees to connect and interact directly with one another, to be part of their community.”

    I hope to be able to facilitate a great discussion where we can all learn from each other.

    This session will be on Wednesday, June 8th at 7:45PM.

  • Advocating Agile in a CMM or MSF shop - level 200

    That's exactly what I'm doing right now.  My development shop used to be MSF waterfall and is now pushing for CMM.  This is a push from management.  It is very difficult to write good, maintainable software in this fashion.  Sure, we can crank out version 1 and maybe 2 without a hitch, but as soon as the developers who intimately know the software leave, or forget, you immediately have legacy code.  You don't know what you can change without breaking other things.

    I don't recall from whom I heard the quote, but I've heard it said that:

    Legacy code is code for which there are insufficient unit tests.

    I could not agree with that more.  I'm the pusher for TDD in my work group, so it's difficult getting there, but there is a significant difference in the code that is written using TDD and the other code that exists (and is being added) without unit tests.  The design is different too (TDD is design).  It is incredibly obvious that 1) the TDDed code has fewer bugs and can be changed with confidence, and 2) The other code is a ball of mystery (legacy) that you don't want to touch for fear of unforeseen consequences.

    Another Agile practice I'm pushing is automated builds.  Our build is scheduled to run twice a day.  It does everything to get the new source built an on a development server.  It runs the unit tests and reports.  I use NAnt for that, and it works very well.  I intend to hook up FxCop and CruiseControl.Net to our build process soon.

    One thing I'm not sure will change is the manner in which we plan projects.  Our project managers _must_ use CMM in their planning, so it's probably a losing battle right there.  The schedule will be set, the features will be planned, the headcount will be assigned, and then it's expected that the team deliver 100% of the scope on the due date.  No incremental releases with requirements verification and reprioritization, but pure waterfall.  Plan phase, dev phase, stabilization phase, and deploy.  Then 5 years down the road, replace the app because it's become hard to maintain, but create the new app in the exact same manner.  It's quite confusing.

    I also have some more general observations about much of the industry as a whole.  I've heard when replacing an application that "we're going to do it right this time".  I firmly believe that the first go-round was not preceded with the thought "let's do it wrong this time", yet when we identify that an app has turned out to be unmaintainable, and it needs to be replaced, why don't we identify the reasons it became unmaintainable?  Why don't we fundamentally change the way the new app is written because just rewriting an app using the same process as the first is going to get the same result as the first.

    If an application needs to be replaced, we should analyze why it failed.  If it didn't fail, and we just want to move to a new technology, then pieces of it should be wrapped and leveraged in the new app.  If that can't be done, then I would say the old app failed.  It can't be reused.  It's life is over.  Going a step further, if you absolutely want all the code to be in the new technology, then just port the code.  If _that_ can't be done, then the app is a failure.  The app is dead.

    Agile methods, coupled with able developers,  promise (and deliver) maintainable, well-designed software that will never become a rigid legacy application.  As the word implies, the application will remain agile.

  • What a great list of tools to use for Agile development! - level 300

    Jeremy Miller has posted a great list of tools he's currently using in his Agile shop.  I've using a few, but I'd like to use more.

    http://jeremydmiller.blogspot.com/2005/04/bypass-vsts-and-get-yourself-poor-mans.html

  • Tech Ed Pre-Party update - level FUN

    I received some good responses from my initial announcement of a party on Saturday, the day before the PreCons.

    We're only about 5 weeks away, so I need to start getting a list of people who are planning on being there.  A comment to this post is adequate.

    Also, if anyone would like to help me plan the event, please chime in.

  • Affecting your .Net SOAP message through attributes - level 300

    With the .Net implementation of web services, you can design the schema of a web service call without having to author WSDL by hand.  I won't discuss contract first here.  I recognize that many are happy with the default .Net implementation of a webservice.  It is possible to easily affect the Xml format of the SOAP envelope, however.  Mainly, you need to define the Xml structure of the SOAP envelope.  By default, .Net makes nodes with your parameter names, like so:

      146 [WebMethod]
      147 public int Foo(string firstParam, string secondParam) {return 0;}
    POST /webservicetest/movie.asmx HTTP/1.1
    Host: localhost
    Content-Type: text/xml; charset=utf-8
    Content-Length: length
    SOAPAction: "http://palermo.cc/Foo"
    
    <?xml version="1.0" encoding="utf-8"?>
    <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
      <soap:Body>
        <Foo xmlns="http://palermo.cc">
          <firstParam>string</firstParam>
          <secondParam>string</secondParam>
        </Foo>
      </soap:Body>
    </soap:Envelope>
    HTTP/1.1 200 OK
    Content-Type: text/xml; charset=utf-8
    Content-Length: length
    
    <?xml version="1.0" encoding="utf-8"?>
    <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
      <soap:Body>
        <FooResponse xmlns="http://palermo.cc">
          <FooResult>int</FooResult>
        </FooResponse>
      </soap:Body>
    </soap:Envelope>

    What if I don't want to expose my naming conventions in my soap message?   Moreover, I have specific names that I want for the Soap message.  I can add XmlElement attributes to the parameters to customize the Soap message:

      148 [WebMethod]
      149 public int Foo(
      150     [XmlElement("ProductCode")] string firstParam,
      151     [XmlElement("Quantity")] string secondParam)
      152 {return 0;}

    Here is the part of the SOAP message that is changed:

    <?xml version="1.0" encoding="utf-8"?>
    <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
      <soap:Body>
        <Foo xmlns="http://palermo.cc">
          <ProductCode>string</ProductCode>
          <Quantity>string</Quantity>
        </Foo>
      </soap:Body>
    </soap:Envelope>


    Because .Net uses the XmlSerializer for Soap-object conversion, the service Xml schemas can be completely customized.  Another one of my favorite things is to return a object from a web service while ensuring the contract is explicit.  On my object, I implement ISerializable and define my format. 

  • An extra tip to make you a better ASP.NET developer - level 200

    I'd like to add an extra tip to make you a better ASP.NET developer:

    • Don't use the designer for anything more than the most trivial control-placement tasks.  The designers are geared toward RAD development.  That rhyms with "BAD".  If you get v1 of software out with RAD, each subsequent version will be worse and worse maintenace-wise.  For those who've felt the pain, you agree with me.  For those newer to development, RAD seems great.  Drag and drop, and call the database from code-behind. . .and it works.  Don't take my word for it.  Do some self-study.
    • One more tip:  Study material BESIDES MSDN material.  MSDN sells RAD, after all.  .Net 2.0 - do the same thing with 70% less code!! 

     

    8 Tips to make you better ASP.NET developer

    A nice list of tips, plus links to other good resources.

     

  • Ramping up with NAnt for automated builds - level 300

    At first glance, the NAnt .build files may seem daunting, especially the really long ones, but the documentation for NAnt is superb!

    I wanted to start with a real VS solution instead of the trivial HelloWorld .cs file, so I used my Model-View-Presenter demo solution.  Since this was a Visual Studio solution, all I had to do was add a Solution task in the build file.

    Here is my build file.  Now if that doesn't convince you that automated builds aren't that hard, I don't know what will!

    <project name="Model View Presenter with Repository" default="rebuild">
        <property name="configuration" value="release"/>
       
        <target name="clean" description="Delete all previously compiled binaries.">
            <delete>
                <fileset>
                    <include name="**/bin/**" />
                    <include name="**/obj/**" />
                    <include name="**/*.suo" />
                    <include name="**/*.user" />
                </fileset>
            </delete>
        </target>
       
        <target name="build" description="Build all targets.">
            <call target="build.solution"/>
        </target>
       
        <target name="rebuild" depends="clean, build" />

        <target name="build.solution">
            <solution configuration="${configuration}" solutionfile="MVPWithRepository.sln" />
            <property name="expected.output" value="View/bin/${configuration}/View.exe"/>
            <fail unless="${file::exists(expected.output)}">Output file doesn't exist in ${expected.output}</fail>
        </target>
       
    </project>

  • Rode my bicycle from Houston to Austin this weekend - level SORE

    Last weekend, I participated in the MS 150 bicycle tour from Houston to Austin to raise money for the MS Society.  It's a crippling disease for which there is currently no cure.  I'm really sore, but I'm glad I did it.  This is the second time I've done it, and I averaged 15.3 miles through the full 180 miles in two days.

    If you'd like to donate to the MS society in my name, just follow this link: http://ms150.org/edon.cfm?id

    This is the first year that there was a Texas A & M riding team, and we had a blast.  We had 75 members, and Saturday night in La Grange, we woke up the campgrounds with an Ol' Army yell practice.  I look forward to next year and an even bigger Aggie team.

    My brother took a lot of pictures and some movies. 

  • Getting started with ReSharper by JetBrains - level 200

    I'm a bit behind the curve on this one, but I'm now developing with the 30 day trial of ReSharper by JetBrains.  I haven't even tried all of the features.  There are keyboard chords and hidden features I need to learn.  The obvious ones are code-formatting and general helping you out.  It will close your braces, parens, quotes, etc.  It color codes different types of members. 

    As I get more into Agile development methodologies, I'm trying to leverage more tools in order to be more productive. 

  • Austin Agile User Group meeting Wednesday - level 000

    This Wednesday, the Austin Agile user group is meeting during lunch at the Mongolian BBQ on N. Lamar.  Check out the website for details: http://groups.yahoo.com/group/agileatx/
  • Vote for Birds of a Feather sessions for Tech Ed. - level 000

    If you haven't already voted for BoF sessions, go there!  http://www.msteched.com/cfp/bofvoting.aspx

    I submitted the following:

     

    Agile Methodologies With .Net

    I have to look hard to find fellow developers using Agile methodologies with .Net projects in my area. Wouldn't it be great to talk about how others are using Agile? Also, the next version of MSF will have an Agile track, and this would be an excellent forum for discussion.
    Intended Audience: Developer
    Submitted By: Jeffrey Palermo, Dell, Inc.
  • Step by Step: Create java package and import to use with C# - level 300

    Yesterday I explained that I was able to import java .jar packages for use with .Net.  Here's the steps.

    First, here is my sample Java class.  (Don't put this in VS.Net, compile this with the java compiler):

        1 package ClassLibraryInteropTest;
        2 
        3 public class Calculator
        4 {
        5     public int Add(int first, int second)
        6     {
        7         return first + second;
        8     }
        9 
       10     public int Subtract(int first, int second)
       11     {
       12         return first - second;
       13     }
       14 
       15     public int Multiply(int first, int second)
       16     {
       17         return first * second;
       18     }
       19 
       20     public float Divide(int first, int second)
       21     {
       22         return first / second;
       23     }
       24 }

    This is just a sample calculator that I will leverage at the end with my C# code.  I'll need to compile this, so I'll run:

    javac Calculator.java

    This will create a Calculator.class file.  Next I'll package that class into a .jar file:

    jar cvf Calculator.jar *.class

    This will take all the class files in the directory and put them in Calculator.jar.  I only have one class, so I'm good to go.  Now, I'll run JBImp, with is a .Net utility, to convert the .jar's Java bytecode to MSIL:

    jbimp /t:library Calculator.jar

    And you'll see the following output:

    Microsoft (R) Java-language bytecode to MSIL converter version 1.1.4322.0
    for Microsoft (R) .NET Framework version 1.1.4322
    Copyright (C) Microsoft Corp 2000-2002. All rights reserved.

    Created ClassLibraryInteropTest.Calculator.dll

    Now I have my .Net assembly named ClassLibraryInteropTest.Calculator.dll.  Note that the utility used the package name (defined internally) to prefix the assembly name.

    Next, create a .Net project to use as a test harness, and add a reference to this newly created .dll file.  Once you have referenced it, you'll be able to use the following C# code:

        1 using System;
        2 
        3 namespace JavaInterop
        4 {
        5     class Tester
        6     {
        7         [STAThread]
        8         static void Main(string[] args)
        9         {
       10             ClassLibraryInteropTest.Calculator myCalc = new ClassLibraryInteropTest.Calculator();
       11             Console.WriteLine(myCalc.Add(23, 7).ToString());
       12             Console.ReadLine();
       13         }
       14     }
       15 }

    If you get an error running this code (cannot find assembly Calculator), rename the assembly: ClassLibraryInteropTest.Calculator.dll to Calculator.dll. 

    You get full intellisense about all the methods of the Calculator class, and essentially, you treat it exactly the same as .Net code because the JBImp utility actually makes it a .Net assembly.

  • Import existing Java .jar files to .Net .dll files for use with any .Net project - level 400

    If you have existing .jar files from a Java application, and you need to use that existing business logic or rewrite it, wouldn't it be nice if you could just leverage the existing package? 

    You can with the JBImp utility.  I recently had to do this, and it was a breeze.  I ran the utility on my .jar, and out came a managed .dll that I subsequently referenced and used in my .Net app.

    According to the documentation, the utility actually converts the Java IL to MSIL at the bytecode level.  It sure did make the reuse picture a lot prettier.

  • Patterns: Provider vs. Plugin vs. Strategy - level 300

    Previously I made an implementation and called it the Provider pattern.  After some good discussion, I must redefine what I implemented.  I implemented something that had major traits of Provider, Plugin, and Strategy.  I implemented a Repository class that used a configuration service to get the assembly and type of the class to load.  This class loads the appropriate type that implements my interface.  My implementation implements every element of Provider except that instead of an abstract base class for contract, I use an interface.  That breaks the definition.  Strategy is defined as using interfaces, but in my implementation uses a configuration item to dynamically load the concrete implementation via reflection, so I've added something not explicitly not defined in the pattern.

    I have a feeling that our vocabulary is getting a bit muddled because we now have pattern names from different sources, and they overlap quite a bit.  I don't feel that I can use a pattern name:  I have to define it first so that fellow developers know what I really mean.

    Perhaps as our industry matures more, a common vocabulary will truly emerge.

More Posts Next page »

Our Sponsors

Free Tech Publications

This Blog

Syndication

News

Headspring Systems

View Jeffrey Palermo's profile on LinkedIn

See my new blog at .jeffreypalermo.com