Pretend you have an object that represents something like an "Order" in the sense of a shopping cart order. The order object has all these attributes and methods, and after you have populated the order with a customer, a list of items, and finalized the order using your fancy methods, you want to print out the order information to the customer so they can have a look over it and send an e-mail message if something is wrong. Not an uncommon problem.
It seems you are suggesting that instead of having accessor methods I can use to query specific data from the object and pass said data to something like a template system, you would have a method on the $order object called something like $order->print() or $order->fetch_printable() or something like that. In which case, we either have embedded HTML or template logic (where the templates are located, how to populate them) inside the class.
Now pretend this information is embedded into an outer page. Fine, you can use a script to pull the printable and place it inside the other page. What if you want to use some specific information from the order to place in the TITLE of the page? For instance, the order number? Oh wait, we can't have accessors so we will have to have the order object generate the entire page.
So then you get into this situation where each of your objects have to know how to render themselves completely (in the context of an entire web page, or pdf file, or gui window, etc.). But in order to render themselves, they need some information from other objects, which in turn requires accessors.
So exactly what are you suggesting?
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.