fuzzelogic Solutions

January 5, 2010

alternatives

Filed under: BDD, OO, Programming, c#, design, projects — Tags: , , — admin @ 6:38 am

Hi All!
Since the last bdd sugar post, I’ve been using a slightly different layout on the bdd “style” tests. First off, maybe a little clarification is in order - to set the record straight. BDD - is a phase coined by Dan North and (in simplistic terms) uses a Given, When, Then grammer. The other grammer used is highlighted in the context specification style of writing these [tests]. At a high level both try to achieve the same thing of shifting the focus onto the behaviour of the system under development and to make this a design effort. Both also focus on a AAA style . There are differences, and (to me) both provide benefit.

Some terms that I’ll be using, and what they are intended to mean.
Context:   the bits that are setup and used within a particular story/feature/behaviour
Scenario : a condition/set of conditions that contribute to a scenario
Observation: the outcome of executing the Context  + Scenario.
If: the actual scenario / alternate path.
So what are the changes. Well, I’ve tried to bring the observation more into focus, and moving the context “lower” to not distract from what we want to achieve. here’s an example…

[Scenario][Context("when<transfering_money_between_accounts>")]
public class if_the_FROM_account_has_sufficient_funds : when<transfering_money_between_accounts>{
[Observation]
public void it_should_debit_the_amount_from_the_FROM_account_and_credit_it_to_the_TO_account(){
/// setup for the scenario....
/// observe the outcome..
  }

}

Thats cleared up the context, provided us a path to explore different scenarios and observe their outcomes. The only setting up we are doing at that point is for the change in the scenario. The actual context remains unchanged. Thats taken care of in the implementation of the when<transfering_money_between_accounts>. Here’s a sample of the context

 #region-[ Contexts ]-

        public class transfering_money_between_accounts : AccountManagerSpecs{
            public IMessageService message_service;
            public override void setup_the_context(){
                the_to_account = a_mock_of<IAccount>();
                message_service = a_mock_of<IMessageService>();
            }
            protected override IAccountManger create_the_system_undertest(){
                return new AccountManager(message_service);
            }

            public IAccount the_from_account;
            public IAccount the_to_account;
        }
        #endregion

BDD: Given when then
Implementing the given when then grammer we have the following

[Scenario][Context("when<transfering_money_between_accounts>")]
public class if_the_FROM_account_has_sufficient_funds : when<transfering_money_between_accounts>{
 [Observation]
 public void it_should_debit_the_amount_from_the_FROM_account_and_credit_it_to_the_TO_account(){
  Given(x => x.the_from_account = new Account(200))
   .When(x =>x.the_system_under_test.transfer(100,x.the_from_account, x.the_to_account))
      .Then(x => x.the_from_account.debit(100))
      .And(x =>x.the_to_account.was_told_to(y => y.credit(100)));
  }
}

Context Specification:
Implementing the context specification grammer we have the following

[Scenario][Context("when<transfering_money_between_accounts>")]
public class if_the_FROM_account_has_sufficient_funds : when<transfering_money_between_accounts>{
 [Observation]
 public void it_should_debit_the_amount_from_the_FROM_account_and_credit_it_to_the_TO_account(){
  If(x => x.the_from_account = new Account(200))
   .because(x =>x.the_system_under_test.transfer(100,x.the_from_account, x.the_to_account))
      .observer_that(x => x.the_from_account.debit(100))
      .observer_that(x =>x.the_to_account.was_told_to(y => y.credit(100)));
  }
}

For me, this moves the context slightly out of focus , and moves the scenario and observation more in focus. Is this better?? Well, I’m using it on a current project, and will let you know.

Hope that helps
Thanks
Zak

October 8, 2009

SOLID : Interface Segregation Principle

Filed under: OO, Programming, c#, design, projects — Tags: , , — admin @ 3:51 pm

“Clients should not be forced to depend upon interfaces that they do not use.” — Robert Martin

DevG / Isle of Man software developers group monthly meetings

I’m trying to schedule the next one of the S.O.L.I.D principles - the Interface segregation principle - for the 21st October 2009. It should be at the same place (Dimension data-Isle of man) and for around the same time - start at 6:30pm

The actual presentation shouldn’t be too long, although based on the previous ones, the actual discussions could go on.

Hope that’s ok..

Thanks

Zak

October 6, 2009

SVN : rename a repo

Filed under: projects — Tags: , , — admin @ 11:44 am

Hey all!

Just though I’d post this more as a reminder for me… I had a need to rename one of my repositories in svn, turns out there’s magic “rename repository” function.

What I ended up doing was..

1.create a new a repository  ::   svnadmin create [fullpath/]newRepoName

2.dump the existing repo to a dump file :: svnadmin dump [fullpath/]old_Repo > dumpFileName.dump

3.load the new repo from the dump file ::  svnadmin load [fullpath/]newRepoName < dumFilename.dump

Is there another way?

Hope that helps

Thanks

Zak

August 22, 2009

Open closed - Code update

Filed under: BDD, OO, Programming, c#, design, projects — Tags: , , , , , , — admin @ 4:16 pm

Hi All!

I’ve uploaded the code used in the demo on the open closed priciple (part of the SOLID presentations) presented to the Isle of Man software developers group on the 19th of August 2009.

As a reminder….

  1. All objects with names ending in Specs.cs are the “test” cases
  2. The folder named “Attempt” is the first try at how we would have looked at solving this problem.(Breaks the OCP)
  3. The folder “LosTechies” is the solution presented by LosTechies ( a possible solution -that I felt, although addresses the OCP, broke the SRP)
  4. The folder “Fuzzelogic.Refactored” together with the folder “Infrastructure” contains the solution I presented making use of the specification pattern. It was easier to extend the appliaction when new requirements came about, and it provided us with a reusable “pattern” in extending the matching/filtering solution to other parts of  the application
  5. The Bdd project is used to simplify the “test”ing of and makes for a more readable approach.

The code is available from here

All comments / questions are welcome.

Hope this helps

Zak

May 19, 2009

CodeRush Express is free

Filed under: Programming, projects — Tags: , , , , , — admin @ 2:05 am

Hi!

I usually use resharper, but it seems the good folks at devexpress want to give stuff away  http://www.devexpress.com/Home/Announces/CodeRushXpress.xml.  Its for vs 2008 (don’t think it works on the express editions) and if after you install it, you feel a little lost (cos’ I still can’t see the menu option) try this magic shortcut… Ctrl+Shift+Alt+O brings up the editor window.

Now there’s no excuse to not refactor !

Hope this helps

Zak

Older Posts »

Powered by WordPress