Sunday, July 08, 2012

Git and Visual Studio 2012


Some points to take into mind when using Git in combination with Visual Studio 2012, Resharper and NUGet.
Manually add following entries to your .gitignore file
  • packages/
  • TestResults/
#################
## Visual Studio
#################

## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.

# User-specific files
*.suo
*.user
*.sln.docstates

# Build results
[Dd]ebug/
[Rr]elease/
*_i.c
*_p.c
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.vspscc
.builds
*.dotCover
bin/

packages/
TestResults/


# Visual Studio profiler
*.psess
*.vsp

# ReSharper is a .NET coding add-in
_ReSharper*

# Installshield output folder
[Ee]xpress

# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html

# Click-Once directory
publish

# Others
[Bb]in
[Oo]bj
sql
TestResults
*.Cache
ClientBin
stylecop.*
~$*
*.dbmdl
Generated_Code #added for RIA/Silverlight projects

# Backup & report files from converting an old project file to a newer
# Visual Studio version. Backup files are not needed, because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML



############
## Windows
############

# Windows image file caches
Thumbs.db

# Folder config file
Desktop.ini


#############
## Python
#############

*.py[co]

# Packages
*.egg
*.egg-info
dist
build
eggs
parts
bin
var
sdist
develop-eggs
.installed.cfg

# Installer logs
pip-log.txt

# Unit test / coverage reports
.coverage
.tox

#Translations
*.mo

#Mr Developer
.mr.developer.cfg

# Mac crap
.DS_Store

Saturday, July 07, 2012

SharpPOS: The Personae


Manager

basil Basil is a restaurant owner. At the end of the day he would like to have an overview of what has been paid by what means. At the end of the month he would like to have an overview of how much has been sold per day per tax category so he can pass this information to his accountant.

Waiter

manuel001 Manuel is a waiter at basil’s restaurant. When he takes orders from customers he writes it down on a notepad, after he has written down the order he walks to the cash register and copies the information in the POS, if an order contains food it should be printed automatically to a secondary printer which is located in the kitchen, so the chef knows what dishes he has to prepare.

When a customer asks for the check Manual wants to be able to print an overview of what the customer has ordered and the total amount that he needs to pay. After getting the money from the customer he enters the amount that has been paid, the system should indicate how much money he has to render.

At the end of his shift he needs to close his shift and an oveview should be printed of how much he has sold, so he can count the money that is in the register

Friday, July 06, 2012

New Project

A few weekends ago a friend of mine lost his POS program during renovations. I told him maybe I could help him out and find him a new (open source) alternative instead of having to buy a new one. I deceided to give OpenBravoPOS a go, it is a neat system with tons of functionalities. However it has some quirks the most important one is that the Close Cash report, that is printed at the end of the day has not the possibility to print the total amount that has been sold per tax category, so it needs to be calculated afterwards which is a bit a pain in the ass... 

Other things I noticed is entering products is really, but really a painful experience, reference and barcode need to be unique... when in fact we don’t need neither the reference neither the barcode. When entering the price of the product you need to set the amount of tax before you can enter the sell price + tax because the base of the calculation is the price excluding the tax is a bit annoying also. 

So I came up with the idea to write him a brand new program called SharpPOS. First thing I did was write up the personas, I wrote one for the owner and one for a waitress. Then I went forward to identify the Minimal Marketable Product which was quit ok. the goal of my little project is to show the real power of Agile.
update: project canceled due to changed legislation

Wednesday, May 02, 2012

Friday, February 17, 2012

The difference between a Mock and a Stub

