-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Modularized code quality needs improvement. #300
Comments
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
One more: Allow configuration of packages to be scanned for external predicates. |
@AntoniusW could you please take care of this? I lack the level of detailed expertise in our |
The current javadoc for both of these is not approachable to users without in-depth knowledge of ASP solver architecture. Any API user wanting to use anything other than default settings here will have to read some research papers as well as sources of the |
|
Moving a TODO here: class BasicLiteralImpl extends AbstractLiteral implements BasicLiteral
// TODO could we parameterize Literal with Atom type? |
Resolves #108. See #300 for further suggestions to improve code quality. Summary: - New Gradle modules. - Hide implementations, provide API. - Move CLI to separate module, consuming API. Co-authored-by: Michael Langowski <[email protected]> Co-authored-by: Antonius Weinzierl <[email protected]>
Here we track code quality issues that became visible due to the modularization. The goal is to fix those issues after the basic modularization has been merged into master, as addressing all of them before merging would significantly increase the scope of changes already in PR #274. The lists here will be expanded during code review and modified according to ongoing discussions.
Documentation missing:
BinaryNoGoodPropagationEstimation
.BasicSubstitution
.Refactoring required:
Alpha#getConfig
is never used and can be removed.AnswerSetQuery#forPredicate(Predicate)
and the interface contains superfluouspublic
modifiers.ProgramParser#parse(Map<String, PredicateInterpretation> externalPredicateDefinitions, Path... programSources)
is the sole overloadedparse
method where external predicates is the first parameter (probably due to varargsPath...
). This should be in line and varargs avoided with aPath[]
array as first parameter.Refactoring suggestions:
NormalProgram
from API and keep it only in core.NormalProgram
is contained inDebugSolvingContext
and written inMain.java
but anASPCore2Program
would suffice there.java.util.function.Predicate<Predicate> filter
andAnswerSetPredicateFilter
may be more telling.AnswerSet
could support methodMap<Predicate,SortedSet<Atom>> getInstances()
while method#getPredicateInstances
could be renamed to#getInstancesOfPredicate(Predicate)
.ComparisonOperator
should probably be replaced with an enum in API and just state the standard operations. There should to be no need for arbitrary comparison operators. Additionally,ComparisonOperators
replaced a switching of the type of operator with sub-classing, spreading the behaviour ofComparisonOperator#compare
over six classes -- a simple switch in one place probably is much more understandable and avoids a lot of boilerplate. Additionally, inAggregateLiteralSplitting
an if-else-if chain could be replaced with a switch on the enum (again).MinusTerm
ofArithmeticTermImpl
seems superfluous.Atom
andLiteral
hierarchies (not all interface methods make sense on every atom or literal). This should also consider dissolvingVariableNormalizableAtom
as its only method is implemented by all atom implementations. Consider whether a generic form of literalLiteral<SpecificAtomType>
makes sense.BasicSubstitution
really should be in commons and not just in core and available through a factory in commons. Some methods ofSubstitution
may have better names.AbstractProgram
should implementProgram
.Predicate#isInternal
andPredicate#isSolverInternal
likely should not be in API as their names already suggest.ComponentGraph#SCCComponent
are not named very intuitively.DependencyGraph
is actually a predicate-dependency graph, this should be reflected in its name. Furthermore,DependencyGraph#Node#getLabel
is only an alternative name forNode#getPredicate#toString
and probably can be removed.Unifier
currently extendsSubstitution
, but maybe should be the other way round asSubstitution
is actually only for grounding substitutions and unifier is a substitution that allows mappings to variables, not just ground terms. AsSubstitution#eval
is used at the core of all grounding, care must be taken to not impact performance negatively with those changes.Predicate
really needs methodsisInternal()
andisSolverInternal()
.AggregateElement
represents.Atom#substitute
methods, also document them.AnswerSetQuery
allows to set filters but lacks the most important one, namely whichPredicate
this query is applied to. This is currently based in the factory method to construct a query, but would make more sense in place where all other conditions for the query are set.DisjunctiveHead
or implement a rewriting in case input program is head-cycle-free.Literals#fromAtom
is a duplicate ofAtom#toLiteral
functionality and remove if so.at.ac.tuwien.kr.alpha.commons.substitutions.Instance
from api/commons view and move to core.TODO
comments in code.Terms#renameTerms
is mis-named as it callsnormalizeVariables
which in turn renames only variable terms.Terms#evaluateGroundTerm
to make clear that this is arithmetic evaluation yielding integers.Terms#new..Term
vsPredicate#getPredicate
vsAtoms#new..Atom
vsLiterals#fromAtom
. Previously most of these used a#getInstance
naming.CompiledRule
andCompiledProgram
exists since both are in alpha-core where their only implementationsInternalRule
andInternalProgram
also exist. It seems that both interfaces can be deleted.BridgedGrounder
andBridge
architecture of the grounder could be removed, since it is not in use any longer and Alpha nowadays has its own mechanism for external predicates.RuleGroundingOrder
andRuleGroundingInfo
can be reverted as this is pretty internal information and only used in the core.core.Programs
provides one single helper method (of 2 lines of code) that is only used in one test, maybe the class should be inlined completely.[Interface]Impl
andBasic[Interface]
but we also have interfaces namedBasicAtom
which gives rise toBasicAtomImpl
.AtomCounter
should count atom types based on theirString
representation or onClass
objects.parseAndPreprocess
function, it looks like this could be shared among those tests.ASPCore2Program
whose sole implementation isInputProgram
, which is not obvious from the naming.Improve/Complete documentation in:
The text was updated successfully, but these errors were encountered: