• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

sun example Model datatype

 
Ranch Hand
Posts: 264
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi

i checked some example on the sun web site
http://java.sun.com/blueprints/guidelines/designing_enterprise_applications_2e/web-tier/web-tier5.html#1078777

for Example 4.7, we can see



any idea what is: Model?

thank
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It looks like a facade - a single object in the model layer that has all the methods that the Action can call in the model. A facade doesn't do much work, it mostly delegates work to the rest of the model layer.

It might look like:

What value does something like that add when it just passes all the methods through to other objects? It gives the people who write Action classes a single object to deal with, hides that tricky stuff to get a user service instance, and can do more complex things to work with two or three model objects. It lets the people who write the model change things around without telling anybody as long as the facade APIs stay the same.

Is that making sense?
 
mark smith
Ranch Hand
Posts: 264
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
don't know but

Action is an abstract class.... many other class will extend it

like you write your code, Model is specific to an action

that don't have sense
 
Stan James
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yup, confusing. At first I though abstract Action had an abstract Model and concrete extensions of Action would use concrete extensions of Model. But the little sample you gave did not cast the "model" variable to a specific subtype; instead it called createUser() on Model. That made me think that Model might be a concrete type with all the methods all the actions will need.

We're probably over thinking a simple example by expecting it to run exactly as given. In building a real system, you could choose a facade design to make a single Model class serve every Action, or you could choose some other design. Maybe this change would be better:

Or maybe not. Figuring that out is the fun part of design.
 
mark smith
Ranch Hand
Posts: 264
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
anyway, that will not build, Model is not defined

funny that sun provide a lot documentation but are incomplete....
[ December 22, 2006: Message edited by: mark smith ]
 
Stan James
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
They're using some level of abstraction, assuming we can fill in the rest. Some times that's a good shorthand to avoid getting bogged down in deails, and some times it just leaves us saying "Huh?"

Did we explore possibilities far enough that you can make up something to bridge the gaps? There are many possible answers, none of them "right" for all situations, so you will assuredly be on your own at some point.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic