Solved

# revised agent

Posted on 2006-05-26
Medium Priority
264 Views
Hi sjef, marilyng,

Here's a revised problem statement. I'll be working on this all day to come up with some sort of simple algorithm and then I can post and wait for suggestions.

"The program should create test responses for each product document in the database in one year batch. The number of annual tests set for each product are predetermined by  an interval set on the product form".

For example, a customer may have 100 products which he needs to create regular testing on, but he want to test on one product 12 times a year, on some other product 6 times a year and on others only once a year on so on...

Is this problem statement much clearer and simpler?

0
Question by:varvoura
• 8
• 8
• 5

Author Comment

ID: 16775361
Hi all, here a modified version of what the agent suppose to do.

for all productdocs found in db
check hasresponse field on each productdoc
if doc hasresponses = N then
check testtestinterval field on productdoc
check value of excludeweekendfield on productdoc
if value of excludeweekendfield is Y
divide result by 12
get result
do until count equals to result
create testresponse docs
save all responsesdocs
set value of hasresponsefield on productdoc to Y
initiate a save on productdoc
end if

if hasresponse = N then
if excludeweekendfield = N
check if the current year is a leap year
if leap year
divide 366 by the testinterval field value
get result
do until count equals to result
create testresponsedocs for each product
save all responsesdocs
set value of hasresponsefield on productdoc to Y
initiate a save on productdoc

else

if current year is not a leap year then
divide 365 by the interval field
get result
do until count equals result
create responsedocs
save all responsesdocs
set value of hasresponsefield on productdoc to Y
initiate a save on productdoc

end if
end if
end if
end if

if a productdoc is found in db then
if doc hasresponses = Y then
subtract productdoc initialtargetdate from todaydate
get result
if not leap year then
if result = 365
reset initialtargetdate to today's date(this will be used to start the new batch for of testdocs for the next year)
reset hasresponse to N
save productdoc

if leap year
check if result of initialtargetdate - todaydate = 366
reset initialtargetdate to today's date(this will be used to start the new batch for of testdocs for the next year)
reset value of hasresponse field to N
save productdoc

else

if a productdoc is found in db then
check value of hasresponse field on productdoc
if doc hasresponses = Y then
subtract productdoc initialtargetdate from today's date
get result
check if result is < 366 if leap year or
if result < 365  if not leap year
do nothing

end if
end if
end if
end function

Assumptions made: testtestinterval field should not be blank when a user creates a new product document
We divide by 12 to get the number of test for each product based on the
testinterval set on each product

By resetting the initialtargetdate at the end of every year, I am trying to make sure that I create an annual report
added to a specific product throught the year as all the test for the year will be initially created when a new product is created.

By checking if the document has responses and the number of days in process is < 365, I am trying to ensure that not documents are created throughout the year after the initial tests created.

As the agent will be scheduled to run once a day, the next time it runs, it will find the value between the initialtarget date and that day's date <> 365 and the hasresponse is reset to N, so it will create another batch of the testresponse documents for that new year as if it is a new year.

There will be another field on doc(createddate) which will remain unchanged so that the customer will always be able know when the initial product doc has been created.

0

LVL 46

Assisted Solution

Sjef Bosman earned 800 total points
ID: 16775762
A+ for the problem statement!

The pseudo-code is still too detailed. Half of the statements can be removed. Whenever you say "check this" or "check that", it's unnecessary information, because the item will be used in the next line. Also, you use fields, you talk about a leap year and you use a function HasResponse, but that's all implementation. What the LOGICAL idea behind using that function is to find out if there is a Test done already in the past (or so). Please keep in mind that some poor sole/soul, who will have to maintain your software after you, will have a lot of trouble finding the problem in his additional functions when he added just another response-to-response document (e.g. Modifications).

for all productdocs found in db
check hasresponse field on each productdoc              ' X
if doc hasresponses = N then                                    ' ?
check testtestinterval field on productdoc                   ' X
check value of excludeweekendfield on productdoc     ' X
if value of excludeweekendfield is Y                        ' ?
get result of businessday function                     ' ?
divide result by 12                                           ' X?
get result                                                        ' X
do until count equals to result                           ' ??
create testresponse docs
save all responsesdocs
set value of hasresponsefield on productdoc to Y
initiate a save on productdoc                        ' X
end if
...

