Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move default aspect function implementations from interfaces to concrete classes #354

Open
Ruin0x11 opened this issue Jul 24, 2021 · 0 comments
Labels
refactoring This requires refactoring existing code standardization Concerns conventions that should be strongly followed in mods

Comments

@Ruin0x11
Copy link
Owner

Ruin0x11 commented Jul 24, 2021

I think it would be better to declare the default implementations of aspect functions in the classes implementing the aspects instead of the aspect interfaces. The concern with default functions was reusability, but having them implicitly copied from the interface could be confusing. Instead of having the default functions implicitly copied, writing this code would at least make it clearer where they came from:

local ICharaSandBag = require("mod.elona.api.aspect.ICharaSandBag")
local CharaSandBagAspect = require("mod.elona.api.aspect.CharaSandBagAspect")

local MySandBag = class.class("MySandBag", ICharaSandBag)

function MySandBag:init() 
   -- ...
end

-- Proposed change: document the aspect method reuse explicitly
MySandBag.hang_on_sand_bag = CharaSandBagAspect.hang_on_sand_bag
MySandBag.release_from_sand_bag = CharaSandBagAspect.release_from_sand_bag

Because interface methods have always been copied from the start, this is a only change in convention instead of a change in the way the OOP system works.

@Ruin0x11 Ruin0x11 added standardization Concerns conventions that should be strongly followed in mods refactoring This requires refactoring existing code labels Jul 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactoring This requires refactoring existing code standardization Concerns conventions that should be strongly followed in mods
Projects
None yet
Development

No branches or pull requests

1 participant