Here is what my current XML file looks like.
<book>
<isWritable>true</isWritable>
<writeDelay>4.0</writeDelay>
<isReadable>true</isReadable>
<readDelay>3.2</readDelay>
<isDestroyed>false</isDestroyed>
</book>
I have:
3 boolean flags - isWritable, isReadable, isDestroyed.
2 values writeDelay, readDelay.
Conditions:
isWritable require writeDelay
isReadable require readDelay
You can be isDestroyed but not isWritable or isReadable
You can be isWriteable and isReadable
You can be isWritable or isReadable
Current implementaion:
Book.class has all of these has required fields. I'm looking to simplifying this.
If my book is readable but not writable. The XML file should only be:
<book>
<isReadable>true</isReadable>
<readDelay>3.2</readDelay>
</book>
Likewise if the book is destroyed. The XML should only be:
<book>
<isDestroyed>true</isDestroyed>
</book>
Is there any existing design pattern that applies to my situation? I have looked at a few and am leaning towards polymorphism but wanted to reach out to see if there are any other patterns I have not yet considered.
Polymorphism: Here is my idea but to me, it seems a lot for just a boolean and value.
Class called bookDescription.
subclass: writeDescription, readDescription, writeAndReadDescription (subclass of writeDescription), destroyedDescription.
Any comments and suggestions will be appreciated. Thank you!