Do you see there is too much detail in your specifications? The lines with an X can be removed, they are superfluous to me since they add no information. The lines with a questionmark have some higher meaning. I'll try to "translate":

for all productdocs found in db
if there is a test document for this product then
calculate number of required tests
generate those test documents
else
? what should be done when there is no document yet??
end if
???? where is the "end for" or the "next"???
...
and the rest...
0

LVL 18

Accepted Solution

marilyng earned 1200 total points
ID: 16776228
Yes, a good start... I fiddled with the logic a bit, so here's my example.  I really think you need to include a product life cycle on your form.  And the difficulty is not in creating the test documents, but in the long-term maintenance of the parent doc.  At any rate, this is a starting outline of my version of the product testing application.  This is before I wrote ANY code.  Notice how I start with what do I want to see in the views...sjef.. feel free to add to this.

Logic
Given a Product with a created date, a start life cycle date, Life Cycle in Years, and the number of times we need to test this product each year, we want to create a series of test documents that are responses to the Product Document for each test date between the Start and Product Expiration Date.

Since a product life cycle can extend to 20 years, we want to display the Product and its related test documents by:
1.      Year of Test
2.      Current Year Testing
3.      Previous Year Testing
4.      Next Year Testing
5.      Current Month testing
6.      Previous Month Testing
7.      Next Month Testing
8.      Agent View to Collect Parent Documents having a TestDate value or you can do this by dbsearch.
9.      Response lookup view by parent doc ID + yyyymmdd test date lookup key.

