Assignment
"The JavaScript Math object
contains advanced mathematical methods
and constants. ... Using some of the
Math object methods, create a calculator
that performs advanced calculations,
including the exp() (exponential value)
function and the sqrt() (square root
function). Instead of using the eval()
method to evaluate the contents of
a text field, allow users to type
a number into a text field and then
calculate the number directly using
individual buttons for such advanced
math functions. Save the program as
AdvancedCalculator.html." (p.
169 of book)
In her day job, Elizabeth works as
the human factors engineer on a system
engineering team that defines requirements
for enhancements to an information
system, and provides them to the software
engineering team for implementation.
The clearest way to state what a product
must do so that it can be designed,
coded, and tested unambiguously
is to write the "shall"
statements that the assignment contains.
(It is also the best way to make sure
the assignment is understood and to
identify any questions about it.)
These requirements (also called "shall"s)
consist of two kinds:
- Explicit requirements are
specifically contained in the assignment
or the specification of what the
product must do
- Derived, or implicit, requirements
are identified and defined (usually
by the software team) to capture
what is implied but not specifically
stated by the explicit requirirements.
This assignment has four explicit
requirements, and yields four derived
requirements.
Requirements
Explicit requirements:
- The Advanced Calculator shall
perform built-in JavaScript functions,
including but not limited to the
EXP and SQRT functions.
- The Advanced Calculator shall
accept input typed from the keyboard
into a text field.
- Each of the advanced math functions
in the Advanced Calculator shall
use a button that operates directly
on the number in the text field.
- The Advanced Calculator shall
be stored in a file named AdvancedCalculator.html.
Derived requirements:
- The Advanced Calculator shall
replace the number in the text field
with the result of the calculation.
(reason: It has to go somewhere.)
- The Advanced Calculator shall
limit its advanced math functions
to those that accept only one text
input from the user. (reason: There's
only one text input field.)
- The Advanced Calculator shall
leave the result in the text field
until the user enters a new one.
(reason:
- The Advanced Calculator shall
provide a "Clear" button
that erases the current contents
of the field. (reason: The user
has to have a way to start over.)
These last four are really more design
decisions, or maybe software requirements
(not that there's a big difference
<grin>), than they are requirements
at the product level, but they are
things we identified as necessary
for the Advanced Calculator to work
correctly and be usable.
Team Process
We spoke by phone on Friday, July
2, and agreed that Elizabeth would
design and set up the webspace for
the Green Team's projects. This was
completed on Saturday, July 3.
We emailed several times during development,
and spoke by phone once more.
Janey wrote, commented, and tested
the code. She made it look like a
physical calculator, and even included
one of the theme colors from the Green
Team project site. She emailed Elizabeth
with a couple of concerns about its
functioning and questions about its
look. Elizabeth tested it as well,
said it seemed to work fine, and gave
some suggestions for tweaking the
visual design. We spoke again by phone
on Tuesday, July 6, and discussed
further details about the look (button
alignment, etc.). Elizabeth asked
for clarification about the purpose
of some items in the code; Janey gave
explanations, and the team discussed
one or two modifications to the code.
Both team members use Dreamweaver.
Almost all of this record was written
after the product was complete. Derived
requirements would normally be documented
as they were identified (rather than
later), but in this case it is only
their documentation (the writing-down,
as it were) that lagged; the needed
features were identified and discussed
during the process.
Documentation of Product
Description
This product works similarly to a
hand-held calculator that has a small
number of functions. Via the computer's
keyboard, the user enters a number
into a text box at the top of the
calculator and clicks one of the buttons
to perform a calculation on the number
entered. The user can clear the input
at any time, by clicking the "Clear"
button.
The calculator provides six functions:
SQRT (square root), ABS (absolute
value), EXP (exponentiation, with
a base of e), LOG (natural
logarithm), SIN (sine), COS (cosine),
x^2 (x squared), and x^3 (x cubed).
The six function buttons are approximately
the same size and are arranged in
rows and columns, with related buttons
beside each other. The "Clear"
button is centered at the bottom,
and is wider than the others.
Software Design
A function in the <head> section
accepts input from the text box and
returns a number to the advanced math
function invoked by the button the
user clicked.
Each button in the calculator invokes
one built-in JS math function and
stores the result in the text box,
replacing any content that was there.
The Clear button sets the text input
to the null string.
Lessons Learned
Typing new input into the text field
without clearing it first will append
the new input to the existing content
in the field. I (Elizabeth) do not
think it likely that the user will
begin typing before clearing the existing
content, but it is a potential source
of error. Ideally, the field should
be blanked out when it receives focus.
|