Published on InterSystems Developer Community (https://community.intersystems.com)

Home > Subclasses and/or Inheritence

Question
Steve Hayworth · Mar 25, 2019

Subclasses and/or Inheritence

First time post, also a new Cache developer, hence the <Beginner> tag.

If our data has Predefined terms in a dictionary, and a user can add terms on their own, can the terms exist in different tables?

Lets call the tables "Terms" and the user data in "UserTerms".

If a third class definition has a property of "Term" can it not be either Terms or UserTerms?

I'm leaning towards using a Subclass strategy where the pseudo "Parent" (forgive me) is  Dictionary.Term and the child is along the lines of Dictionary.Term.User

Dictionary.Term.User can inherit from Dictionary.Term and this is stated in the Docs "If class B inherits from class A, you can use an instance of class B in any location where you can use an instance of class A."

This applies to properties of a class correct? Not just methods?

Is there an alternative data model for this that would support the access to the predefined terms to be in a read-only database so as to protect them from changes, yet the users can add terms all they want?

#Beginner #Data Model #Object Data Model #Caché

Source URL:https://community.intersystems.com/post/subclasses-andor-inheritence