I am gonna make a personal shop and I was asking my self, speaking in terms of server performance, what would be better? Setup a config, so there I can add items, and use a loop to show it, or hardcode it inside the plugin.
Solved Hardcode or config
Discussion in 'Rust Development' started by Reynostrum, Sep 17, 2016.
-
That depends basically on how you create it...Normally it make's no real difference, if you do it not really really wrong
-
Hardcoding will be more efficient but it isn't a significant cost as loading the config happens when the plugins loads.
It doesn't matter, don't hardcode things because you think it'll improve performance, hardcode things because you think that there's no use in server admins changing it.
Good defaults are extremely important for a good plugin (i.e. good default values and lack of redundant configuration) to reduce complexity and make the plugin easier to use.
Think of a concrete use case that benefits multiple people for a config option.
If you can't think of one and your users can't either, then it's probably redundant (often people suggest features that don't really make sense for most people, only for themselves).
If you can find one, ask yourself whether it makes more sense to implement that feature in a seperate plugin.
If the config option is a flag (true/false) think twice if you can't implement in terms of an actual value instead (e.g. instead of having a flag report_info = true/false use a value report_every = 30, where 0 means it doesn't report anything).
Generally, keep configuration to a bare minimum, but provide enough useful configuration so that most users can do what they want to do. -
Thank you all!
