Skip to content

Software Development Blogs: Programming, Software Testing, Agile Project Management

Methods & Tools

Subscribe to Methods & Tools
if you are not afraid to read more than one page to be a smarter software developer, software tester or project manager!

Requirements

Quote of the Month January 2017

From the Editor of Methods & Tools - Thu, 01/19/2017 - 11:37
Although many organizations are certified at SEI CMM Level 5, when a team hits a production snag, those certificates don’t carry much weight. People need IT heroes in the team to pull things through. Dependencies on folks who are technically competent, can think on their feet, and can manage time pressures increase that much more. […]

Scrum & Tests Refactoring in Methods & Tools Winter 2016 issue

From the Editor of Methods & Tools - Mon, 01/09/2017 - 13:36
Methods & Tools – the free e-magazine for software developers, testers and project managers – has published its Winter 2016 issue that discusses Better Retrospectives, Refactoring Tests, Delivering Scrum Projects and the following free software tools: doctest, MarkupKit. Methods & Tools Winter 2016 issue content: * Making Sprint Retrospectives Work * Embracing the Red Bar: […]

Self-Healing Systems

From the Editor of Methods & Tools - Wed, 01/04/2017 - 16:33
We can think of the whole computer systems as a human body that consist of cells of various types. They can be hardware or software. When they are software units, the smaller they are, the easier it is for them to self-heal, recuperate from failures, multiply or even get destroyed when that is needed. We […]

Software Development Conferences Forecast December 2016

From the Editor of Methods & Tools - Tue, 12/27/2016 - 08:41
Here is a list of software development related conferences and events on Agile project management ( Scrum, Lean, Kanban), software testing and software quality, software architecture, programming (Java, .NET, JavaScript, Ruby, Python, PHP), DevOps and databases (NoSQL, MySQL, etc.) that will take place in the coming weeks and that have media partnerships with the Methods […]

Blockchain for Software Developers

From the Editor of Methods & Tools - Tue, 12/20/2016 - 09:18
In a lot of software developer conferences, there are talks about the technical aspects of the blockchains, how to develop smart contracts on top of Ethereum and things like that. But before looking at those, it is crucial to take a step back and understand what is the blockchain, what it brings to the table […]

Software Development Linkopedia December 2016

From the Editor of Methods & Tools - Wed, 12/14/2016 - 12:21
Here is our monthly selection of knowledge on programming, software testing and project management. This month you will find some interesting information and opinions about project management personalities, better teams, starting a new job, code reviews, agile testing, scaling Agile, IoT and tests quality. Blog: Implementers, Solvers, and Finders Blog: Giving better code reviews Blog: […]

Quote of the Month December 2016

From the Editor of Methods & Tools - Mon, 12/12/2016 - 15:48
Experience shows that architecting is not something that’s performed once, early in a project. Rather, architecting is applied over the life of the project; the architecture is grown through the delivery of a series of incremental and iterative deliveries of executable software. At each delivery, the architecture becomes more complete and stable, which raises the […]

The Impostor Software Developer Syndrome

From the Editor of Methods & Tools - Wed, 12/07/2016 - 17:50
Did you ever feel like a fraud as a software developer? Have the feeling that at some point, someone is going to find out that you really don’t belong where you are? That you are not as smart as other people think? You are not alone with this; many high-achieving people suffer from the imposter […]

fck: Fake Construction Kit

Think Before Coding - Jérémie Chassaing - Sun, 12/04/2016 - 10:34

Yeah it's christmas time again, and santa's elves are quite busy.

And when I say busy, I don't mean:

Santa's elves

I mean busy like this:

Santa's elves

So they decided to build some automation productivity tools, and they choose Santa's favorite language to do the job:

F# of course !

F# scripting

No body would seriously use a compiled language for automation tools. Requiring compilation or a CI server for this kind of things usually kills motivation.

Of course it is possible to write bash/batch files but the syntax if fugly once you start to make more advanced tools.

Python, JavaScript, Ruby or PowerShell are cool, but you end up as often with scripted languages with dynamic typing which you'll come to regret when you have to maintain it on the long term.

F# is a staticaly typed language that can be easily scripted. Type inference make it feel like shorter JavaScript but with far higher safety !

Writing F# script is easy and fast. Test it from the command line:

1: 
vim test.fsx

Then write:

1: 
printfn "Merry Christmas !"

press :q to exit

now launch it on linux with:

1: 
fsharpi --exec test.fsx

or on windows:

1: 
fsianycpu --exec test.fsx

Excellent.

The only problem is that typing the fshapi --exec this is a bit tedious.

Bash/Batch to the rescue

We can create a bash/batch script to puth in the path that will launch the script (for linux):

1: 
vim test

1: 
fsharpi --exec test.fsx

1: 
chmod +x test

or one windows

1: 
vim test.cmd

1: 
fsianycpu --exec test.fsx    

Done !

Better, but now we need to write a bash and/or a batch script for each F# script.

fck bash/batch dispatcher FTW !

