Homework 0 forum

Inconsistency in parameter order for callbacks and handlers

 
Picture of Bastien Wermeille
Inconsistency in parameter order for callbacks and handlers
by Bastien Wermeille - Tuesday, 22 September 2020, 16:28
 

Hello,

Just a small note which could be change for next homework to bring a bit more consistency and avoid issues.

The signature to handle messages is the following :

```go
ExecuteHandler(f interface{}, f2 *net.UDPAddr)
```

Whereas the signature for a callback is:

```go

type NewMessageCallback func(origin string, message GossipPacket)

```

It could be great to have always the same order for the parameters so "origin, message" or "message, origin" but not both changed for the next homework.

Best regards,

Bastien

Picture of Cristina Basescu
Re: Inconsistency in parameter order for callbacks and handlers
by Cristina Basescu - Wednesday, 23 September 2020, 08:35
 

Hi Bastien,

Thanks for the suggestion.

Because we aim to have the homeworks backwards-compatible (i.e., the tests for homework 0 should still pass on homework 1, 2 etc), we won't make the change for this year. However, we'll take your suggestion into account for next year.

Cristina