Re: Test Driven Development Sample

From: Universe (universe_at_covad.net)
Date: 12/04/03


Date: Thu, 4 Dec 2003 04:19:29 -0500


"Isaac Gouy" <igouy@yahoo.com> wrote in message

> igouy@yahoo.com (Isaac Gouy) wrote in message
> We can use a similar approach to accumulate the intermediate bowling
> scores for a possibly incomplete sequence of valid throws - update the
> sequence after each throw and recalculate the scores.

Yeah bouyeee!!!!

Just excited, man! I got it! Shweet worked out overall architectural
plan and real, actual proven hooks for then nitty gritty, lower level,
"how" aspect of the design.

[Aside: if a single class with "everything in it" effectively models
essential logical domain role abstractions and collaboration dynamics,
then it does. It would be silly to condemn such an OO design out of
hand, purely on the basis of it using only a single class. Some domains
are logically anchored in only 1 single major abstraction, or a single
abstraction period. Avoid dogmatism.] Check use of lighthearted,
*Logical* OOPL:

class Scorer
{
private:
    ref2FrameStructure Frame;
    ref2BagO'Frame FrameBag;
    bool isFoul;
    bool isBonus;
    int PinArray
    int ThrowCount;
public
    Scorer( "init privates"; );
    throw(Pins;...)
    tally(Pins; ThrowCount; isFoul; FrameBag... )
};

structure Frames
{
private:
    int FrameNum;
    int mainDigit;
    int upperLeftDigit;
    int upperRightDigit;
public:
    Frames(0, 0, 0, _FrameNum) { FrameNum=_FrameNum; };
};

~ must know specific pins up/down after a throw.
    e.g if Pin 1 is standing after a throw( ) it affects the way Frame
score is calculated
~ must know if bowler committed line isFoul
~ must know specific

It seems the "tuned" following code might work as my 'tally( );'

Elliott

> Start = scores [10, 4,6, 10, 4,6, 10, 4,6, 10, 4,6] [] 0 0
>
> scores pins a total 10 = a
> scores [] a total count = a
> scores [x] a total count = a
>
> scores [x,y] a total count
> | x == 10 = a
> | x+y == 10 = a
> | otherwise = a++[total+x+y]
>
> scores [x,y,z:rest] a total count
> | x == 10 = scores [y,z:rest] (a++[total+x+y+z]) (total+x+y+z)
> (count+1)
> | x+y == 10 = scores [z:rest] (a++[total+x+y+z]) (total+x+y+z)
> (count+1)
> | otherwise = scores [z:rest] (a++[total+x+y]) (total+x+y)
> (count+1)
>
>
> The answer in this case would be [20,40,60,80,100,120,140] - the 8th
> total for the spare cannot be calculated until the next throw.
>
> best wishes, Isaac

+

-- 
Rather than try to make object design as much like procedural design as
possible, I have found that the most effective way of teaching the
idiomatic way
of thinking with objects is to immerse the learner in the "object-ness"
of the
material.


Relevant Pages

  • Re: More CChildFrame questions
    ... DisplayInfo info; ... Note that if you "know UML" then why didn't UML tell you that your design was bad? ...
    (microsoft.public.vc.mfc)
  • Re: exe error, works on some pcs but doesnt on others
    ... Make sure you have a .msi file to install it; create this using the install project ... the "wizard" is crippled (another piece of irresponsible design) ... int GetScreeny ... GdiplusStartupInput gdiplusStartupInput; ...
    (microsoft.public.vc.mfc)
  • Re: Inheritance
    ... Yes I think you are right, it is a bad design. ... int wheels; ... class glider: public monoplane { ... Given this hierarchy, I can probably come up with actual planes that don't fit it. ...
    (microsoft.public.vc.mfc)
  • Re: [CodeGallery] MFC MD5 Calculator
    ... Then when they added types, internally, the compiler still thought they were int values, ... ANSI standard began to emerge that the language design ...
    (microsoft.public.vc.mfc)
  • Re: Why I dont believe in static typing
    ... igouy@yahoo.com (Isaac Gouy) writes: ... trick, where it actually performed the computation (with n=5, I ... presume) and concluded it was an int. ... If I add a cast to integer for the above formula (or construct an int ...
    (comp.lang.lisp)