Heh. Having just finished the chapter in Code Complete on Abstract Data Types over lunch, I've got a few comments for you.
  1. Use ADT's. They will make your life so much easier. And, your code will be more readable and maintainable. (Read on for how!)
  2. Use accessor methods into your ADT. Rip out every single direct access into your data structure(s) and replace them with well-defined, loosely-coupled accessor routines. Things like GetEmailAccounts(), Remove EmailAccount(), and AddEmailAccount(). Your code using this ADT will be very easy to read. It might even become self-documenting!
  3. Put your ADT into a module. Maybe, even an object! Then (and here's the kicker) ...
    NEVER EVER DIRECTLY ACCESS THE INTERNALS!!!
  4. Let me repeat it.
    NEVER EVER DIRECTLY ACCESS THE INTERNALS!!!
  5. If you do, you will be worse off that you are now, cause you'll change the implementation and something will break and you don't know why and you don't know where and you thought you should've had it cause you had these fancy accessors but someone violated the contract! *deep breath*
The point here is data-hiding/encapsulation/all that stuff. Add on well-named and well-defined accessor methods and the only place your data structure is ugly is in the module(s) that define/access it. Sorta like CGI, DBI, or IO::File, if you think about it. Make your own CGI and the people who follow will bless your name one thousand times.

------
/me wants to be the brightest bulb in the chandelier!

Vote paco for President!


In reply to Use ADT's to Balance everything! by dragonchild
in thread Balancing Complexities of Data Structures, Code and Readability by jlongino

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.