Specification of methods

Specification of methods - Specifications of methods You...

Info icon This preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Specifications of methods You know what the first function mini does, because its specification, in the comment preceding it, tells you. You don’t need the function body —which we show you now. You have no idea what the second function does, because its specification has not been given. To understand what it does, you would have to look at its body: Integer.signnum . A specification of a method defines what a call on a method does. The specification should be precise, complete, and as clear as possible. So that you don’t have to look at the method body. In fact, every method should have a specification, and you should never have to look at the method body when writing a call on a method. The method body indicates how a task is carried out. When writing a call on a method, we don’t want to know that, we want to know what the task is. And the spec should tell us. Writing procedure specifications We write method specs as Javadoc comments immediately preceding the method. Javadoc comments begin with /** and end with */ . The next lecture will explain why we use Javadoc comments. Let’s begin discussing specs for procedures. There are two points to make here. /** Set the title to t */ public void setTitle(String title){...} 1. The spec mentions every parameter by name, and in a way that explains what that parameter is for. If a
Image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

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