On 17 May 2013 16:57, Denny Vrandečić <[email protected]> wrote:
> Hey,
>
> in order to sanity check the code we have written in the Wikidata project,
> we have asked an external company to review our code and discuss it with
> the team. The effort was very instructional for us.
>
> We want to share the results with you. The report looks dauntingly big, but
> this is mostly due to the appendixes. The first 20 pages are quite worth a
> read.

I read half of the report. Here is what I got out of it:

* We should do dependency injection to make code testable
* We should adhere to the single responsibility principle to make code
testable and less complex
* MediaWiki in many places (special pages, api, hooks to name few)
makes it impossible or at least very hard to do the above for most
classes

They proposed a solution (work around in Wikibase) to allow writing
better code in Wikibase. In section 4.1.6 it reads "The sketched
approach fulfills all presented requirements: The dependency injection
mechanism is kept simple and easy to understand". But as a reader I
did not understand how it works or what would be the practical gains
for the code complexity that the solution itself introduces. I would
attribute some part of this to the many typos, mistakes and non-fluent
language in the text and examples. One example:

"For example, if the a DependencyManager as configured in Illustration 1:
DependencyManager is asked to retrieve the object with the key “mail”, it will
ask the registered DatabaseBuilder to create that object and return it."

I am curious whether there was any discussions if and how these issues
could be fixed in MediaWiki core? Or do we need[1] to figure that out
on our own?

[1] I see that I already jumped on the "how to get there" part, but I
guess I should first ask: is there sufficient mass that thinks there
is an issue and that the issue should be fixed? I think that there is
definitely a need for core to adopt better coding practices to reduce
code complexity and allow easier unit testing. Just like the move from
svn to git and gerrit, it will need a lot of effort and can annoy
people, but in the end we will be better than before.

  -Niklas


--
Niklas Laxström

_______________________________________________
Wikitech-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikitech-l

Reply via email to