discussion

grapedraughtΛογισμικό & κατασκευή λογ/κού

2 Δεκ 2013 (πριν από 3 χρόνια και 10 μήνες)

93 εμφανίσεις

Action Package

grapedraught
_917cce44
-
c710
-
4bd0
-
a55c
-
c017a9088a9d.doc

Action Package


1.

Top level

Class name or high level issue

1.1.


Second

level

Method or secondary
-
to
-
a
-
high
-
level issue

1.1.1.


Third level

Comment or argument about the issues. First token is author name.

2.

Class: Action

2.1.


execute() or execute(Object…)

What is the parame
ter list of execute()?

2.1.1.


Rob. Parameters: none or Param… (execute() or execute(Object…))

I think it’s clear (is it?) that actions often take parameters (eg: action closeDoor takes a
parameter specifying an instance of a door, and possibly a
manner

parameter

(
slam,
gently…
). So, I think allowing 0 or more undefined parameters make sense. Therefore
we should choose execute(Object…), which still allows for the form execute().

2.2.

{void | Status} execute(...)

2.2.1.


Rob. I vote for Status execute(…)

Status is defined is

really the pair {int statusNumber x String explanation}).

Status is used in casa everywhere. Often what’s really passed back is a
StatusObject<?> (<: Status) which allows for passing back a return value if necessary.

2.3.

abstract Action.getName()

2.3.1.

Rob. Add
this method.

Abstract because a particular class (ie the composite ones) might want to return a
constant, rather than have String attribute returned (ie the run
-
time defined ones).

2.4.

compareTo(Action), equals(Object)

2.4.1.

Rob. Add these methods.

If these are gong

to be put into sortable containers or sets, we want to have control over
sorting/identity. Therefore we should implement Comparable, and it follows we should
implement/override equals() for consistency between compareTo() and equals() (which
is recommend
ed, but not required in the Java documentation).

2.5.

toString() and fromString()

2.5.1.

Rob. We need these for serialization

I don’t like Java serialization, so casa uses toString and fromString for persistence.
Caveat: this needs a lot more thought because we need
to have persistent
definitions

as well as persistent
instances

or these actions.

2.6.

static ActionIO defaultIO, ActionIO IO, setIO(), getDefaultIO(),
setDefaultIO()

2.6.1.

Rob. Add these attributes and methods.

These are all for “visitor”
-
type I/O to allow for pers
istence in Lisp, XML, etc syntax.

Needs more work.

Action Package

grapedraught
_917cce44
-
c710
-
4bd0
-
a55c
-
c017a9088a9d.doc

3.

Class: CompositeAction()

3.1.

Type parameterization?

3.1.1.

Rob. It doesn’t have to be type
-
parameterized.

We can skip the type parameterization if favour of just casting to the specific type of the
contained actio
n (TestAction in your JUnit file).

The implementation you did with type parameterization has the additional problem of
you can’t make a ComposteAction that contains heterogeneously
-
typed action, which
we definitely want to do!

I have made the changes to
your classes to show that this works.

3.2.

Abstract Collection as the primary attribute

3.2.1.

Rob’Im a bit concerned that CoompositeAction requires a Collection to
be passed to it’s constructor to define the concrete type.

I kinda like that fact that you can change t
he collection type to suite the iterator, but this
change is at run time, and the iterator is defined at compile time, so that somewhat
defeats the purpose. Since java will pass by reference, the collection can later be
modified from
outside

the class, wh
ich allows a data validity problem. It might be better
to define the concrete type within the constructor and pass either null or a collection in
the constructor that actually isn’t directly used. Because of it’s convenience, I tend to
prefer using Java’
s “…” construct, which allows us to pass nothing, a arbitrarily long
param list, or an array. (new CompositeAction(a, b, c) == new CompositeAction(new
Action[]{a, b, c})). Helping this, all collections have a convenient toArray() method.

Summary
: I fav
our constructor CompositeAction(Action… actions) over
CompositeAction(Collection<Action> actions).