Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make all classes immutable #211

Open
TRPB opened this issue Mar 20, 2019 · 1 comment
Open

Make all classes immutable #211

TRPB opened this issue Mar 20, 2019 · 1 comment

Comments

@TRPB
Copy link
Member

TRPB commented Mar 20, 2019

Developing Transphporm becomes increasingly complex because of action-at-a-distance. Various places amend a single \DomDocument instance. It gets passed in to various methods in different ways (e.g. some as a reference to an element, which is then modified).

The problem with this approach is that development becomes complex. It's not clear what happens where.

I've added some preliminary work to make every class in the project immutable. All changes to the DomDocument will now happen in the \Transphporm\Document class which wraps the \DomDocument object.

The idea is that anything that changes the document is given the immutable instance and returns the updated document e.g.

public function doSomethingWithTheDocument(\Transphporm\Document $document): \Transphporm\Document {
   return $document->someChange();
}

The will remove (or at least help reduce) the effect of changes happening to a \DomDocument object somewhere else in the library, make development and testing easier.

@cxj
Copy link
Contributor

cxj commented Apr 5, 2019

This makes sense to me. I remain a huge fan of Transphporm. Anything that makes it easier to maintain and develop sounds like a good idea.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants