[Cs5500] Redesign of the game definition

Ahmed Abdelmeged ahmed.mohsen at gmail.com
Tue Mar 8 18:21:40 EST 2011


On Tue, Mar 8, 2011 at 4:14 PM, Karl Lieberherr <lieber at ccs.neu.edu> wrote:

> Getting back to Rick's remark that the protocol should be indepedent
> of the domain,
> consider Anush's and Rashmi's code:
>
> /home/lieber/.www/courses/se-courses/cs5500/sp11/GenericSCG/anush-rashmi/HSR
> Game Definition/hsr/protocol
>
> Positive {{
>        public double getResult(Claim claim, List<Response> replies){
>                double claimedQuality = claim.getQuality();
>                if(replies.length() == 2){
>                        ProvideResponse provideResponse =
> (ProvideResponse)replies.lookup(0);
>                        if(provideResponse.getInstance() == null){
>                                provideResponse.getInstance().finishParse();
>                        }
>                        HSRInstance i =
> (HSRInstance)provideResponse.getInstance().getInstance();
>
> The last line is the only one depending on the domain. To stay with
> Ahmed's design approach,
> it is important that the protocol is independent of the domain.
>
> Ahmed recommends to use:
>
> Instance i = (HSRInstance)provideResponse.getInstance();
>
> and to take the protocol code outside the hsr directory.
>
> Anush and Rashmi: please can you test this redesign.
>
HSRInstance i = (HSRInstance)provideResponse.getInstance().getInstance();

with

InstanceI i = (InstanceI)provideResponse.getInstance().getInstance();

same for the protocols in csp.
A better solution yet, is to make Instance implement InstanceI and forward
it's methods to the "inner instanceI". This way it is also possible to
localize finishparse() calls into Instance (if the inner instanceI is null
then call finish parse otherwise forward the call to the inner instance).


>
> The benefit is, as Rick said, better modularity and reusability of
> protocols.
>
> -- Karl
>
> _______________________________________________
> Cs5500 mailing list
> Cs5500 at lists.ccs.neu.edu
> https://lists.ccs.neu.edu/bin/listinfo/cs5500
>
>


-- 
Ahmed
-------------- next part --------------
HTML attachment scrubbed and removed


More information about the Cs5500 mailing list