There are some really weird modules out there, I'm not sure whether it
makes a good discussion environment to point them out.

My wild guess is that the modules turn into an imperative style because the
libraries (including Wikibase), returns fragments of large table
structures. To process the fragments you then do iterations where different
subparts of those tables are extracted, keeping a state for whatever you
infer from those calls. This creates a lot of extracted states, and often
the states exists inside calls you can't test. Usually you can't even get
to those calls without breaking the interface *somehow*.

Perhaps something can be done by writing a few example pages on Mediawiki,
but my experience is that developers at Wikipedia (aka script kiddies like
me) does not check pages at Mediawiki, they just assume they do it
TheRightWay™. Writhing a set of programming manuals can thus easily become
a complete waste of time.

No, I don't have any easy solutions.



On Wed, Dec 6, 2017 at 11:53 PM, Jeroen De Dauw <jeroended...@gmail.com>
wrote:

> Hey,
>
> While I am not up to speed with the Lua surrounding Wikidata or MediaWiki,
> I support the call for avoiding overly imperative code where possible.
>
> Most Lua code I have seen in the past (which has nothing to do with
> MediaWiki) was very imperative, procedural and statefull. Those are things
> you want to avoid if you want your code to be maintainable, easy to
> understand and testable. Since Lua supports OO and functional styles, the
> language is not an excuse for throwing well establishes software
> development practices out of the window.
>
> If the code is currently procedural, I would recommend establishing that
> new code should not be procedural and have automawted tests unless there is
> very good reason to make an exception. If some of this code is written by
> people not familiar with software development, it is also important to
> create good examples for them and provide guidance so they do not
> unknowingly copy and adopt poor practices/styles.
>
> John, perhaps you can link the code that caused you to start this thread
> so that there is something more concrete to discuss?
>
> (This is just my personal opinion, not some official statement from
> Wikimedia Deutschland)
>
> PS: I just noticed this is the Wikidata mailing list and not the
> Wikidata-tech one :(
>
> Cheers
>
> --
> Jeroen De Dauw | https://entropywins.wtf | https://keybase.io/jeroendedauw
> Software craftsmanship advocate | Developer at Wikimedia Germany
> ~=[,,_,,]:3
>
> On 6 December 2017 at 23:31, John Erling Blad <jeb...@gmail.com> wrote:
>
>> With the current Lua environment we have ended up with an imperative
>> programming style in the modules. That invites to statefull objects, which
>> does not create easilly testable libraries.
>>
>> Do we have some ideas on how to avoid this, or is it simply the way
>> things are in Lua? I would really like functional programming with
>> chainable calls, but other might want something different?
>>
>> John
>>
>> _______________________________________________
>> Wikidata mailing list
>> Wikidata@lists.wikimedia.org
>> https://lists.wikimedia.org/mailman/listinfo/wikidata
>>
>>
>
> _______________________________________________
> Wikidata mailing list
> Wikidata@lists.wikimedia.org
> https://lists.wikimedia.org/mailman/listinfo/wikidata
>
>
_______________________________________________
Wikidata mailing list
Wikidata@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikidata

Reply via email to