Re: To Reference or not to reference



On 3/29/07, Marilyn Sander <marilyn-sander@xxxxxxxxxxxxx> wrote:
Chas,

You mention an issue that i've been pondering for a while. When and
why should you
use an OO style instead of a hash? If your basic data structure (or
several) is a hash,
what is to be gained by refactoring as OO? Isn't OO just a large
amount of syntactic
sugar surrounding some simple data constructs?

I'm not being facetious or sarcastic. I characterize OO as "syntactic
sugar" only as a
straw man to knock down. I really would like to know what people see as
the advantage to OO in this situation.
snip

When you have one data structure that has lots of functions called to
operate upon it you have an object whether you are doing OO style or
not. There are definite benefits of switching to an explicit OO style
in those cases:

1. The relationship of the functions to the data is clearer
2. You can generalize code up into super classes
3. Passing around objects is conceptually easier than passing around
hashes or hashrefs
4. You gain the ability to easily hide implementation and therefore
the ability to create facades (very useful for testing)

There are other benefits as well, but I need more caffeine.
.



Relevant Pages

  • RE: Who changed /proc/<pid>/ in 2.6.0-test5-bk9?
    ... when I pass an abstraction (data structure etc) around ... didn't have the ability to do CLONE_THREAD at all. ... send the line "unsubscribe linux-kernel" in ...
    (Linux-Kernel)
  • Re: Hash order bug?
    ... a review of one's Data Structures course may be in order ... did I realize that the underlying data structure is a hash, ... If you need to iterate through a hash in order by key, ...
    (comp.lang.ruby)
  • Re: Parsing dhcpd.leases and squid access.log
    ... Paul Kraus wrote: ... Need to create a hash like data structure that contains the key as ... The dhcpd leases file contains all leases handed out and the ... - You never read from the %users hash. ...
    (perl.beginners)
  • Re: [rfc][patch] dynamic resizing dentry hash using RCU
    ... that to the dentry hash. ... the find details because it is not in code or pseudo code format. ... All you need it to know how to perform a lookup on both your old ... and new data structure, and the same algorithm is basically applicable ...
    (Linux-Kernel)
  • Re: hash table size
    ... You pointing out that a chess hash table is being done as a cache rather ... some sort of data structure that gets updated dynamically. ... simple and a fixed cost regardless of the size of the table. ...
    (rec.games.chess.computer)