<div dir="ltr"><div><div>Very excited by this idea.  Lot's to think about.  We're on board with most of it and are ready to help.<br><br></div>Cheers,<br></div>Brendan <br></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Apr 10, 2018 at 9:30 AM, Jonathan Druart <span dir="ltr"><<a href="mailto:jonathan.druart@bugs.koha-community.org" target="_blank">jonathan.druart@bugs.koha-community.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Ha, found it!<br><a href="https://gitlab.deichman.no/digibib/Koha/commits/circ_rewrite_master" target="_blank">https://gitlab.deichman.no/<wbr>digibib/Koha/commits/circ_<wbr>rewrite_master</a><br></div>I was looking at the digibib github repo!<div><div class="h5"><br><br><div class="gmail_quote"><div dir="ltr">On Tue, 10 Apr 2018 at 13:28 Jonathan Druart <<a href="mailto:jonathan.druart@bugs.koha-community.org" target="_blank">jonathan.druart@bugs.koha-<wbr>community.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div>Hi Benjamin,<br><br>Where is the code of the "working example"?<br></div><br>Cheers,<br></div>Jonathan<br></div><br><div class="gmail_quote"><div dir="ltr">On Tue, 10 Apr 2018 at 12:04 Benjamin Rokseth <<a href="mailto:benjamin.rokseth@deichman.no" target="_blank">benjamin.rokseth@deichman.no</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Community hackers,<br>
<br>
on hackfest I got introvertly enthusiastic about the concept of a Koha Core, and<br>
about time I shared some thoughts.<br>
<br>
Background: Deichman (Oslo Public Library) is heavily leaning on bleeding edge Koha<br>
development (REST, Objects, Auth, NCIP and such) and, like at least some others, maintain<br>
a lot of local patches to tweak Koha into our users needs. Some are probably interesting to<br>
Community, others not. Now to keep everything in sync with Community would be amazing,<br>
but not likely to happen anytime soon.<br>
<br>
Great work has been done on refactoring Koha (new namespace, Koha Objects and REST api, etc.),<br>
but we'd like to suggest one more - a Koha core.<br>
The idea is simple: borrow from object oriented languages, java, or actually more ruby, since<br>
we're dealing with a dynamic language, use class/module inheritance and method overrides.<br>
Perl has the "use parent" concept which simplifies inheritance/subclassing and allows for<br>
nested overrides.<br>
<br>
As an example we refactored the current circulation in Koha, since this for us is the core<br>
functionality that we depend on and need to hook our local quirks on top of.<br>
An attempt to illustrate:<br>
<br>
+------------+<br>
| Core::Main |<br>
+--^---------+<br>
   |<br>
+--+----------------+<br>
| Core::Prefs       |<br>
| Core::Exceptions  |                +-----------------------+<br>
| Core::Circulation <-----+------+---| Deichman::Circulation |<br>
| ...               |     |      |   +---^-------------------+<br>
+-------------------+     |      |       |<br>
                          |      |       |<br>
       +------------------+------+       +--------------------------+<br>
       | Core::Circulation::SIP  |       |Deichman::Circulation::SIP|<br>
       +----------------------------<wbr>------------------------------<wbr>--+<br>
                                 |        use parent qw(<br>
                                 |          Deichman::Circulation<br>
          +----------------------+          Core::Circulation::SIP<br>
          | Core::Circulation::UI|        )<br>
          +----------------------+<br>
                                 |<br>
                                 ~<br>
<br>
* Core::Main is simply an empty class that act as a parent for any child, including Core::Circulation.<br>
* Core::Circulation has a constructor that takes koha objects item and library, optionally patron<br>
  and sysprefs overrides. It can have accessors such as checkout, messages and other things needed for<br>
  intra, SIP or whatever. It has methods Checkin, Checkout and Renew, amongst others.<br>
* then: Deichman::Circulation::SIP in this example is a local override that inherits from parents<br>
  Deichman::Circulation and Core::Circulation::SIP<br>
<br>
now the beauty of this is that Deichman::Circulation::SIP can override anything (even the constructor)<br>
without touching any of the core code, and perl will traverse the inheritance tree until it finds the<br>
first matching constructor and method.<br>
<br>
Pros:<br>
  - simpler, more readable and more reusable code.<br>
  - local adaptations are easy to hande, and reusable for others<br>
  - the slight overhead of using blessed objects and inheritance is easily gained by the fact that any<br>
    operation will only need fetching Koha objects once (item,library,patron etc) instead of refetching<br>
    them numerous times spread across methods calls and loops<br>
  - way less db calls if done right, faster Koha<br>
  - no more C4::Context, hopefully<br>
  - systempreferences can be dramatically reduced, since most of them are about overrides anyways<br>
  - can be done incrementally, replacing one functionality at a time<br>
<br>
cons:<br>
  - refactoring doesnt make end users happy (but needs to be done in any case)<br>
  - a bit of work to keep templates happy<br>
  - requires a basic understanding of oop<br>
<br>
So to sum up: We already have a working example for circulation (though not in production)<br>
that we can demonstrate. It reimplements basically the entire C4::Circulation, just some small<br>
parts missing. So it can be done.<br>
<br>
But we'd love to hear second opinions from the community! We know the fear for breaking changes, but<br>
its neither scary or complicated to implement!<br>
<br>
Benjamin Rokseth<br>
Oslo Public Library<br>
______________________________<wbr>_________________<br>
Koha-devel mailing list<br>
<a href="mailto:Koha-devel@lists.koha-community.org" target="_blank">Koha-devel@lists.koha-<wbr>community.org</a><br>
<a href="http://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel" rel="noreferrer" target="_blank">http://lists.koha-community.<wbr>org/cgi-bin/mailman/listinfo/<wbr>koha-devel</a><br>
website : <a href="http://www.koha-community.org/" rel="noreferrer" target="_blank">http://www.koha-community.org/</a><br>
git : <a href="http://git.koha-community.org/" rel="noreferrer" target="_blank">http://git.koha-community.org/</a><br>
bugs : <a href="http://bugs.koha-community.org/" rel="noreferrer" target="_blank">http://bugs.koha-community.<wbr>org/</a><br>
</blockquote></div></blockquote></div></div></div></div>
<br>______________________________<wbr>_________________<br>
Koha-devel mailing list<br>
<a href="mailto:Koha-devel@lists.koha-community.org">Koha-devel@lists.koha-<wbr>community.org</a><br>
<a href="http://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel" rel="noreferrer" target="_blank">http://lists.koha-community.<wbr>org/cgi-bin/mailman/listinfo/<wbr>koha-devel</a><br>
website : <a href="http://www.koha-community.org/" rel="noreferrer" target="_blank">http://www.koha-community.org/</a><br>
git : <a href="http://git.koha-community.org/" rel="noreferrer" target="_blank">http://git.koha-community.org/</a><br>
bugs : <a href="http://bugs.koha-community.org/" rel="noreferrer" target="_blank">http://bugs.koha-community.<wbr>org/</a><br></blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr">---------------------------------------------------------------------------------------------------------------<br>Brendan A. Gallagher<br>ByWater Solutions<br>CEO<br><br>Support and Consulting for Open Source Software<br>Installation, Data Migration, Training, Customization, Hosting<br>and Complete Support Packages<br>Office: Portland, OR - Office: Redding, CT<br>Phone # (888) 900-8944<br><a href="http://bywatersolutions.com" target="_blank">http://bywatersolutions.com</a><br><a href="mailto:info@bywatersolutions.com" target="_blank">info@bywatersolutions.com</a><br></div></div></div></div>
</div>