[Esug-list] Concurrency Best Practices + Tests

Giovanni Corriga giovanni at corriga.net
Sat Sep 7 11:56:27 EDT 2019


Some random thoughts:

1) model your concurrency problem before you start with TDD, e.g. using
TLA+. This will make clear what you need to implement using TDD.

2) once you have a satisfying result from 1, you can start designing your
solution using TDD. Of the tests that you will need to write:
- some will be pure behaviour tests which don’t to worry about concurrency
- some will be coordination tests were you need to worry about concurrency.


The coordination tests can be approached as simulation problems, where you
can manage the choreography of the various concurrent processes. To do this:

A) model your concurrent operation as transactions. Split the transaction
execution into smaller steps, that can be tested separately.
You can then set up a sequence of operations coming from multiple
processes, interleaving ops from one process with those from the others.
This will also make it easier to understand where to use coordination
primitives.

B) Explicitly manage the evaluation of the code in the two processes. You
can do this with a creative use of method wrappers, Delay objects etc., or
by forcing the code to run through a debugger, so that can manage the order
of the message sends between the processes


Please also note that TDD might not be enough and you might need to run
other type of tests than TDD-style unit tests.

Cheers,

Giovanni

Il giorno sab 7 set 2019 alle 03:25 Stéphane Ducasse <
stephane.ducasse at inria.fr> ha scritto:

> Hi guys
>
> I imagine that noury knows most of the remarks you sent it.
> He is far from dull.
> Now it would be nice to read his questions and reply to them and not just
> tell him
> “oh do not use concurrency”
>
> The questions are essentially how do we test? how does concurrent
> programming fit in TDD.
>
> Stef
>
>
> On 6 Sep 2019, at 02:32, Andres Valloud <avalloud at smalltalk.comcastbiz.net>
> wrote:
>
> TL; DR: generally, developing a good sense of what to do ***before
> writing a single line of code*** works really well.
>
> On 9/4/19 6:32 , N. Bouraqadi wrote:
>
> Hi everyone,
>
> Can I get your input on the following questions :
>
> - What are your best practices and recommendations for developing and
> testing concurrent software?
>
> - How to discover need for synchronization/critical sections/ when doing
> TDD?
>
> - How to write code to avoid dead-locks?
>
> Thanks for your help,
> Noury
> _______________________________________________
> Esug-list mailing list
> Esug-list at lists.esug.org
> http://lists.esug.org/mailman/listinfo/esug-list_lists.esug.org
> .
>
>
> _______________________________________________
> Esug-list mailing list
> Esug-list at lists.esug.org
> http://lists.esug.org/mailman/listinfo/esug-list_lists.esug.org
>
>
> --------------------------------------------
> Stéphane Ducasse
> http://stephane.ducasse.free.fr
> http://www.synectique.eu / http://www.pharo.org
> 03 59 35 87 52
> Assistant: Julie Jonas
> FAX 03 59 57 78 50
> TEL 03 59 35 86 16
> S. Ducasse - Inria
> 40, avenue Halley
> <https://www.google.com/maps/search/40,+avenue+Halley?entry=gmail&source=g>
> ,
> Parc Scientifique de la Haute Borne, Bât.A, Park Plaza
> Villeneuve d'Ascq 59650
> France
>
> _______________________________________________
> Esug-list mailing list
> Esug-list at lists.esug.org
> http://lists.esug.org/mailman/listinfo/esug-list_lists.esug.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.esug.org/pipermail/esug-list_lists.esug.org/attachments/20190907/5e80702a/attachment-0001.html>


More information about the Esug-list mailing list