views and dynamic binding 
Author Message
 views and dynamic binding

This is related to the example given in the book (OOS/W Construction).
The example talks about how to create different 'views' ( in database sense)
of the same data structure using exports and inheritance:

It defines a class bank_account with all the procedures but without exporting
any, different views like clerk_view,customer_view etc are direct children
of the class bank_account with different exports.

Now suppose in one top level class ( like session) i need to have different
views of the a same account:

I am confused about how to do it:

first of all when i create a new account: should i create a bank_account entity
or a manager_view entity  or  a customer_view entity? Basically it is not clear
to me how different views could be refered to the same account object.

Perhaps reverse assignment attempt will be useful here: create the account as
bank_account type and reverse assign to different views.
Then the routines in session has to  be written in terms of the class
type  to which it dynamically binds after the reverse assignment to satisfay
static type checking of eiffel.  Is this the correct
way to do it?  Am I missing some simple things?

Any help is greatly appreciated.

--partha



Sun, 25 Sep 1994 06:06:35 GMT  
 views and dynamic binding

Quote:

> This is related to the example given in the book (OOS/W Construction, p272).
> The example talks about how to create different 'views' ( in database sense)
> of the same data structure using exports and inheritance:
> It defines a class bank_account with all the procedures but without exporting
> any, different views like clerk_view,customer_view etc are direct children
> of the class bank_account with different exports.
> Now suppose in one top level class ( like session) i need to have different
> views of the a same account:
> I am confused about how to do it:
> first of all when i create a new account: should i create a bank_account entity
> or a manager_view entity  or  a customer_view entity? Basically it is not clear
> to me how different views could be refered to the same account object.
> Perhaps reverse assignment attempt will be useful here: create the account as
> bank_account type and reverse assign to different views.
> Then the routines in session has to  be written in terms of the class
> type  to which it dynamically binds after the reverse assignment to satisfay
> static type checking of eiffel.  Is this the correct
> way to do it?  Am I missing some simple things?

I believe the confusion is Meyer's, not yours.  The reverse assignment
operation is not relevant here, since it only provides the ability to assign
an entity with static BANK_ACCOUNT to an entity of static type CLERK_VIEW
if the dynamic type of the object bound to the entity is actually CLERK_VIEW.

I also believe the solution is straightforward: create another type called
INTERNAL_BANK_ACCOUNT, which is a descendent of all the xxx_VIEW classes,
in which a feature is exported if it is exported in *any* of its ancestors.
Then instantiate your bank account as INTERNAL_BANK_ACCOUNT, and everything
should work as desired.

Cheers,

Geoff
--



Sun, 25 Sep 1994 21:21:56 GMT  
 views and dynamic binding

Quote:

>This is related to the example given in the book (OOS/W Construction).
>The example talks about how to create different 'views' ( in database sense)
>of the same data structure using exports and inheritance:

>It defines a class bank_account with all the procedures but without exporting
>any, different views like clerk_view,customer_view etc are direct children
>of the class bank_account with different exports.

>Now suppose in one top level class ( like session) i need to have different
>views of the a same account:

>I am confused about how to do it:

>first of all when i create a new account: should i create a bank_account entity
>or a manager_view entity  or  a customer_view entity? Basically it is not clear
>to me how different views could be refered to the same account object.

Using the inheritance hierarchy from the book example, you would have
to create a CLERK_VIEW or CUSTOMER_VIEW object.

Quote:
>Perhaps reverse assignment attempt will be useful here: create the account as
>bank_account type and reverse assign to different views.
>Then the routines in session has to  be written in terms of the class
>type  to which it dynamically binds after the reverse assignment to satisfay
>static type checking of eiffel.  Is this the correct
>way to do it?  Am I missing some simple things?

Reverse assigment would not work here. Because object of type
BANK_ACCOUNT is not of type CLERK_VIEW - reverse assigment would just
give you "Void".

I think that the inheritance hierarchy of this example is wrong. It's
upside down. It should be like this:

       CLERK_VIEW      CUSTOMER_VIEW      MANAGER_VIEW
           ^                ^                  ^
           |                |                  |
           \                |                  /
            \               |                 /
             \              |                /
              \             |               /
               ----   BANK_ACCOUNT  -------

Then you create BANK_ACCOUNT objects, and then assign it to entities
of the type you want. So, the code might look like this:

            account : BANK_ACCOUNT;

            c_acct : CLERK_VIEW;

            ...

            account.Create;
            c_acct := account; -- now you get clerk's view through
                               -- the "c_acct" entity.

I hope this answers your question.

...richie

P.S. It feels funny to disagree with OOSC , I hope I didn't put my
     foot in my mouth. :-)

P.P.S. This example also shows a non-trivial use of
       multiple-inheritance.
--
* Richie Bielak   (212)-815-3072   | "Your brain is a liquid-cooled parallel  *

* Bang {uupsi,uunet}!bony1!richieb | "This is the fan."                       *
*    - Strictly my opinions -      |                     - David Chudnovsky - *



Mon, 26 Sep 1994 20:31:56 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. views,dynamic binding, addendum to my previous posting

2. No bind on variable View (801) attempting ot open the currewnt view

3. Dynamic Index Filter and VIEW

4. Dynamic views

5. Dynamic Tree-View

6. Dynamic view creation

7. Model for creating dynamic views in IBM Smalltalk?

8. VisualAge Dynamic Views

9. Error: View-Presenter binding in packages

10. Bind Error and view errors

11. No Bind 801 View Open Error

12. View engine AND BINDING ERRORS!!!

 

 
Powered by phpBB® Forum Software