IITC-CE / ingress-intel-total-conversion

intel.ingress.com total conversion user script with some new features. Should allow easier extension of the intel map.
https://iitc.app
ISC License
291 stars 109 forks source link

Refactoring and IITC API #108

Open johnd0e opened 5 years ago

johnd0e commented 5 years ago

As said in our documentation, [iitc] 'exposes a plugin API which is rich and thoroughly undocumented.' In fact, iitc core is developed in special manner: all internal objects/functions exposed via window, in hope that it could be useful for plugins.

Actually, only a subset of all exposed function ever could be useful. And so extensive api has a number of drawbacks:

  1. For plugin developer: it's hard to figure out what functions are really important. Actually there is only one way: see working plugins and try do the same (btw even iitc official plugins code is full of bad patterns).
  2. For IITC developers: it's hard to document every detail.
  3. It's impossible to maintain, as any refactoring could brings potential incompatibilities.

Connected issues: #52, #46, #39 etc.

johnd0e commented 5 years ago

I suppose that we can clean up IITC API a bit. But I'm going to remove some function only after making sure that it's not used outside of IITC core. Obviously I can't verify all existent plugins, and it's possible that removed function still used by someone. But in such case it would be easy to reintroduce it back (or fix that plugin).

Here I'm going to make the list of functions that removed from api.

johnd0e commented 5 years ago
angel93ayora commented 5 years ago

As API needs changes (and documentation) it could be useful when removing a function to maintain it for some time (3 months for example) like this: function someOldApiFunc(args...) { . alert('someOldApiFunc is deprecated and will be removed in next versions, {issue url}') . someRefactoredFunc(args...); }

johnd0e commented 5 years ago

Alert could be helpful, I agree, even for completely removed functions. As for maintaining, I am not sure that it worth of efforts (in most cases).

johnd0e commented 5 years ago

So I'm going to do (in long term):

johnd0e commented 5 years ago

Phase 1: stop exposing internal functions, clearly not useful for any plugin. Expect refactoring of every module in code/*..

johnd0e commented 3 years ago

I'm going to start removing of unused/deprecated functions. Of cause, it may appear that some plugin out there still depends on them. So to make this cleanup less painful I will transfer such functions to new 'Legacy' plugin: if anyone finds that some plugin fails in new iitc-ce - he can easily re-enable all old api with that plugin.

McBen commented 3 years ago

Will there be an easy way to differ IITC-ce from IITC(.me)?

(without detailed version checks)

johnd0e commented 3 years ago

@McBen As always, the best way is detect features, not versions.

So you can try to check api.