LDEV-4609 Calculate dates and status for archived progress
Methods which calculate LearnerProgress dates and status use ugly
instanceof cons… Show more
Methods which calculate LearnerProgress dates and status use ugly
instanceof cons… Show more
LDEV-4609 Calculate dates and status for archived progressMethods which calculate LearnerProgress dates and status use uglyinstanceof constructs. There seem to be no good alternatives, though.LearnerProgressArchive can inherit from LearnerProgress and we usetable-per-subclass Hibernate strategy. But then queries forLearnerProgress would fetch also LearnerProgressArchive entities unlessin each HQL query we put "WHERE lp.class = LearnerProgress". It is easyto forget plus generic methods like findAll() will not work well anyway.LearnerProgress and LearnerProgressArchive can extend a newAbstractLearnerProgress and we use table-per-concrete-class Hibernatestrategy. Same with CompletedActivityProgress andCompletedActivityProgressArchive. But thenAbstractLearnerProgress.completedActivities will not let use both ofthem due to lack of polymorphism in collections. NeitherMap<Activty, AbstractCompletedActivityProgress>norMap<Activity, ? extends AbstractCompletedActivityProgress>will not work. And this collection is the main reason why to doinheritance in the first place.Looking how the above solutions add complexity and little gain, thesefew methods with instanceof seem to be a fine trade off.
Show less
![]() |