Reply to comment

operation vs. method

I often mix up the term "operation" with the term "method".
Because I think that many software engineers have the same problem, I would like to explain the differences today in this post:

Operation
An operation is the abstract definition of a functionality. So to say operations are only the functions head, not the body / implementation.
They describe (by comment and name) WHAT the function does, but not HOW the function achieves this.

Example:

  1. interface Example {
  2. /**
  3.   * Executes an example function.
  4.   **/
  5. public function execute();
  6. }

So typically interfaces may only contain operations but not methods, because they do not implement the HOW, just tell WHAT the operation should do.
The concrete implementation is being done by the inheriting classes.

Method
A method is a concrete implementation of an operation and contains a method body though. The method represents the HOW.

Example:

  1. class ExampleClass implements Example {
  2.  
  3. /**
  4.   * @see Example::execute()
  5.   **/
  6. public function execute(){
  7. echo("Execution successful! Have a nice day :)");
  8. }
  9. }

I hope to help you with my little explanation / definition.

Trackback URL for this post:

http://julian.pustkuchen.com/en/trackback/227

Reply

The content of this field is kept private and will not be shown publicly. If you have a Gravatar account, used to display your avatar.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd><blockquote>
  • Lines and paragraphs break automatically.
  • Pairs of<blockquote> tags will be styled as a block that indicates a quotation.
  • You can enable syntax highlighting of source code with the following tags: <c>, <cpp>, <css>, <drupal5>, <drupal6>, <java>, <javascript>, <mysql>, <php>, <python>, <ruby>, <smarty>, <xml>. The supported tag styles are: <foo>, [foo]. PHP source code can also be enclosed in <?php ... ?> or <% ... %>.
  • Textual smileys will be replaced with graphical ones.

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.