What is the correct way to add an entry to a NamedDomainObjectCollection?

The docs show 2 quite different approaches

Firstly there is Implementing Gradle plugins which allows for a clean DSL when adding new items, clean here means a simple block structure.

Secondly there is Developing Custom Gradle Types which requires the use of a register('name') method in order to add an item

The difference between these two approaches is not explained in the docs, can anyone clarify why there are 2 different approaches and what the practical differences between them are?

Experimentation locally indicates the latter approach behaves as per task avoidance which suggests it’s not really suitable for use with configurable data structures.