The Product document will need the following fields:
Parent DocID field
Product Name
Created Date
Start Life Cycle Date
Life Cycle Years (How many years, 3, 5, 10, 15, 20)
Calculated Expiration Date (adjust Start Life Cycle Date by Life Cycle Years)
Number of Test Intervals per Year
Interval Years (same as Life Cycle)
Interval Days (the number of days calculated: Integer((365/Interval) + .4999)
Test Dates (Generated from available data, maximum field length = 32000 bytes)
Lookup Dates (Generated from Test Dates using the format: yyyymmdd)

The Test Document Response will need the following  Fields:
Parent Doc ID
Test Date
Sort Date (yyyymmdd)
Sort Month (yyyymm)
Sort Year (yyyy)
Whatever other fields are need to complete the test information

Basic Logic:
When a Parent Document is created
-Generate a complete list of Test Dates for the product life cycle on the Post Save event
-Create the test documents for the current year (currentdate to one year from now)
Logic:
-Get all test dates falling in the current year range
-Concatenate the parent doc ID and the yyyymmdd string
-Check to see if the response doc exists
-If not, then create the response doc
Considerations:
If the Product Start Date changes, then the test dates will change.
If the LifeCycle years change, then the test dates will change.
If the Test Intervals change, then the test dates will change.
Additional Field Tracking on Parent Form:
Check StartDate_OLD
Check LifeCycle_OLD
Check TestIntervals_OLD
Check TestDates_OLD

If the Parent Doc is changed then
-Collect current responses
-Keep those that are completed and get the last competed date.
(Using the ParentDOCID+LookupDates_OLD to find the documents)
-Delete those that are not completed.
-Find the next new test date
-Get all the next test dates that fall in the current year date range, and create those documents.

If the last test date was 5/16/2006, and the start date is 4/1/2006,
then you want the next test date following the 5/16/2006 date through 3/31/2007 dates.

-Once you have the list of test dates, loop through each and check to see if the response document
exists by concatenating the parent doc ID + yyyymmdd of the test date.
-If the document doesnâ€™t exist, create it.

Other maintenance:
-What if we need to expire the parent doc.. then we need to remove the future test documents.
-What if we expire a parent doc and then re-open it.
-What if we shorten the product life cycle.
-what if someone accidentally deletes a test date, how would we know?

Agent to create new documents:
(Since we know we are generating the first year of documents when we create the form, then we need to decide how often to run the agent.  Since our lowest counting element is a day, then we need to run the agent once a day. But we only want to run the agent on parent documents that need to have new dates created.. that is the test Dates array contain the target date range.  Else, when the database gets large, the agent will never finish running.

Personally, I would create only ONE document each day.. that is, I would set the target date to one year from today, and find all parent documents having a date value equal to the agent's target date.  for instance, if today's date is 5/27/2006, then my agent would collect Parent docs having a test date in the test date array of  todaydate.adjustyear(1).  Then create those documents.

If my agent runs once a day for a year, by 5/27/2007 I will have test documents created through 5/27/2008

-Start Agent
-Set target testdate
-Collect all Parent Documents having that target testdate in the test array
-concatenate the Parent Doc ID + the targettestdate
-see if the response document exists in the response lookup view
-if it doesn't exist, then create the document.

--------------
Other considerations:

You can create all the test documents when you create the parent document.  The test date array shows no sign of exceeding Notes Limits for a 20 year life cycle, testing every 14 days.  Downside is that you have a lot of documents, and if the user changes the parent document, you would have to delete all the not-started response documents, and then create the new ones.  Many delete stubs, and then replication problems.

Plus side, is that you can instantly check to see if the number of projected test documents exist, and if the number is correct.
0

LVL 18

Expert Comment

ID: 16776289
Also, just reviewing a few things...

I sometimes write some code to see if the logic I think works does work - so I have these test databases will tons of forms, views, agents and script libraries. << but all snippets.

So, once i have the big picture done, I can add little bits of refined logic:

-Start Agent
-Set target testdate
branch- check day to see if it's a weekday
-if not, then get next weekday date.
-Collect all Parent Documents having that target testdate in the test array
-concatenate the Parent Doc ID + the targettestdate
-see if the response document exists in the response lookup view
-if it doesn't exist, then create the document
0

Author Comment

ID: 16777354
sjef, Marilyng,

I'll never be able to thank you both enough for this. I'll will certainly use this example as a solid foundation in future for the many systems that I'll be developing from now on.

Meanwhile, I read briefly all your comments and suggestions. I am going to read it a few times today to make sure that its exactly what I need then I'll post back.

Once everything is all good, then I'll start coding bit by bit and Marilyng I will take your offer of helping me snippets when I need it.

Thanks again

0

LVL 18

Expert Comment

ID: 16777480
Marilyng I will take your offer << hm.. made no offer. :)  Was speaking metaphorically.
0

LVL 46

Expert Comment

ID: 16778782
Hm, I don't have much to add to this :)

Vera, can you see the bigger picture now? Can you also see the bigger picture of the bigger picture, I mean, what Marilyn did and how she got there? I know a lot is born from practice and by now some sort of second nature, but we all started making the same mistake: "Ah, I understand, so now I write main() { and some printf-statements?". May I suggest you buy a good book about the Software Lifecycle, and use it. It describes the "art" of software development, in several phases:
0) definition: a one-liner about the whole system (or one-pager)
1) requirements: in somewhat more detail, WHAT the user wants in HIS terms
2) analysis: in detail, WHAT the user wants in your own terms (logical design)
3) design: in detail, HOW you're going to develop the application (physical design)
4) coding
5) code testing
6) system testing
7) finalisation and implementation at the client's

Prototyping is in my view no more than a repetition of phases 3, 4 and 5, which result in adaptation of documents produced in phase 2 because the client's mindset has changed.

I had, in the old days, some training in the Yourdon methodology, but I'm not a true follower so forgive me if I stray too much. The methods adopted by me work for me.

