Hello,

I have stumbled about an implementation issue, which I´m not that sure how to solve. It´s not about programming, but rather design - more specifically nomenclature of object methods.

I have several objects which represent a more or less granular view of some world facts. Lets keep it simple: There is an object class called Entry it has semantic knowledge about a word/phrase. Now I would like to have a method that does the semantic consistency check. This is no problem, but the consistency check is only in the scope as far as the Entry data structure can see - that is, within its own data. So far so good.

Then there is a superposed structure - Dictionary that also has to do semantic checks, but the scope is wider, the checks are touching virtually all Entry-Objects (that are part of the Dictionary).

And last there should be a consistency-check routine, that is looking at several dictionaries simultaneously. Now my problem/ question:

In my first approach I was tempted to call all of these methods semcheck and there will be of course no nameclashes as all semchecks are in separate Namespaces, but is it really a good idea to have them all have the same name? FOrmally the answer would be yes, as they all serve the same purpose within their own semantics. But practically I have serious doubts:

Just because of readability of the code. Objects of the various Classes may exist in parallel and the situation can arise, where in the global function (no method) named semcheck you have a call $e->semcheck; folowed by $d->semcheck probably folowed by a recursive call to &semcheck;

What say you? Should I avoid calling them the same (and thus circumventing what OO would like to abstract), or should I have faith in readability of good OO code? What is your experience?

Thank you for your opinions and suggestions

Richard


In reply to Question to OO Masters (about Style) by PetaMem

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.