Coder Social home page Coder Social logo

Immutability (minor issue) about archie HOT 2 CLOSED

nedap avatar nedap commented on July 21, 2024
Immutability (minor issue)

from archie.

Comments (2)

pieterbos avatar pieterbos commented on July 21, 2024

Hello Bert,

Thank you for the report.

I noticed the immutability of the original java-libs. I do not see it as a benefit and consider it to be one of the libraries drawbacks, especially when combined with the exception throwing in constructors instead of having separate validity checkers.

This makes the java-libs much harder to use: you cannot construct objects, then set fields, then validate them, you have to do it all at once using a complicated constructor with many parameters. It is also hard to create simple tools to construct reference models from archetypes plus input.
With the original java-libs, you cannot easily create a serializable version of a not yet valid model to store for the user to fix later.

With archie, all of these things are easy to do in a performant way, thanks to the mutability of objects.

Furthermore, use cases for changing the model instances exist: for the AOM this includes authoring tools or the flattener in Archie.
For the RM, updates to existing compositions can require model changes.

Builder patterns could solve this, but this means a lot of work and a lot of extra code and possible bugs. Plus more for the developer using Archie to understand.

So, all these reasons mean it is up to the user of Archie to only change the AOM/RM models when he or she means to, and to not touch setters and add-methods in all other cases.

from archie.

 avatar commented on July 21, 2024

I understand your point, and on second thoughts is it good to have a mutable AOM. I gonna do that too. But separate. Thanks for sharing your opinion. Inspiring.

from archie.

Related Issues (3)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.