exercism / exercism/go-representer

[Discussion] Ideas for additional normalizations

Open
#26 1 comment 0 reactions 0 assignees View on GitHub
x:rep/large
Dominant language
Go
Stars
4
Forks
8
Avg merge
8d 6h
Merged PRs (30d)
1

Description

This issue is to collect ideas for additional normalizations that the representer could make so that more student solutions would get a matching representer comment in the future.

Some things to keep in mind:
* The admins currently tend towards the idea that it would be ok if the analyzer would comment on something and the representer would then normalize the same thing. So just because something is listed below does not mean the student would not get feedback on it.
* The mentor that writes a representer comment would see a list of normalizations that are potentially applied and should therefore not be commented on.
* Some normalizations might not be worth the effort coding them as they will not significantly decrease the number of unique/rare representations. It is a bit hard to tell which ones those are exactly and where to draw the line so it is ok to collect all ideas for now.

The normalizations that are currently applied can be found in the [README](https://github.com/exercism/go-representer/blob/main/README.md#current-normalizations).

Ideas for additional normalizations:
- variable declarations, e.g. `var a string` vs. `a := ""`
- variable increment, `i++` vs. ` i = i + 1` vs. `i += 1`
- `make` without capacity and length vs. non make version (slices/maps)
- `new(someStruct)` vs. `&someStruct{}`
- unnecessary variable declaration before return
```
x := someFunction()
return x
```
- Single import with and without brackets
```
import "fmt"
// vs.
import (
"fmt"
)
```
- Named return values but the names are unused
```
func myFunc() (y int) {
return calc()
}
```
- Remove example tests that a student might have written
- `len(someString) == 0` vs. `someString == ""`
- expressions where the order does not matter, e.g. simple math expressions like `return 2*x` vs. `return x*2`
- constants with unnecessary type definition, e.g. `const x int = 40` vs. `const x = 40` (not sure it is possible to know when this normalization is ok to do though)
- `slice[0:n]` vs. `slice[:n]`
- `> x-1` vs. `>= x` when x is int/uint

(Some items on the list are taken over from https://github.com/exercism/go-representer/issues/10. Note that some others listed there were already implemented. Other items on the list are from looking at distinctions that appear between the current representations.)

If you have additional ideas or are interested in implementing one of the normalizations, please leave a comment below.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.