Many people have a lot of problems to understand the difference between a Mock and a Stub. Marting Fowler states that a Mock is about behaviour verification and a Stub is about state verification
From: http://martinfowler.com/articles/mocksArentStubs.html





  • Dummy objects are passed around but never actually used. Usually they are just used to fill parameter lists.
  • Fake objects actually have working implementations, but usually take some shortcut which makes them not suitable for production (an in memory database is a good example).
  • Stubs provide canned answers to calls made during the test, usually not responding at all to anything outside what's programmed in for the test. Stubs may also record information about calls, such as an email gateway stub that remembers the messages it 'sent', or maybe only how many messages it 'sent'.
  • Mocks are what we are talking about here: objects pre-programmed with expectations which form a specification of the calls they are expected to receive. 


  • I am going to try to explain you in one simple example the difference...
    The classes involved:
    FileProcessor: The actual business logic, that we are trying to test, the Subject Under Test
    File: some file we are processing
    FileValidator: Performs some logic on the file to see if it contains errors
    FileMover: Moves the file to a specific location depending on the results returned by the FileValidator

    public class FileProcessor{
            private readonly IFileMover _FileMover;
            private readonly IFileValidator _FileValidator;

            //Constructor
            public FileProcessor(IFileMover fileMover, IFileValidator fileValidator){
                       IFileMover _FileMover = fileMover;
                       IFileValidator _FileValidator = fileValidator;
            }

            public void Process(File file){
                 ValidationResults result = _FileValidator.Validate(file);

                 if(result.IsValid){
                      _FileMover.Succes(file)
                 }else{
                      _FileMover.Error(file)
                  }
            }
    }

    public interface IFileMover{
           void Success(File file);
           void Error(File file);
    }

    public class ValidationResults{
                public virtual bool IsValid{
                     get;
                }
    }

    public interface IFileValidor{
           ValidationResults Validate(File file);
    }

    We need to create a dummy called DummyValidationResults

    public class DummyValidationResults: ValidationResults{
             public virtual bool IsValid{
                    get{ return false;}
             }
    }

    Now we create a Mock MockFileMover

    public class MockFileMover: IFileMover{

        public void Success(File file){
               this.SucessCalled++;
         }

        public void Error(File file){
             this.ErrorCalled++;
        }

        public int SuccesCalled{get; private set;}
        public int ErrorCalled{get; private set;}
    }

    We create a Stub named StubFileValidator

    public class StubFileValidator: IFileValidator{
         public ValidationResults Validate(File file){
            return new DummyValidationResult();
        }
    }


    now when we would like the test the Fileprocessor we can write:
        File aFile = new FakeFile();
        MockFileMover fileMover =  new MockFileMover()
        FileProcessor processor = new FileProcessor(new MockFileMover(), new StubFileValidator());
        processor.process(aFile);

        Assert.AreEqual(1,fileMover.ErrorWasCalled);
        Assert.AreEqual(0,fileMover.SuccessWasCalled);

    So what is the difference?
    The stub returns a predetermined answer what needs to happen and the path through the code dictates it will always be called. As you can see the methods of the mock are enclosed in decision logic in this case an if statement (this can as wel be a try catch switch or whatever), then we verify if the correct method on the mock has been called... so the mock is responsible for failing or succeeding the test...

    Friday, November 18, 2011

    Executing all SQL files in a folder

    SET dbName=RemmicomMeetingDb
    SET sqlCmdCommand=sqlcmd -S . -E -i

    %sqlCmdCommand% "DropAndCreateDb.sql"

    FOR /F %%i IN ('dir /b /on *.sql') DO %sqlCmdCommand% %%i -d %dbName%

    Monday, November 07, 2011

    Incremental Software Delivery

    What i see occur quite often is that User Stories are to big, resulting in work that is not done at the end of the sprint.

    Lets take a look at the story below:


    As an office manager I would like to be able to lookup contacts quickly so that I can quickly find someone's contact details.

    clip_image001[1]

    Acceptance criteria

    • Given an Office Manager enters "como" When I press the search button Then he/she should see the contact details of everyone who's full name contains "como"
    • Given an Office Manager enters"ce" When I press the search button Then he/she should see the contact details off everyone's title containing "ce"
    • ...

    Now if we think about this for a second, we could start to break down the tasks as follows:
    • Create the database tables
    • Create the data access layer
    • Create the DTO's
    • Create the UI
    • Create the service layer
    If we stop and think about this a second it does not really make sense in a incremental delivery mindset. If you reflect on this from a Form Follows Function Perspective, that the shape of an object should be based upon its purpose. This is a faulty breakup of the feature we are trying to build, since we are going to make the purpose - storing the data in a database and then transfer it to a screen - take precedence over the function, searching contact details.
    It makes more sense tobreak up the screen in functional components as shown below:
    clip_image002
    Then we could break the feature up as follows:
    • Display Search Results
    • Enter Search Criteria
    • Display status message "x out of Y contacts"
    This will require developers to shift there mind from "Horizontal thinking" - thinking in terms of technical layers, to vertical thinking - what I often refer to as "Slicing the Cake". This enables you to incremental delivery of features and get earlier feedback.
    The most important thing is the green grid displaying the search results. From a technical perspective this seems a bit weird, since we autmatically think that its not usable once we have hundreds of contacts. But this mindset is wrong, it is workable, whether its practical that is another thing.
    If we would take this approach we could deliver the following screen to the Product Owner:
    clip_image003
    If he can get his hands on this he can allready take a look and maybe he could allready experience this bit of functionality and conclude he would like to add some fields to the grid like email and phone, that he did not think of immediately.
    So an extra task is added to the story "Add email and phone fields to the grid"
    In the meanwhile wile the product owner is allready playing around with the screen we can allready add the yellow part to the screen:
    clip_image004
    This will enable very short continuous feedback loops, moreover working like this will help you deliver functionality sprint after sprint.
    This is what the end result could look like
    clip_image005
    As you see apparently there was no more time for the status message at the bottom of the screen and this task has been removed from the story another change from the initial version is also the "Search" button.
    Find here an overview of what was implemented and what was removed:
    As an office manager I would like to lookup contacts quickly so that I can quickly find someone's contact details.
    1. Display search results: Done
    1. Enter Search Criteria: Done
    1. Display status message "x out y contacts": removed
    1. Add phone and email fields to the grid: Done
    1. Filter results grid when typing text: Done
    1. Remove search button: Done
    There is one caveat with this approach, business user tend to like alot to add stuff, but they really dislike removing stuff… But this is where the timebox principle kicks in, if for instance there would be no more time left than the 2 last tasks (tasks 5 and 6) than the Product Owner might still choose to accept the story as done and the Functionality could potentially be shipped.

    Friday, September 30, 2011

    Scrum.org PSM II Certification

    I reached a major milestone and obtained my Professional Scrum Master Certification II last week. A put alot of effort in it and it paid of.

    Monday, June 20, 2011

    Something on Continuous Integration

    In the past I have been experiencing some weird practices concerning CI. In the following article I will outline some do's and don'ts when implementing continuous integration.

    First and foremost it is ok to break a build that is why the thing is there you know. Comparing the number of broken builds against the ones that don't break is not a good measure of quality instead measure the time to fix the build.

    Do Integrate static code analysis in your build like FxCop, Ndepend and Simian. Giving you early feedback on your code quality. If the tools give you warnings solve them as well. If you keep up on regular basis this will keep your code base clean.

    Do Integrate your Unit tests to run every build. Again providing early feedback on integration issues.

    Do provide visual feedback (Andon) that give people an immediate feedback when a build fails.

    Don't force developers to do a get latest, run all their unit tests and then check in. This is a waste of time. But when a build fails fix it!

    Don't seek who broke the build. Something that is very common is that people are very eager to investigate who broke the build and pointing fingers. Instead look what broke the build try to fix it, this will enhance collective code ownership.

    Don't check in, close your laptop and sprint out of the office. This practice kills team morale.

    Tuesday, June 14, 2011

    Determine Iteration Length

    Something I come across quite often is that teams don't consciously determine the iteration length of their sprints. They usually take 2 weeks as some default length. This is not really the way to go… Lets see what criteria we can put forward to fine tune the iteration length.
    Here are the 3 major factors to consider:
    • Project Duration
    • End-User commitment (how available are they to provide feedback and input)
    • Maturity of the team
    The shorter the project the shorter the sprints enabling to have more feedback cycles, minimizing the risk building the wrong thing. This however will require a significant amount of commitment of the stakeholders (weekly review meetings, availability to clarify and develop the product backlog with the Product Owner,...). Short sprints also have one big advantage they are more prone to fail… The reason why I see this as an advantage is that problems will surface more quickly, enabling your team to address them and thus further minimizing risk.
    The second factor is also quite important: are there end-users available to provide feedback and are they easily accessible? One thing to keep in mind is that people are not used to the fact they will have to be available for a project throughout its duration. In the past they participate in workshops in the beginning of a project and in acceptance testing testing near the end (oh sweet memories :))
    Finally you should consider how mature your team is. This means how experienced are they with agile practices such as Test Driven Development, Continuous integration, Test Automation, Collective Code Ownership (instead of finding out who broke the build, investigate and fix what broke the build), being cross technical (no specialist like the database guy, the UI guy, etc.). This however does not mean there is no room for specialists and that everybody has to be a generalist but everyone chips in where needed. A big obstacle are teams that divide work parallel with the layers instead of what i call "slicing the cake", this means implementing a feature from front to back, this will enable them to incremently deliver software.

    For more information see: Agile Estimation and Planning from Mike Cohn