88

I was reading Algorithms in a Nutshell (O'Reilly) and came across this symbol in a class diagram. My guess is that it means the member is protected, but I wanted to see if anyone knows for sure what it means.

troyal
  • 2,499
  • 6
  • 25
  • 28

5 Answers5

185

It indicates a protected member of a class or other data type.

- Indicates private

+ Indicates public

# Indicates protected

Mike Hofer
  • 16,477
  • 11
  • 74
  • 110
  • 1
    Yes, or protected 'operation'. – Jayden Jan 06 '09 at 21:54
  • 1
    The visibility indicator can apply to association ends as well as attributes and operations. – chimp Jan 06 '09 at 22:41
  • I've seen some UML diagrams define `f` for final (functions that cannot be overriden), `underline` or `s` for static functions, and `italics` or `a` for abstract functions. – Yzmir Ramirez Apr 23 '11 at 18:13
  • What if you dont want a modifier/symbol ? Just leave it blank? – Vipin Verma Sep 27 '17 at 06:36
  • @vipin8169 Yes. However, the default accessibility modifier is language-specific. For example, in Visual Basic, it's `public`, whereas it's `internal` in C#. If your diagram doesn't make it otherwise clear what the default accessibility modifier is, it's a good practice to include the access modifier symbol. – Mike Hofer Dec 14 '17 at 14:02
11

Add also to :

~ Indicates package-private (or default)

8

'#' indicates the visibility. In this case it refers to a protected operation [ edited out the term 'method' as this is not as generic ].

Jayden
  • 2,656
  • 2
  • 26
  • 31
  • PS: The reference to look this up is UML 2.0 In A Nutshell. A desktop quick reference. Dan Pilone, Niel Pitman. O'Reilly. – Jayden Jan 06 '09 at 21:51
  • Oh yes, my terminology isn't accurate. A bit sloppy. The below post by Mike Hofer uses the term 'protected member'. I think if you want to be completely accurate / agnostic, you could say a 'protected operation'. – Jayden Jan 06 '09 at 21:53
  • Wasn't trying to be snarky, and I apologize if it seemed I was. Truth is, the symbol can be applied to attributes as well as operations, so its scope is a bit broader, and I wanted to be sure that was clear. Again, my apologies for seeming crass: it was not my intent. – Mike Hofer Jan 06 '09 at 21:59
  • No worries. Didn't think you were. :) Cheers – Jayden Jan 06 '09 at 22:18
4

'#' stands for visibility "protected" (similar to public,private ) behavior of the property/methods in the class . You can find more of the same at uml_basic_notations

matang
  • 259
  • 2
  • 9
3

It implies that it is protected, for a variable it will only be seen in the class and inherited classes.

william.eyidi
  • 2,315
  • 4
  • 27
  • 39