mercredi 31 mars 2021

Design pattern - Best place for helper class

I have a question regarding source code structure. What is the package should I allocate the helper classes which implement some logic.

enter image description here

Here is my source code structure. Let me explain it:

I have many rules when getting information about a flight, such as baggage allowance rule (BaggageAllocationRule.java), meal rule, seat allocation rule... All above rule has common information that is defined in FlightCommonRule class (extends abstract class Rule). Then, I have abstract class RuleMatcher that provides functions to lookup matched rules. There are 2 types of RuleMatcher, SingleHitRuleMatcher (returns at most one rule), MultipleHitRuleMatcher (returns multiple rules).

I think that BaggageAllowanceRuleMatcher, SingleHitRuleMatcher, MultipleHitRuleMatcher, RuleMatcher are allocated in the wrong package (model).

How should I restructure the source code?

Aucun commentaire:

Enregistrer un commentaire