home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / lang / cplus / 18334 < prev    next >
Encoding:
Text File  |  1992-12-23  |  3.0 KB  |  91 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!psinntp!uu0465!andrew
  3. From: andrew@tagsys.com (Andrew Gideon)
  4. Subject: Re: Complexity in the eyes...V2.0
  5. Message-ID: <1992Dec23.031930.15291@tagsys.com>
  6. Followup-To: comp.lang.c++
  7. Summary: That which the errorstack stacks
  8. Keywords: error errorstack
  9. Sender: andrew@tagsys.com (Andrew Gideon)
  10. Organization: TAG Systems inc.
  11. References: <1992Dec17.042207.8150@tagsys.com> <rmartin.724631935@thor>
  12. Date: Wed, 23 Dec 1992 03:19:30 GMT
  13. Lines: 76
  14.  
  15.  
  16. In article <rmartin.724631935@thor> rmartin@thor.Rational.COM (Bob Martin) writes:
  17. >
  18.     ...
  19. >
  20. >ErrStack e;
  21. >e.PushMessage("Device error");
  22. >e.AddParam(deviceAddress);
  23. >e.AddParam(errorCode);
  24. >
  25. >--
  26. >Robert Martin                        Training courses offered in:
  27. >R. C. M. Consulting                       Object Oriented Analysis
  28. >2080 Cranbrook Rd.                        Object Oriented Design
  29. >Green Oaks, Il 60048 (708) 918-1004       C++
  30.  
  31.  
  32. Hmm.
  33.  
  34. If I understand your proposal, you'd have me add an ordered collection
  35. of "parameters" to the base error atom class?  Interesting thought.
  36.  
  37. Well, let me describe my vision of the error atom - something that I
  38. stayed away from in previous posts.
  39.  
  40. The base error atom class ErrorAtom provides virtual methods
  41. like theSeverity(), theMessage(), isWarning(), etc.  Each module
  42. (or some other partition of code) provides a subtype of the error
  43. atom for a specific domain of errors.  
  44.  
  45. So instances of the DeviceErrorAtom class might contain a severity
  46. value and an offset into an array of error messages.  This array would
  47. be a class member (static member).  This provides for easy copying of
  48. atoms, nicely partitioned error spaces, a good starting point for user
  49. documentation, etc.
  50.  
  51. In practice, I rarely got this far.  Instead, I used a generic error
  52. atom which contained a severity and a message string.  The strings
  53. were efficient, but the solution was not nearly as complete as I'd
  54. originally envisioned.  
  55.  
  56. I can certainly envision an atom class accepting additional parameters, 
  57. and then having these used in generating the message returned by
  58. theMessage().  It is an good idea.  Thanks.
  59.  
  60. But I might change your example to:
  61.  
  62.     ErrorStack    err;
  63.     DeviceError    devErr;
  64.  
  65.     devErr.theError(code);
  66.     devErr.theAddress(deviceAddress);
  67.     err.pushMessage(devErr);
  68.  
  69. Add a reasonable constructor, and we have:
  70.  
  71.     ErrorStack    err;
  72.     err.pushMessage(DeviceError(code, deviceAddress));
  73.  
  74. A later call to theMessage() on that atom might yield:
  75.  
  76.     "EMP scrambled device brains at address 0x666"
  77.  
  78. Hey.  I like it.
  79.  
  80.     - Andrew Gideon
  81.  
  82. === 
  83.  -----------------------------------------------------------
  84. | Andrew Gideon              |                              |
  85. | Consultant                 |                              |
  86. |                            |   TAG Systems inc.           |
  87. | Tel: (201) 890-7189        |   D2-181 Long Hill Road      |
  88. | Fax: (201) 890-1581        |   Little Falls, N.J., 07424  |
  89. | andrew@tagsys.com          |                              |
  90.  -----------------------------------------------------------
  91.