Tuesday, December 18, 2012

Methods Vs Functions

  • Usually In Object--Oriented--Programming We use The Name "Method" and in Imperative languages we use the name "Function"
  • Both Do The Same Thing. (But  Object--Oriented--Programming  has their own Way to Handle Methods)
  • Methods Live inside A Class And Functions Can Live its Own

Example for methods : (methods usually lives inside a class)
Class ClassType {
         Public methodOne( ){
               //Method Body
         }
         Public methodTwo( ){
               //Method Body
         }
}


Example for Functions:
Public FunctionNameOne( ) {
     //Function Body
}
Public FunctionNameTwo( ) {
     //Function Body
}

Identifying A Method or Function : Method or Function Name Usually Ended With Brackets
ex: functionOne( ), functionTwo( )

Example for  Object--Oriented--Programming languages
C#
JAVA

Example for Imperative languages
C

More resources:
http://en.wikipedia.org/wiki/Object-oriented_programming
http://en.wikipedia.org/wiki/List_of_programming_languages_by_type




No comments:

Post a Comment