mirror of
https://expo.survex.com/repositories/expoweb/.git/
synced 2026-02-25 21:55:22 +00:00
Django upgrade and troggle docm.
This commit is contained in:
@@ -95,7 +95,7 @@ could mean that we could gain.
|
||||
<p>Writing our own multi-user code would not be sensible, hence the database.
|
||||
But we could move to a read-only system where the only writing happens on data-import.
|
||||
Then we could use python 'pickle()' or 'json()' read-only data structures, but we
|
||||
would need to create all our own indexing and cross-referencing code.
|
||||
would need to create all our own indexing and cross-referencing code (which is <a href="#mud">a much bigger job</a><sup>*</sup> than you might think).
|
||||
<p>There would be more lower-level code, but the
|
||||
different segments of the system could be in caving-sensible modules not
|
||||
django-meaningful modules. And we would not have all the extra
|
||||
@@ -114,6 +114,17 @@ which is a port to JavaScript of the Django templating system we use
|
||||
Nunjucks including <a href="https://service-manual.nhs.uk/design-system/prototyping">
|
||||
the NHS digital service</a> and Firefox.
|
||||
|
||||
<h3 =id="mud">* Later Note on object dependencies</h3>
|
||||
<!-- Philip Sargent 29 July 2020 -->
|
||||
<a href="http://picocontainer.com/inversion-of-control-history.html#timelines">
|
||||
<img class="onright" src ="../computing/ioc-timeline.png" width="200px"></a>
|
||||
<p>Currently every troggle code operation uses the django ORM <var>search</var> and <var>filter</var> operations on the central database to find any object it needs. If we don't have a central database then we have to use direct object references and we need to think about the design of <a href="https://medium.com/@geoffreykoh/implementing-the-factory-pattern-via-dynamic-registry-and-python-decorators-479fc1537bbe">a central registry object</a> to hold these. There is a well-studied design pattern that describes this design "<a href="http://www.laputan.org/mud/">Big Ball of Mud</a>" which and the contributing actions "Piecemeal growth" and "Sweeping it under the rug".
|
||||
<p>We are always using one object, e.g. a wallet, just to get at another object, e.g. a scan of some original notes, in order to check the data we are checking, e.g. a survex file. Maintaining two-way dependencies amoung all the objects is what "foreign keys" do in a database, but the problem doesn't go away when we don't have a database: it gets slightly harder. <p>One thing that is easier with troggle is that we don't have many object lifecycle issues. Everything is created once and lasts forever. There are only a few ephemeral objects during the initial data import from files.
|
||||
<h4>Wiring-up components</h4>
|
||||
<p>Troggle today doesn't need anything complex, a single <a href="https://hub.packtpub.com/python-design-patterns-depth-singleton-pattern/">registry
|
||||
singleton</a> would probably be fine (though hard to test), but if it evolves towards being a set of interacting services then a more sophisticated architecture would be needed.
|
||||
<p>The Java community found "dependency resolution" very helpful for wiring-up loosely objects/components in the late 1990s with the "<a href="http://picocontainer.com/inversion-of-control.html">Inversion of Control</a>" technique which can be implemented in several ways, most commonly using "<a href="https://martinfowler.com/articles/injection.html">Dependency Injection</a>". But for troggle we must be careful that doing this the "right" way may make the code even more inaccessible to novice caver-programmers than django is. Which is the whole point of moving away from django. Fortunately python programmers have produced some recent guidance: <a href="https://blog.benpri.me/blog/2020/05/13/python-dependency-injection-made-simple/">Python Dependency Injection Made Simple</a> and <a href="https://python-dependency-injector.ets-labs.org/introduction/di_in_python.html">Dependency injection and inversion of control in Python</a>. We should probably use the simpler "<a href="http://picocontainer.com/constructor-injection.html">Constructor Injection</a>" variation as we need to make all our code <a href="http://picocontainer.com/mock-objects.html">more easily testable</a>. Flask uses that.
|
||||
|
||||
<hr />
|
||||
Return to: <a href="trogdesign.html">Troggle design and future implementations</a><br />
|
||||
Return to: <a href="trogintro.html">Troggle intro</a><br />
|
||||
|
||||
Reference in New Issue
Block a user