We create a fck file (don't forget to chmod +x it) that takes a command

 1: 
 2: 
 3: 
 4: 
 5: 
 6: 
 7: 
 8: 
 9: 
10: 
11: 
12: 
13: 
14: 
15: 
16: 
17: 
18: 
19: 
20: 
21: 
22: 
23: 
24: 
25: 
26: 
27: 
28: 
29: 
30: 
31: 
32: 
33: 
34: 
35: 
36: 
#!/usr/bin/env bash


# fck tool path
fckpath=$(readlink -f "$0")
# fck tool dir
dir=$(dirname $fckpath)
script="$dir/fck-cmd/fck-$1.fsx"
shell="$dir/fck-cmd/fck-$1.sh"
cmd="$1"
shift

# packages if needed
if [ ! -d "$dir/fck-cmd/packages" ]
then
pushd "$dir/fck-cmd" > /dev/null
    mono "$dir/fck-cmd/.paket/paket.bootstrapper.exe" --run restore
popd > /dev/null
fi

# script command if it exists
if [ -e $script ]
then
    mono "$dir/fck-cmd/packages/FAKE/tools/FAKE.exe" "$script" -- $@

# shell command if it exists
elif [ -e $shell ]
then
    eval $shell $@

# help
else
pushd "$dir/fck-cmd" > /dev/null
    mono "$dir/fck-cmd/packages/FAKE/tools/FAKE.exe" "$dir/fck-cmd/fck-help.fsx" -- $cmd $@
popd > /dev/null
fi

and the batch version:

 1: 
 2: 
 3: 
 4: 
 5: 
 6: 
 7: 
 8: 
 9: 
10: 
11: 
12: 
13: 
14: 
15: 
16: 
17: 
18: 
19: 
20: 
21: 
22: 
23: 
24: 
25: 
26: 
27: 
28: 
29: 
30: 
31: 
32: 
33: 
34: 
@echo off
set encoding=utf-8

set dir=%~dp0
set cmd=%1
set script="%dir%\fck-cmd\fck-%cmd%.fsx"
set batch="%dir%\fck-cmd\fck-%cmd%.cmd"
shift

set "args="
:parse
if "%~1" neq "" (
  set args=%args% %1
  shift
  goto :parse
)
if defined args set args=%args:~1%


if not exist "%dir%\fck-cmd\packages" (
pushd "%dir%\fck-cmd\"
"%dir%
popd 
)

if exist  "%script%" (
"%dir%/fck-cmd/packages/fake/tools/fake.exe" "%script%" -- %args%
) else if exist "%batch%" (
pushd "%dir%\fck-cmd\"
"%batch%" %cmd% %*
popd
) else (
"%dir%/fck-cmd/packages/fake/tools/fake.exe" "%dir%
)

Forget the paket part for now.

The bash take a command argument, and check whether a fck-cmd/fck-$cmd.fsx file exists. If it does, run it ! It also works with shell scripts name fck-$cmd.sh or batch scripts fck-$cmd.cmd to integrate quickly with existing tools.

Fake for faster startups

When F# scripts start to grow big, especially with things like Json or Xml type providers, load time can start to raise above acceptable limits for a cli.

Using Fake to launch scripts takes adventage of it's compilation cache. We get the best of both world:

  • scriptability for quick changes and easy deployment
  • automaticly cached jit compilation for fast startup and execution

We could have written all commands in a single fsx file and pattern maching on the command name, but once we start to have more commands, the script becomes bigger and compilation longer. The problem is also that the pattern matching becomes a friction point in the source control.

FckLib

At some point we have recuring code in the tools. So we can create helper scripts that will be included by command scripts.

For instance parsing the command line is often useful so I created a helper:

 1: 
 2: 
 3: 
 4: 
 5: 
 6: 
 7: 
 8: 
 9: 
10: 
11: 
12: 
13: 
14: 
15: 
16: 
17: 
18: 
// culture invariant, case insensitive string comparison
let (==) x y = String.Equals(x,y, StringComparison.InvariantCultureIgnoreCase)

open System.Xml.Linq

module CommandLine =
    // get the command line, fck style...
    let getCommandLine() = 
        System.Environment.GetCommandLineArgs() 
        |> Array.toList
        |> List.skipWhile ((<>) "--")
        |> List.tail

    // check whether the command line starts with specified command
    let (|Cmd|_|) str cmdLine =
        match cmdLine with
        | s :: _ when s == str -> Some()
        | _ -> None 

We use the -- to delimit arguments reserved for the script. Since Fake is used to launch scripts, we can also include FakeLib for all the fantastic helpers it contains.

Here is a sample fck-cmd/fck-hello.fsx script that can write hello.

It uses FakeLib for the tracefn function and FckLib for getCommandLine.

You can call it with (once fck is in your Path environment variable):

1: 
fck hello Santa

Help

A tool without help is just a nightmare, and writing help should be easy.

The last part of fck bash script lanch the fck-help.fsx script:

This script tries to find a fck-xxx.txt file and display it, or fallbacks to fck-help.txt.

For exemple the help for our fck hello command will be in fck-hello.txt:

1: 
2: 
3: 
4: 
Usage:
fck hello [<name>]

Display a friendly message to <name> or to you if <name> is omitted.

Of course we can the pimp the fck-help.fsx to parse the txt help files and add codes for colors, verbosity etc.

Deployment

Deployment is really easy. We can clone the git repository, and add it to $PATH.

Run the commands, it will automatically restore packages if missing, and lanch the script.

To upgrade to a new version, call fck update, defined in fck-update.sh :

1: 
2: 
3: 
4: 
5: 
6: 
7: 
script=$(readlink -f "$0")
dir=$(dirname $script)

pushd "$dir" > /dev/null
git pull
mono "$dir/.paket/paket.bootstrapper.exe" --run restore
popd > /dev/null

or batch fck-update.cmd:

1: 
2: 
git pull
.paket

Yep, that's that easy

Happy Christmas

Using Santa's elves tools, I hope you won't be stuck at work on xmas eve ! Enjoy !

The full source is on github

val printfn : format:Printf.TextWriterFormat<'T> -> 'T

Full name: Microsoft.FSharp.Core.ExtraTopLevelOperators.printfn val set : elements:seq<'T> -> Set<'T> (requires comparison)

Full name: Microsoft.FSharp.Core.ExtraTopLevelOperators.set val not : value:bool -> bool

Full name: Microsoft.FSharp.Core.Operators.not
Categories: Architecture, Requirements

Software Development Conferences Forecast November 2016

From the Editor of Methods & Tools - Tue, 11/29/2016 - 16:00
Here is a list of software development related conferences and events on Agile project management ( Scrum, Lean, Kanban), software testing and software quality, software architecture, programming (Java, .NET, JavaScript, Ruby, Python, PHP), DevOps and databases (NoSQL, MySQL, etc.) that will take place in the coming weeks and that have media partnerships with the Methods […]

Quote of the Month November 2016

From the Editor of Methods & Tools - Mon, 11/28/2016 - 13:32
There is surely no team sport in which every player on the field is not accurately aware of the score at any and every moment of play. Yet in software development it is not uncommon to find team members who do not know the next deadline, or what their colleagues are doing. Nor is it […]

Software Development Linkopedia November 2016

From the Editor of Methods & Tools - Mon, 11/21/2016 - 15:08
Here is our monthly selection of knowledge on programming, software testing and project management. This month you will find some interesting information and opinions about introvert project manager, scaling Agile, Test-Driven Development, UX vs UI, philosophy and programming, retrospectives, BDD in Java and Agile metrics. Blog: How Introvert Can Survive as Project Manager Blog: #AgileAfrica […]

Is Your Organization Killing Your Software?

From the Editor of Methods & Tools - Thu, 11/17/2016 - 16:19
When asked “What is your architecture?” most people immediately respond with how their software is laid out and what their plans are for improving parts of it. Rarely does anybody really think through their team and organizational architecture, and even more rarely do people understand how that may fundamentally impact how the software gets written […]

The Software Development Knights Who Say “No!”

From the Editor of Methods & Tools - Wed, 11/09/2016 - 17:13
In the movie “Monty Python and the Holy Grail“, King Arthur and the Knights of the Round Table had to face the obstacle of the knights who say “ni!” to travel further in their quest for the Grail. In the modern software development world, it seems that software developers can instead follow the knights that […]

Software Architecture for the Unknown

From the Editor of Methods & Tools - Thu, 11/03/2016 - 16:35
In this SATURN 2016 Keynote, Grady Booch discusses about architecting the unknown. There are many systems that we know how to architect (usually because we’ve built them many times before). There also many systems for which we know a process that will lead us to a reasonable architecture (usually because the forces on our project […]

Software Development Conferences Forecast October 2016

From the Editor of Methods & Tools - Tue, 10/25/2016 - 14:02
Here is a list of software development related conferences and events on Agile project management ( Scrum, Lean, Kanban), software testing and software quality, software architecture, programming (Java, .NET, JavaScript, Ruby, Python, PHP), DevOps and databases (NoSQL, MySQL, etc.) that will take place in the coming weeks and that have media partnerships with the Methods […]

Software Development Linkopedia October 2016

From the Editor of Methods & Tools - Wed, 10/19/2016 - 11:02
Here is our monthly selection of knowledge on programming, software testing and project management. This month you will find some interesting information and opinions about the life and career of a software developer, technical debt, DevOps, software testing, metrics, microservices, API and mobile testing. Blog: Being A Developer After 40 Blog: Tech Debt Snowball – […]

Quote of the Month October 2016

From the Editor of Methods & Tools - Wed, 10/12/2016 - 12:00
If you blindly accept what clients say they want and proceed with a project on that basis, both you and the clients may be in for a rude awakening. You will have built something the clients cannot use. Often in the process of building a solution, the clients learn what they need is not the […]

A Critical Review of the IoT Hype

From the Editor of Methods & Tools - Thu, 10/06/2016 - 16:58
According to the Gartner Hype Cycle 2015, Internet of Things (IoT) is on the “Peak of Inflated Expectations”. So it’s time to take a good hard look past the promises of IoT , to see what it is really accomplishing. What is IoT really? What do companies mean when they dream about the IoT revolution? […]

Thu, 01/01/1970 - 01:00