[kplato] Some code for KPTProject::getDuration()
Thomas Zander
kplato@kde.org
Sun, 26 Aug 2001 22:41:28 +0200
--9amGYk9869ThD9tj
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
On Sun, Aug 26, 2001 at 08:47:22PM +0100, John D Lamb wrote:
> Thomas Zander wrote:
>=20
> > Then the data of that relation should either be stored in the relation
> > itself, or in _both_ the item X and item Y.
> >=20
> > I have chosen for the latter since we dont want duplication info.
> >=20
> > Other then that; it is possible to add more then one dependency between
> > 2 nodes, and at the moment you create 2 lists which should be in sync w=
ith
> > each other (one list for the child-nodes and one for their relation) you
> > should look if it is not wiser to create a class to combine that data.
>=20
> That sounds right, but the code at the moment has 3 lists (I think this
> confused me). m_nodes makes obvious sense, but why not just one list:
> m_relations instead of m_dependChildNodes and m_dependParentNodes. OK,
> at the moment I assume m_dependChildNodes should list the Relations
> whose parent is this and whose child is another node with the same
> parent as this. But that seems to have duplication.
You are confusing the time dependent and tree dependent nodes, let
me just state them for completeness.
The 3 lists are as follows;
- m_nodes contains all child nodes in the logical structure.
(making table contains child node polishing wood)
- m_dependChildNodes contains all nodes that are dependent on this node
to [finish|start] before they [start|end]
- m_dependParentNodes contains all nodes that this nodes depends on to
[finish|start] before I can [start|end]
The last 2 are a double linked list idea;=20
Creating table
^ |
| |
| v
House is finished
What I am actually missing is a m_parentNodes, consider the following=20
example:
Dinner
|
+ - Buy food
|
+ - cook food
|
+ - eat
|
+ - set table
|=20
+ - put forks on table
Dinner has 3 children, described in m_nodes. But Buy food, has just one
parent, described in m_parent.
The same example, just time based;
Buy food
^=20
+ ------ cook food
^
+-----------------+
put forks on table |
^
+ -------------- eat
(cant eat until food has been cooked, and forks have been put on table)
In my data structure this means that eat will have 2 parents, and cook
will have one parent and one child.
This data is needed for all sorts of calculations.
Your code examples don't make sense since the 2 tree structures are=20
totally seperate. In my example the whole thing was in one 'tree' but
it is entirely possible to have one node in project X being dependent on
another node in project Y.
Maybe not in the calculations (yet) but in the data structure it should be.
> Here's another way that makes more sense to me. If P is a node that is
> not a task, then m_nodes contains all its subprojects and tasks.=20
You know naturally that m_nodes only contains the direct children, so
Dinner will not contain "put forks on table"
>=20
> KPTRelation* getFirstDependChild() {
> if( m_parent =3D=3D 0 )
> return 0;
> else {
> q =3D find_if( m_parent->m_relations.begin(),
> m_parent->m_relations.end(),
> is_successor( this ) );
Whoa!!! That is a private list, only for internal use, don't use it like th=
at
that is not OO.
In this I mean that it is not nice to assume things about the internals of
data you are pointing to, even if you are based on the same class.
In other words; either store your own data, or use a method on the remote=
=20
object for searching.
> > > How about a flags userStarted and userFinished on each Node to say th=
at
> > > whether the user has specified a start or finish time? with a check on
> > > dependent parent nodes before allowing the user to set something. Then
> > > the start time, end time and duration are either user fixed or estima=
ted
> > > by PERT/CPM. If the user has specified anything, that gives an earlie=
st
> > > starttime that PERT/CPM can use. Otherwise, use 0?
> >=20
> > Excelent, and we can leave the flag out since checking if the m_startTi=
me
> > (=3DuserStarted) is zero means it is not set.
> >=20
> > Oh, wait, that was my initial design as well ;)
> >=20
> Sounds good. Do we need to cover the possibility that a user has started
> an activity, but that it hasn't finished yet?
Yes, an activity should be possible to take a long time, so this is
entirely possible.
> > > I suggest we add (in a struct?) earliest_start, latest_finish as
> > > QDateTimes.
> >=20
> > Just a comment; _dont use structs_. C++ has classes for that :)
>=20
> I used to avoid them, but in C++ they are classes in which everything is
> public by default. Just occsasionally that's useful. There is another
> reason to use structs occasionally, but it's so obscure almost no-one
> uses it. On the other hand, you may prefer to avoid structs.
True, I used them, and then just rewrote them to a class to basically do=20
the same thing.=20
I think it is confusing to see that a struct has a destructor ;)
> >=20
> > Just that it is too hot to do anything intelligent here... (Holland/Eur=
ope)
> Ja! Het is zeer heet hier ook... (Kent/Europe)
> JDL
Great! :))
--=20
Thomas Zander zander@earthling.n=
et
The only thing worse than failure is the fear of trying something new
--9amGYk9869ThD9tj
Content-Type: application/pgp-signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org
iD8DBQE7iV74CojCW6H2z/QRAq2NAKDUCk8Gy+C33m+DVhHFSoJekgiOHwCfdm5k
XO/IeWn7doVDu/erHIL9oAA=
=5DQ3
-----END PGP SIGNATURE-----
--9amGYk9869ThD9tj--