The analysis phase is WHAT: what does the client want, in terms of data flow, data structure, input, output, types of users, and "processes". Required tools for this are Data Flow Diagrams (DFD's), Entity Relationship Diagrams (ERD's) and logical State Transition Diagrams (STD's). The logic is described using some sort of pseudo code, usually telegram English. Still, no real choice is made regarding the environment (O/S, database, etc) or the language(s) needed to develop the system!

The design phase is HOW: how am I going to develop the application, calling functions, using variables and classes, databases, fields, all the details of the application.

Using C or Fortran back then, phase 3 was a necessary and explicit phase. Nowadays, thanks to the visual development tools we have, the design phase grows more and more into the development phase. What's still a very important step is the partitioning of the code into logical and manageable pieces.

Okay, this all said, you can see Marilyn filled many gaps left by you. There is some Requirements in her description (display Product by), some ERD (the Product document will need the following fields), and some logical process description (basic logic). Still there are several white spaces, for you to find them and colour them in.

A suggestion for a book? Sorry, can't give you one... Marilyn??

This seems an interesting page to read:
http://codebetter.com/blogs/raymond.lewallen/archive/2005/07/13/129114.aspx
0

LVL 46

Expert Comment

ID: 16778983
0

LVL 46

Expert Comment

ID: 16778990
0

Author Comment

ID: 16779246
marilyng,

I have a couple of small questions in regards to your modifications:

1. Check StartDate_OLD
Check LifeCycle_OLD
Check TestIntervals_OLD
Check TestDates_OLD

Are these old values of StartDate, LifeCylce, TestIntervals, TestDates, LookupDates fields which are also found on the product documents?

2. Personally, I would create only ONE document each day.. that is, I would set the target date to one year from today, and find all parent documents having a date value equal to the agent's target date.  for instance, if today's date is 5/27/2006, then my agent would collect Parent docs having a test date in the test date array of  todaydate.adjustyear(1).  Then create those documents.

*************************************************************************
I am still a bit confused here, can you pls elaborate a bit on no. 2 above
*************************************************************************

You are aware that product formis a response for a customer form and that test form is a response of that product form. Will this change anything?

Thank you
0

Author Comment

ID: 16779292
Marilyng,

The Test Document Response will need the following  Fields:
Parent Doc ID
Test Date
Sort Date (yyyymmdd)
Sort Month (yyyymm)
Sort Year (yyyy)
Whatever other fields are need to complete the test information

*********************************************
Test Date field, is the lookup from the lookupdate view in which we have all test dates created for the product for its entire life cycle? Is this correct?

Sort Date (yyyymmdd), Isn't this one value, why are we sorting? or this is an array for the year? Is this used for the year of test reporting view?

Sort Month and Sort year(obviously, they are sort test month and test year) and are mainly used to report in Current Months test, current year test and so on..
Is this correct?

0

LVL 18

Expert Comment

ID: 16779460
1.  yes
2.  agent runs today, finds all documents that need a testdate for 5/28/2007, creates those for those dates.
>>You are aware that product formis a response << and I care why?  I am providing metaphoric examples.  You can fill in the specifics for your needs.

Question 2: if you don't know why you're sorting, then you haven't planned your application, and you need to do that.  Once again, you're jumping to the details when you haven't solved the big picture.

stop that.
0

LVL 18

Expert Comment

ID: 16779499
Parent Doc ID
Test Date <<there can be only one document for each date.
------------------------------
0001PARENTDOCID~20070528
0001PARENTDOCID~20070628
0001PARENTDOCID~20070728
0001PARENTDOCID~20070828
0001PARENTDOCID~20070928

0

LVL 18

Expert Comment

ID: 16779557
Excellent book, sjef!!  I have a copy.   Varvouva, you should get a copy.    Notes provides excellent examples of standards, and accepted practices in its templates, and in the Sandbox instructions and examples.

However, as sjef says, these standards only make sense if you have a good foundation and understanding of the software cycle.   Once you have a good understanding of the cycle, moving to different platforms, languages, or systems becomes a matter of learning the new syntax.  The planning, logic, and cycles are all the same.  The only thing that changes is the properties, methods, syntax and GUI.

So, we will only answer questions after you provide your software cycle example.  Not code, not the agent. :)
0

Author Comment

ID: 16782885
Marilyng/sjef,

It will be hard to read a book and do whatever when you have to deliver a draft of the application by tomorrow afternoon which is 20 hours from now.

Anyway, I have the refined requirements and this time they are final. Marilyng, I know you're doing what you're doing to help me learn much faster but I seriously need your suggestions and help to make this work so I can at least draft of this damn app by tomorrow afternoon, books and life cycles will have to be just after.
I will buy the books that sjef recommeded and start using them. Anyway, I'll have no choice as this is only one of the many development projects that i have to undertake for this year and I have no choice but to make them work.

sjef, thanks for the books, I'll buy them, read them and will practice their theory, meanwhile, I am so tight for time to think about anything but this app right now.

I am so stressed too, so please try not to make any hurtful comments right now. If yo wish to torture me, pls make it later!!

0

Author Comment

ID: 16783095
Revised requirements

Given a created date, a life cycle date, a life cycle period and an expiration date, i would like to create a set of testdate for the entire life cycle of the product on postsave event on the product doc.

1. If a product test date gets deleted, the remaining tests for in the entire period should stay intact.

