demikernel icon indicating copy to clipboard operation
demikernel copied to clipboard

[build] Fix the super vs. self vs. crate inconsistency

Open anandbonde opened this issue 2 years ago • 3 comments

Context

The codebase currently uses a mix of super vs. self vs. crate methods to specify references. It would be good to have consistency.

Proposed Solution

Finalize and use the same method across the codebase.

Alternative solutions

This is not a bug, but it would make the code easier to read/consistent if we just use one method everywhere. This is possibly applicable to other repos in Demikernel, as well.

anandbonde avatar Sep 09 '22 05:09 anandbonde

Super SHOULD NOT be used. Rationale:

  • If you are using super, it means that you are trying to re-use some component, which is AWESOME.
  • However, if you properly architected software, the component would be module-visible or crate-visible.
  • Super allows people to introduce cycle dependencies and tightly coupled designs.
  • This is similar of having relative includes in C.

ppenna avatar Sep 09 '22 18:09 ppenna

@ppenna - Does this "don't use super" apply even to "mod tests"? I.e. Unit tests that are present in the same file? Offhand, I wouldn't think that would cause any problems.

BrianZill avatar Nov 15 '22 03:11 BrianZill

@BrianZill I agree with you that this does not apply for unit tests that are present in the same file.

ppenna avatar Nov 16 '22 13:11 ppenna