Re: sale.submit() or submitter.submit(sale)



Responding to Greatlord_5...

There are several different kinds of sales, such as OTCSale, WebSale,
PhoneSale and so on. They are different enough to merit different
classes. However, they are submitted to the mainframe in more or less
the same way.

My question is this:
Should the sale object have a submit operation in it? Or should there
be a separate Submitter class which accepts different kinds of sale
objects?

That depends on what is involved in submitting. If all the submit does is package the object's <unique set of> attributes into a data packet to send to the server, you first choice is fine because the differences are tied to the nature of the Sale object.

OTOH, if the submit needs to work through some exotic network protocol and/or the formatting issues are complicated (e.g., breaking up message packets), then that sort of thing does not logically belong to a sale. So you would likely delegate that to another class. In that case, if the individual submit processing was different for each type of sale you might look at the GoF Strategy pattern for that delegation.


--
There is nothing wrong with me that could
not be cured by a capful of Drano.

H. S. Lahman
hsl@xxxxxxxxxxxxxxxxx
Pathfinder Solutions
http://www.pathfindermda.com
blog: http://pathfinderpeople.blogs.com/hslahman
"Model-Based Translation: The Next Step in Agile Development". Email
info@xxxxxxxxxxxxxxxxx for your copy.
Pathfinder is hiring: http://www.pathfindermda.com/about_us/careers_pos3.php.
(888)OOA-PATH
.



Relevant Pages

  • Re: sale.submit() or submitter.submit(sale)
    ... Sale one. ... The base Sale class will have a submit operation which is overriden in ... each child sale class. ... I'm suspecting that the submitter is not the object you want to use ...
    (comp.object)
  • sale.submit() or submitter.submit(sale)
    ... There is a sale that has to be posted to a ledger. ... If the sale object has a submit operation, ... If there is a separate Submitter class, ...
    (comp.object)