What is the difference between directed inheritance and pattern inheritance? - pega

In PDN, in the System Architect Essentials II course they have mentioned Dual inheritance is conceptually similar to single inheritance as many programming languages. What is pattern inheritance and directed inheritance? What is the difference between them?

Well in Pega PRPC, there are two types of inheritance:
Directed Inheritance
Pattern Inheritance
Pattern Inheritance is Inheritance on naming convention, where as Directed inheritance is external or advanced inheritance.
Pattern Inheritance is given preference above Directed Inheritance. As per Pega, if PRPC needs to find RULES (reusable components) which a particular class can use or have access to, first they search through the pattern inheritance. Which is nothing but, the naming convention followed to name a particular RULE in Pega. If PRPC do not find the RULE through the pattern inheritance, it will search the RULE in Directed inheritance.
For example, While naming a RULE in Pega, we use Org-Sub-Work-ClassName, This means, ClassName is inherited from Org-Sub-Work class as well as it is part of Work-Cover-. If we see the inheritance of this class, This will show as:
Short Description | Name
|
ClassName | Org-Sub-Work-ClassName
Work (Default Work Pool) | Org-Sub-Work
HRServices Namespace | Org-Sub
Top Level Class | Org
Cover classes | Work-Cover-
Work classes | Work-
#baseclass | #baseclass
If PRPC, needs to search for a RULE for ClassName, it will first search in Org-Sub-Work, if it is not found, then the search will be made in Org-Sub, if the RULE is not found there as well, it will search in Org. Once, it is not found, PRPC will start searching in Work-Cover-; Not found, next match in Work-. If not found in Work-, it has to be there declared in #baseclass, else it will mark it as not present.
Adding to above and to conclude, the above ClassName also inherits Work-Cover-, However, the point here to note is in Pega, "There are only classes, NO INTERFACE". Therefore, you can think Work-Cover- of an interface rather than being a normal class. So, we can extend a class and implement an interface.

The descriptions for both strategies can be found here on PDN

Direct inheritance defines behavior of the class and Pattern inheritance defines the classes from which we are inheriting the properties. And by doing so, Pega supports multiple inheritance.

Related

Symfony: adding a block-prefix for an abstract custom type

I have a custom type that is abstract.
As it seems that leads to it not getting its own block_prefix in the hierarchy.
So I thought I would put that into configureOptions.
But in the deriving classes I do occassionally also have to define configureOptions which then again leads to either overwriting the parent method which defeats the purpose. Or if I call it explicitly
with parent::configureOptions the system will put the custom prefix above (in the sense of "higher priority") the automatically generated prefix of the implementing class which I obviously do not want.
Is there a solution to this problem that is not "make the parent class not abstract"?
I say that because if possible I don't want to loose the enforcement of the contract given by the abstract parent-class.
EDIT: I realized that it was a false assumption I made that making the base class non-abstract would lead to the addition of the class name as block-prefix.

ndb.PolyModel as an ancestor of a regular entity -- bad idea?

I'd like to make a ndb.PolyModel child entity an ancestor of another ndb.Model entity, because I need the child entity to be strongly consistent for queries.
Something about this makes me nervous. Is this a bad idea?
From what I understand, the secret sauce behind a ndb.PolyModel is that instances of it have a special property called 'class'.
This is a repeated property of strings of all the class names in the inheritance chain, which ndb then uses to instantiate the appropriate subclass when it pulls it out of datastore.
The key for each instance will still be of the parent class.
So for the following example:
class Animal(ndb.PolyModel):
class Cat(Animal):
class Dog(Animal):
If you do
d = Dog(...)
d.put()
d.key will still be something like ndb.Key('Animal', 123456789)
In your Datastore Viewer, you will only have an Animal table and not a Dog table nor a Cat table.
So I would imagine you should be safe to use ndb.Key('Animal', 123456789) as the ancestor for some other model.

Association names on ends without navigability?

I have a question regarding UML Class diagrams.
I know I can just use one name which refers to both sides but my question is:
Is it necessary to show association names at both sides of an association when it is uni directional?
Association ends are properties (i.e., "variables"). When a class owns a property and the property is unnamed, that could be a problem. In contrast, when an association owns an unnamed property, that's not really a problem. You don't need to specify a name for association-owned properties.
Here's an example. I've made MagicDraw show association-end properties as attributes as well, just to make a point:
Notice how theB shows up as a property in class A and at the end of the association with class B. That's because they are two different ways of showing the same property. (It's a special way of showing association-end properties that we normally don't turn on in the tool.) Also notice how class C has an unnamed property inside the box and at the end of the association with class A. Again, that's two different ways to show the same property. How would you implement that unnamed property in a programming language? That could be a problem, right?
Another thing to notice is that class B does not have an attribute called theA, and class A does not have an attribute called theC. That's because those properties are non-navigable and the associations own those properties.
Conflating navigability and property ownership has become deprecated in UML. Recently, the UML spec introduced "association dot notation" to indicate property ownership. (A dot at the end means the class owns the property.) Personally, I never had a problem with the conflation, and I hate the new dot notation. Many tools do not support it, and I think it's downright ugly. Moreover, a diagram that has no dots on it is ambiguous. You can't tell whether it was drawn before or after dots were introduced to the spec!

ASP.NET MVC: ActionMethodSelector / ActionFilter (Attribute) naming conventions

What do you think is the best naming convensions for ActionMethodSelector to differentiate from ActionFilter (Attributes).
I need an ActionMethodSelector that does the same as the AuthorizeAttribute-ActionFilter does, but how would you name that ActionMethodSelectorAttribue? (The implementation is not the issue)
When in doubt follow the framework conventions, if you look at some of their implementations you will see in both cases they simply use an Attribute suffix.
AcceptVerbsAttribute : ActionMethodSelectorAttribute
etc.
and
OutputCacheAttribute : ActionFilterAttribute
etc.
If you have no problem using framework attributes in this way, I don't see any reason you should do anything different for your own code.
Unless you want of course :D
What do you think is the best naming convensions for
ActionMethodSelector to differentiate from ActionFilter (Attributes).
The suffix:
XXXActionMethodSelector
XXXAttribute or XXXActionFilterAttribute
where XXX is obviously the function those classes are supposed to accomplish.
XXXXSelectionAttribute
VS
XXXXFilterAttribute
It really doesn't matter, as long as you are consistent with your implementation, and the prefix or suffix adds a clear picture to its intention.
IMHO.

Per-Data store inheritance strategies in DataNucleus JDO?

I interface with two data stores, one of them is RDMS and the other one is LDAP. What I want to do is to have a hierarchy persisted using "superclass-table" in the RDBMS and "complete-table" in LDAP.
Is such a thing possible? That is, can you specify multiple inheritance strategies, separately for each data store in the *.orm files or am I forced to use a single inheritance strategy?
I couldn't find this information in the documentation of DataNucleus, they only thing I'm sure of is that you can put inheritance elements in an .orm file instead of the .jdo but that still doesn't answer my question...
The hierarchy is rather simple and consists of an abstract class and several subclasses like this:
abstract class Foo implements IFoo
{
...
}
class Foo1 extends Foo
{
...
}
class Foo2 extends Foo
{
...
}
...
I tried to configure inheritance in the two *.orm files AND in the .jdo file (having in mind that it's going to get overriden by the former) but I get an exception
Caused by: org.datanucleus.metadata.InvalidMetaDataException: Class "...Foo1..." has been specified with an inheritance strategy of "superclass-table", yet no superclass exists or none exists with its own table!
at org.datanucleus.metadata.AbstractClassMetaData.validateUserInputForInheritanceMetaData(AbstractClassMetaData.java:903)
at org.datanucleus.metadata.ClassMetaData.populate(ClassMetaData.java:214)
at org.datanucleus.metadata.MetaDataManager$1.run(MetaDataManager.java:2393)
at java.security.AccessController.doPrivileged(Native Method)
at org.datanucleus.metadata.MetaDataManager.populateAbstractClassMetaData(MetaDataManager.java:2387)
at org.datanucleus.metadata.MetaDataManager.populateFileMetaData(MetaDataManager.java:2224)
at org.datanucleus.jdo.metadata.JDOMetaDataManager.loadMetaDataForClass(JDOMetaDataManager.java:741)
at org.datanucleus.jdo.metadata.JDOMetaDataManager.getMetaDataForClassInternal(JDOMetaDataManager.java:353)
at org.datanucleus.jdo.metadata.JDOMetaDataManager$MetaDataRegisterClassListener.registerClass(JDOMetaDataManager.java:184)
at javax.jdo.spi.JDOImplHelper.registerClass(JDOImplHelper.java:376)
I then tried to remove the inheritance elements from the .jdo but the enhancer fails with the following message:
Class "...Foo1..." has been specified to use an inheritance strategy of "superclass-table", persisting to the table of class ...Foo..., however this class doesnt have a discriminator specified.
The individual configurations are correct (new-table with discriminator at base-class and superclass-table at subclasses for the first case and complete-table only at base-class for the second).
You can put that information in the orm file, yes, and indeed that does answer your question since you have one ORM file for RDBMS, and one for LDAP. So package-rdbms.orm, and package-ldap.orm, and then simply set persistence property "javax.jdo.option.Mapping" to either "rdbms" or "ldap". Simple

Resources