প্রপার্টিজ Properties | Object Oriented Programming

প্রপার্টিজ Properties ক্লাসটি পলিটেকনিক [ Polytechnic ] এর অবজেক্ট ওরিয়েন্টেড প্রোগ্রামিং, বিষয় কোডঃ ৬৬৬৪১ [ Object Oriented Programming Code 66641) বিষয় এর অংশ।

 

প্রপার্টিজ Properties

 

property, in some object-oriented programming languages, is a special sort of class member, intermediate in functionality between a field (or data member) and a method. The syntax for reading and writing of properties is like for fields, but property reads and writes are (usually) translated to ‘getter’ and ‘setter’ method calls.

 

প্রপার্টিজ Properties

 

The field-like syntax is easier to read and write than many methods calls, yet the interposition of method calls “under the hood” allows for data validation, active updating (e.g., of GUI elements), or implementation of what may be called “read-only fields”.

Programming languages that support properties include ActionScript 3, C#, D, Delphi/Free Pascal, eC, F#, Kotlin, JavaScript, Objective-C 2.0, Python, Scala, Swift, Lua, and Visual Basic.

Some object-oriented languages, such as Java and C++, do not support properties, requiring the programmer to define a pair of accessor and mutator methods instead.[1][citation needed]

Oberon-2 provides an alternative mechanism using object variable visibility flags.[citation needed]

Other languages designed for the Java Virtual Machine, such as Groovy, natively support properties.

While C++ does not have first class properties, they can be emulated with operator overloading.

Also note that some C++ compilers support first class properties as language extensions.[citation needed]

  • In Microsoft Visual Studio, GCC, and llvm/clang, the __declspec(property) creates properties similar to C#.
  • Borland C++ and Borland/CodeGear/Embarcadero C++Builder use the __property keyword.

In many object oriented languages properties are implemented as a pair of accessor/mutator methods, but accessed using the same syntax as for public fields. Omitting a method from the pair yields a read-only or an uncommon write-only property.

In some languages with no built-in support for properties, a similar construct can be implemented as a single method that either returns or changes the underlying data, depending on the context of its invocation. Such techniques are used e.g. in Perl.

Some languages (Ruby, Smalltalk) achieve property-like syntax using normal methods, sometimes with a limited amount of syntactic sugar.

 

প্রপার্টিজ Properties এর বিস্তারিত ঃ

 

Leave a Comment