What is the difference between function and method ?
Hello everyone! Today we are going to talk about what is the difference between function and method in software. I'm going to explain this using c#, but it doesn't matter which software language we use because probably in all software languages function and method mean the same thing. Let's start with explain what is function.
What Is Function ?
Function is the fundamental concept in programming and usually it is often associated with transactional or functional programming paradigms. A function is a self-contained block of code that performs a specific task or operation. Function can take 1 or more then 1 parameters ,can process them and can return a conclusion or perform an action.
int Topla(int a, int b)
{
return a + b;
}
example of function .
What Is Method ?
A method is a concept closely associated with object-oriented programming (OOP) languages. Method is a function associated with anobject or a class. It operates on this object or is called on this object. Methods are defined in classes and is used for define the structure of the objects of the class
class Dikdortgen
{
int uzunluk;
int genislik;
public Dikdortgen(int uzunluk, int genislik)
{
this.uzunluk = uzunluk;
this.genislik = genislik;
}
public int AlanHesapla()
{
return uzunluk * genislik;
}
}
example of method.
so Briefly the main difference is:
- Bir fonksiyon, belirli bir görevi yerine getiren bağımsız bir kod parçasıdır ve genellikle işlemsel veya fonksiyonel programlamayla ilişkilendirilir.
- Bir metot, bir nesne veya sınıfla ilişkilendirilen ve bu nesnenin yapısı ve davranışı üzerinde çalışan bir fonksiyondur ve genellikle nesne tabanlı programlama (OOP) bağlamında kullanılır.
a function is a independent piece of code that fulfilling the certain task and usually is associated operational and functional programing.
A method is a function associated with an object or class that operates on the structure and behaviour of that object and is often used in the context of object-oriented programming (OOP).
Popüler Gönderiler
-
İngilizce Ettirgen Cümleler: Causative Verbs
15 mins read
-
What is DevOps ?
15 mins read
-
What is the difference between function and method ?
15 mins read
-
Present Perfect Tense Hakkında Her Şey
15 mins read
Yorumlar
Görüşlerinizi lütfen belirtiniz!
cumali
Thanks for the essay
Yorum yazabilmek için lütfen giriş yapınız. Giriş Yap!