2. If a product interval is changed, the entire testdate set should be changed according to new interval

3. If the product is expired, then all testdates following the date of the last completed test date(if any test responses exist) should be delete. Test response for that product prior to expiration date, should stay intact as they will be used for historical purpose

4. If a life cycle of a product changes, then the entire set of testdate should change to reflect the new life cycle of product. Completed tests again should remain as they are.

No more creating responses, we will use the test date as reminder to send to clients, so that they can create their own test documents if they decide to carry on a test. if the wish to skip a test which they have been reminded of then, we need to record that skipped date somewhere where we can use to report on skipped tests history.

No other recommendations or consideration for now.

Do I still have to support the above with life cycle?
0

LVL 46

Expert Comment

ID: 16783640
"There's never time or money to do it right.
But there's always time and money to do it over."

Okay, I read your revised requirements. Now how am I going to bring this to you? Let's just say they make me very sad...

0

Author Comment

ID: 16783680
Thanks, this really makes me feel quite great, especially when my job is on the line.
Between my stress level about the job and these comments, I now feel a million times worse!

I said to you that I only want to do this right, but there is an exception with timing for this one which I have no choice but to obey.

Anyway, thanks for helping, I will delete this question and I have recorded all the books you recommended which I'll purchasing and using for future references.

0

LVL 18

Expert Comment

ID: 16784307

I regret, we cannot solve, complete or even work on your job assignment/homework.

I concur with sjef, please delete the question.

0

LVL 18

Expert Comment

ID: 16784865

There are some really good logical steps/discussion here that would benefit other users.  Even if we didn't solve your problem, I would prefer the question be PAQ'd.

However, I would argue that the steps needed to solve your agent problem exist.  You need only to turn the language into viable code, and the plan into forms and views.   Basically, I sat down and wrote out the plan, then did a database shell before I posted.  Took all of three hours for me to say, is this possible? and how quickly can I get it done?

One of the agents from this nice, focused plan would take about 8 hours, given the shell was in place to test on.

Without really knowing what your situation is, it's been my experience that managers either know what they're expecting and are reasonable based on past experience, don't know what they're demanding is unreasonable, or do know that what they're demanding is unreasonable.  The third possibility always concerns me, because this is not a healthy work environment.

So, what is reasonable?  40 hours to plan and propose an application in language and workflow charts, maybe a few form illustrations. No real coding.  A simple 2-3 form application, less, maybe 20 hours.  How long to deliver?  Well, depends on the work involved.

How long does it take to create and illustrate a form, view, frames, pages, outlines?  These basic things take me around 40 hours. Simple to moderate application, 120 hours + 3-6 months testing to implementation.

Very large, complex applications: 6 months to 2 years.  Lots of planning.

Now, I can deliver a whole lot faster because I make it a point to compartmentalize my code and forms.  I write re-usable code.  So, the agent that would take me 25 hours to complete from scratch, would only take me 4 hours since I already have it done.

Have I run into managers that have me going in ten different directions? sure.  It's up to you to get him or her to prioritize these requests and put them into perspective.  Then you need to budget your work, set deadlines, and offer the complete plan of how you can expect to finish assignments.

The one thing you don't want to do is get yourself so frazzled that you make "quick and dirty" choices now that will come back to haunt you when the application is in production.  You cannot possibly think logically if you are frazzled and afraid for your job.  In the US, this is a tactic used to make someone appear incapable of doing the work, or to test to see if someone can work "under pressure."

Telling an artist he can't use the color "purple" should only inspire him to mix red and blue while still conforming to the request.

:)
0

Author Comment

ID: 16789381
Marilyng, THANK U! You comments are so lovely and you are right, I am going to make this my first, yet last messy messy experience. From now on, SLDC or none. I want to really good profound and good because I do get a great satification working in development and I don't to lose that ever.

0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For Desktop Techs: How to retain a user's Notes configuration data when swapping out the end user's computer. (Assuming that you are not upgrading to a completely different version of Notes client) All you need to do is: 1) install Notes oâ€¦
IBM Notes offer Encryption feature using which the user can secure its NSF emails or entire database easily. In this section we will discuss about the process to Encrypt Incoming and Outgoing Mails in depth.
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased riskâ€¦
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
###### Suggested Courses
Course of the Month15 days, 1 hour left to enroll