fulldecent / aion-aip040

Reference implementation for Aion non-fungible tokens
MIT License
3 stars 3 forks source link

Review code reuse pattern #4

Closed fulldecent closed 5 years ago

fulldecent commented 5 years ago

Motivation

Most new contributors to Aion will start directly by copy-pasting the code here or from another real world example reference project. To help these people, this project should be of the highest quality possible and also make references to all relevant areas where somebody might want to learn more.

Issue

Previously this was written as a combined interface + reference implementation + mock + test mock, that's bad. Now it is spread out to multiple files.

Instead, the interface (AIP040) should be separate from the reference implementation (nf-token.java) and the mock (nf-token-test-mock.java).

This is handled beautifully in 0xcert's reference implementation of non-fungible tokens on EVM:

Reference: https://github.com/0xcert/ethereum-erc721/tree/master/src/contracts/tokens https://github.com/0xcert/ethereum-erc721/tree/master/src/tests/mocks

We should decide how to implement this code modularity in a Java-friendly way. Perhaps an interface with default function implementations will be preferred.

Other notes:

fulldecent commented 5 years ago

Call site code and storage were separated out in https://github.com/fulldecent/aion-aip040/commit/b2ae784f0104c43b76d6a8c8c760286cca67312f.

Current code is organized as:

Work plan

Requesting help: @Jeff-aion @jennijuju

fulldecent commented 5 years ago

Reviewed with team and agreed that this is the approach to use.