[ Post New Message | Post Reply to this One | Send Private Email to Mike Mannakee | Help ]

Duplicating code

from Mike Mannakee (B3FEETBACK@AOL.com)
In the Dated item functions, these two:

ostream& DatedStockItem::Write(ostream& os)
{
  os << m_Expires << endl;
  os << m_Name << endl;
  os << m_InStock << endl;
  os << m_Price << endl;
  os << m_MinimumStock << endl;
  os << m_MinimumReorder << endl;
  os << m_Distributor << endl;
  os << m_UPC << endl;

return os; }

void DatedStockItem::FormattedDisplay(ostream& os) { os << "Expiration date: "; os << m_Expires << endl; os << "Name: "; os << m_Name << endl; os << "Number in stock: "; os << m_InStock << endl; os << "Price: "; os << m_Price << endl; os << "Minimum stock: "; os << m_MinimumStock << endl; os << "Reorder quantity: "; os << m_MinimumReorder << endl; os << "Distributor: "; os << m_Distributor << endl; os << "UPC: "; os << m_UPC << endl; os << endl; }

have me wondering was it just personal choice that you decided to rewrite all the code for these functions in this class, or was there some reason you couldn't have just output the expiration date material and then called the same function in UndatedStockItem to handle the rest of the function? Isn't one of the ideas behind OO programming in the first place that you don't have to go rewriting lots of code?

(posted 9091 days ago)

[ Previous | Next ]