well that's it - I am not at all sure with OOP - I have to big questions:

1) With a class for the FX object - you could have many instances of that object - however where would I set a "global" setting that affects all the objects in that class - e.g. 'the separator character, or '/' (e.g. 'EUR/USD', or maybe 'EURUSD', or 'EUR-USD') - do I have to create a parent class or something?

2) It strikes me that I could break down the object a bit more and have a "Quote" class which would contain something like (timestamp, open, high, low, close) - that could then be used with many derived classes not just Forex quotes, but Stock Quotes, Bonds quotes, etc.

3) and then I guess you could create one 'pair' object - e.g. 'EUR/USD', and then have many (an array) of quote objects for each pair object. Or would that be better to have a quote object which would be of type 'pair' (e.g. type 'EUR/USD')...

and then I get a head explosion and think of giving up...

Also another principal I have heard is that one should make as much of the code as possible as straight functions (normal module code) so that it could be called by any script, and then have the Class call the straight function - is that a good practice?


In reply to Re^2: API Design by Galdor
in thread API Design by Galdor

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.