Question

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?

Était-ce utile?

La solution

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

Autres conseils

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.

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

  • Anomaly, oddity, deviation
  • Alert, message, notification
  • Fault, misstep, failure, glitch

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.

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

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

  • Output
  • LogEntry

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

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top