We can summarize these distinctions schematically like this.docx

  • No School
  • AA 1
  • prapok4122
  • 3

This preview shows page 1 - 3 out of 3 pages.

We can summarize these distinctions schematically like this (explanation to follow): creator : t* → T producer : T+, t* → T observer : T+, t* → t mutator : T+, t* → void | t | T These show informally the shape of the signatures of operations in the various classes. Each T is the abstract type itself; each t is some other type. The + marker indicates that the type may occur one or more times in that part of the signature, and the * marker indicates that it occurs zero or more times. | indicates or. For example, a producer may take two values of the abstract type T , like String.concat() does: concat : String × String → String Some observers take zero arguments of other types t , such as: size : List → int and others take several: regionMatches : String × boolean × int × String × int × int → boolean
Image of page 1
Image of page 2
Image of page 3

You've reached the end of your free preview.

Want to read all 3 pages?

Unformatted text preview: We can summarize these distinctions schematically like this (explanation to follow): • A creator operation is often implemented as a constructor ,like newArrayList() But a creator can simply be a static method instead, like Arrays.List(). A creator implemented as a static method is often called a factory method . The various String.valueOf methods in Java are other examples of creators implemented as factory methods. • Mutators are often signaled by a void return type. A method that returns void must be called for some kind of side-effect, since otherwise it doesn’t return anything. But not all mutators return void. For example, Set.add() returns a boolean that indicates whether the set was actually changed....
View Full Document

  • Fall '19

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask You can ask (will expire )
Answers in as fast as 15 minutes
A+ icon
Ask Expert Tutors