Object

एक object, वो भी object-oriented programming (OOP) में, एक abstract data type होता है जिसे की create किया जाता है एक developer के द्वारा. इसमें शामिल हो सकते हैं multiple properties और methods, यहाँ तक की दुसरे objects भी. ज्यादातर programming languages में, objects को define किया जाता है classes के तोर पर.

Objects प्रदान करता है एक structured approach programming के लिए. एक dataset को define करने के लिए एक custom object के रूप में, एक developer आसानी से create करता है multiple similar objects और साथ में modify करता है existing objects को एक program में. इसके साथ, objects प्रदान करता है “encapsulation,” मतलब की data किसी एक object में protect किया जाता है modify या destroy होने से दुसरे functions या methods के द्वारा, जब तक की उन्हें explicitly allow न कर दिया गया हो.

एक आसान उदाहरण है एक object का जिसमें की एक user account को create किया जाता है एक website के लिए. ऐसे में object को define किया जा सकता है class user-account के रूप में और इसमें शामिल होते हैं attributes जैसे की :

  • first name
  • last name
  • email address
  • password
  • age
  • location
  • photo

इन सभी properties को recreate करने के बदले प्रत्येक new user account के लिए, एक web script को simply instantiate किया जा सकता है एक userAccount object के द्वारा. Data जो की assign होता है object को उन्हें store किया जा सकता है एक database में अगर user account को save किया जाये तब.

एक ज्यादा advanced उदाहरण है एक object का, जो की है एक character एक video game में. Character की कुछ standard attributes होती हैं, जैसे की एक name, hitpoints, और movement speed. वहीँ इसमें दुसरे objects भी शामिल हो सकते हैं, जैसे की weapons, armor, items, इत्यादि. ऐसे case में, character असल में “parent object” होता है और इसमें जो objects मेह्जुद होते हैं वो सभी “child objects” होते हैं.

दोनों ही parent और child objects की अपनी ही properties और methods होती हैं. उदाहरण के लिए, character की काफी सारे methods हो सकती है जैसे की “move” और “attack.” वहीँ “attack” command reference हो सकता है “weapon” object के लिए, जिसकी अपनी ही methods होती है, जैसे की “swing” या “thrust.”

[su_note note_color=”#fffbde” text_color=”#000000″]वैसे तो objects सामान्य ढंग से associated होते हैं object-oriented programming के साथ, वहीँ अगर हम general computer science terminology के आधार से देखें तब, एक object refer करता है एक single programming element को, जैसे की एक variable, constant, function, या method.[/su_note]

« Back to Wiki Index