ARTICLE AD BOX
I am trying to implement password manager on Java right now. I am implementing the vault. I have VaultEntry and VaultFolder classes. VaultEntry has fields id, parentId, name, username, email, password and notes. VaultFolder has fields id, parentId, name. Those classes obviously have same logick (id, parentId). It would be great to have base abstract class VaultItem that has fields id, parentId.
However, if we make abstract base class VaultItem and have single collection List<VaultItem> we will have to use dynamic casts to access type specific information (name, username, email, password and notes) what is considered a bad practice.
On the other hand, if we do not make abstarct base class VaultItem we will have to store VaultFolder and VaultEntry in different collections and we will have to write id-based logick twice on those collections.
What's the best solution in this problem?
