DevPinoy.org

A Filipino Developers Community
Welcome to DevPinoy.org Sign in | Join | Help
in Search

cruizer

aspiring to free and open the mind of .NET developers

August 2006 - Posts

  • PHP can do Test-Driven Development too

    Maybe you thought that test-driven development is restricted only to platforms like Java and .NET...I'll be happy to inform you that PHP can also do that!

    Here's my simplest test case using TDD on PHP:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    <?php

    require_once '../../simpletest/unit_tester.php';
    require_once '../../simpletest/reporter.php';

    class MyTestCase extends UnitTestCase {
      function MyTestCase() {
        $this->UnitTestCase('My test');
      }
      function TestAdd() {
        $this->assertEqual(5, 2+3);
      }
    }

    $test = &new MyTestCase();
    $test->run(new HtmlReporter());

    ?>

    Running it in a web browser results in:

    My test

    1/1 test cases complete: 1 passes, 0 fails and 0 exceptions.


    I'm using this testing framework for PHP called SimpleTest. Somehow I prefer it to the one that got included in the PEAR repository. It's even got mocking facilities too! Now I have no excuse not to do TDD on whatever environment I use...psst, is there any way I can do TDD on SQL?

  • TDD is about design; tests are just side effects

    codebetter.com was down earlier. Dunno why. Anyway, when it went back up I went through some of the posts by Scott Bellware. The following stuff got my attention:

    Debunking Microsoft's Guidelines for Test-Driven Development

    and

    Microsoft Takes It on the Chin over Test-Driven Development

    Fairly old material, but still as relevant today as it ever was. Fascinating thing about TDD is that you think you know it already but everyday you use it you get to learn more. You see with your own eyes how you learn to design classes the right (and flexible) way, in contrast to the old code-first/test-later approach.

    Interesting quote from Scott Bellware here:

    "Testing is a side effect. Design is the goal of TDD, design for testability flows naturally from there, followed by de-coupling, and reusability."

    Very well said. It takes doing TDD head-first in order to appreciate how it opens up your designs.


    Posted Aug 25 2006, 12:44 PM by cruizer with 4 comment(s)
    Filed under: ,
  • Preaching TDD to students

    I've always had a soft spot in my heart for students. Maybe my former (programming) students would vehemently disagree with that. Stick out tongue But I've always wanted to teach the things I've learned and applied in my craft to students. After all, I've also been a student (and I still am, a student of my profession!). There are many things I wish I knew when I was still in college. That's why I taught part-time when I was still reviewing for my engineering board exams; that's why I came back to teach at my alma mater after working for a leading Internet Service Provider (ISP) for one and a half years. Somehow I want students to know what's going on in the real world and be able to relate it with the theories that they're learning, so they can appreciate it better.

    When I was in college I probably didn't understand a thing about computer networking. I only really appreciated it when I saw those theories come to life in the ISP I was working for. And when I came back to the academe I had a great time teaching stuff like IP, subnetting, routing and application-layer protocols to my students. Had I not seen those stuff at work in the real world, I doubt I would be able to teach them effectively, if at all!

    So what's my point in this rant? Stick out tongue I want to challenge, maybe inspire, the professionals in this group -- in the local industry, even -- to share what you are learning "in the real world" to students. When I asked the audience in yesterday's MSDN talk if they've heard of test-driven development, none of them raised their hand. And only a few have gone out of their way to explore stuff like object-oriented programming and .NET. I wasn't really surprised but at the back of my mind I was hoping that the state of computer education today had improved upon the state of computer education during my days. Guess what, it really hasn't. Sad

    I commend Microsoft Philippines for taking time (and resources) to regularly put up events like MSDN Student Developers' Night. Hopefully we can see greater cooperation from the professional sector in helping uplift the state of IT education in this country.
     

  • TDD Sample Code

    Looks like I can only include one attachment per blog post, so I was only able to put the presentation in my previous blog entry.

    Here's the sample code from yesterday...Demo1 is the completed number-to-word conversion class...CurrencyConverter1 is the "god" class implementation of the foreign exchange demo while CurrencyConverter2 is the implementation which makes use of the dependency injection pattern ("inversion of control") and a mock object to illustrate object interaction testing.

    Posted Aug 17 2006, 06:05 AM by cruizer with 1 comment(s)
    Filed under: ,
  • Red-Green-Refactor: Test-Driven Development with .NET

    I had the privilege of discussing Test-Driven Development with students yesterday at the MSDN Student Developers' Night and I had a blast! It was encouraging to see students interested in a topic that can be so boring.

    As promised, I am attaching here my slides (in PPT format) and sample code. Those who were able to attend yesterday might notice that the code is slightly different from what was demoed...that's because we did the demo on the spot! Smile Of course the spirit behind the code is very similar.

    Some links:

    TDD tools I use for .NET (there are more, actually, but here are the essential stuff):

    Hopefully more .NET developers get test-infected! Smile

  • Borland resurrects the "Turbo" Brand

    http://www.turboexplorer.com

    It brings back good memories indeed. Maybe we'll finally see those old Turbo C or Turbo C++ copies in schools laid to rest. When these tools come out early next month (September) I'll surely check out Turbo C# and Turbo C++. Maybe I can hone my C++ skills again, since I'm hoping that Borland's C++ will be more standards-compliant than Microsoft's. Smile

    Exciting times are ahead of us!

Powered by Community Server (Commercial Edition), by Telligent Systems