18

I'd like to build an OO hierarchy of errors and warnings returned to the client during a, let's say, pricing operation:

interface PricingMessage {}

interface PricingWarning extends PricingMessage {}

interface PricingError extends PricingMessage {}

class NoSuchProductError implements PricingError {
 ...
}

I'm not very keen on the name PricingMessage. What is the concept that includes errors and warnings?

EDIT: To be clear, I'm looking for a common concept or name for errors and warnings specifically (excluding e.g. general info messages). For instance, compilers also report errors and warnings. What are these?

sandris
  • 1,363
  • 13
  • 27

7 Answers7

15

Some suggestions...

"Result"

An operation has results, which could be some number of errors, warnings, notes and explicit or implied (no errors) success.

PricingResult

"Issue"

An operation ran, but with issues, some of which could be fatal (errors) and some of which might not be (warnings). If there are no issues, success is implied.

PricingIssue

"Condition"

An operation might have or be in an error condition or a warning condition. I think some compilers use "condition" as an abstract term for an error or warning.

PricingCondition

"Diagnostic"

The outcome of an operation might include diagnostics for errors and warnings. Another compiler term, I believe.

PricingDiagnostic
Eric Smith
  • 2,739
  • 2
  • 30
  • 29
5

If you were dealing with java, or similar OO languages, the word you are looking for would be Exception. This indicates that you have reached an "exceptional" condition which needs to be handled in a controlled way.

takendarkk
  • 3,347
  • 8
  • 25
  • 37
  • 4
    The way I understand 'warning' is that the operation has succeeded, but there is something going on that might be counter to the intention of the client. 'Exception', in Java, I think, implies that the original operation has clearly failed. For instance, it would make sense for a method to return a pair of (result, warning), while methods in Java either return a result or throw an exception. – sandris Jan 16 '14 at 16:14
  • That is very true. When I think of a warning however, I don't really think about it as being part of a structure. If the warning you want to provide is just simply a message that the user will only read (as opposed to handle), I would just return/print a string. The exception would be part of the structure you are building because the user may need to actually do something with it. – takendarkk Jan 16 '14 at 16:22
  • Why wouldn't warnings have a structure, just like errors do? How users handle them is also an interesting question, but the internal representation should fit into OO. (e.g to record which users generate which warnings). – sandris Jan 16 '14 at 16:53
  • It's not that you _can't_ or _shouldn't_ make them have structure, I just don't see the need to make them into their own class or interface when there aren't really any methods that will be associated with them. Recording which user generated which error is as simple as storing a string. Only if you have some operations that you want to perform upon the warning message would I build structure for it. – takendarkk Jan 16 '14 at 16:59
  • They *should* have internal structure so that we can define meaningful operations on them -- a certain warning may have subclasses and we might want to capture all of them. The scope I have in mind is clearly much larger than a method, that was just an example. I feel we're sort of drifting away from the original naming question -- let's take it for granted that warnings have a structure, or discuss this offline ;-) – sandris Jan 16 '14 at 17:23
  • Or agree to disagree, which is what I will do! – takendarkk Jan 16 '14 at 17:25
4

Through looking at a few synonym lists, I found the following:

  • Anomaly, oddity, deviation
  • Alert, message, notification
  • Fault, misstep, failure, glitch
NotEnoughData
  • 188
  • 3
  • 8
3

I prefer the name Alert. An alert IMO can have any level of severity, it could be identified as informational, warning, critical or any other level deemed appropriate.

The counter argument I have heard to this naming is the idea that alert the noun follows too closely to alert the verb, making the distinction that the object (noun) may or many not have been brought to the users attention yet (verb). In this context naming them alert could creates a bit of cognitive dissonance, and perhaps confusion for developers reasoning about your code.

The best I can propose would be to create a hard distinction be made in your code base between Alert (the object of exceptional condition) and Notification (the act of bringing the alert to the users attention) to keep things intuitive for programmers moving forward.

krayzk
  • 877
  • 1
  • 10
  • 19
  • Unless you have `Alert` as logging level ;) https://success.trendmicro.com/solution/TP000086250-What-are-Syslog-Facilities-and-Levels – NN_ Dec 27 '20 at 10:30
0

In theory these could be defined as events - so you could use that.

Pete O'Connell
  • 143
  • 1
  • 2
  • 8
0

This is very subjective, but here are a few suggestions:

  • Output
  • LogEntry
mcsilvio
  • 1,098
  • 1
  • 11
  • 20
0

In web design, the term "admonition" is sometimes used for a block of text that can be an error, warning, or informational.

rdb
  • 1,488
  • 1
  • 14
  • 24