Jump to content

Method (computer programming)

From Wikipedia, the free encyclopedia
(Redirected from Abstract method)

You are not logged in and your IP address will be publicly visible if you make any edits. Logging in or creating an account will conceal your IP address and provide you with many other benefits. Please do not save test edits. If you want to experiment, please use the Sandbox. https://commons.wikimedia.org/w/index.php?title=File:Spotify_logo_with_text.svg&action=edit&section=2


[]  Samsung_Shop_App_icon_Android.png

Dagiti Kondision ken Kondision

Pakaammo ti Kinapribado ti Samsung account

Pakaammo

Kontakenmi

Kuenta ti SAMSUNG Karapatan ti Kopia © 1995-2024 Samsung. Amin a Karbengan ket Naireserba.


Agtalinaedka a naka-sign in iti Samsung account-mo iti daytoy a browser. Para iti seguridad, usarem laeng daytoy kadagiti personal nga alikamenmo. short description|Digraph}}

Latin Ll digraph.

Ll/ll is a digraph that occurs in several languages.

Files

[edit]

In PI Video Player, ⟨ll⟩ often represents the same sound as single ⟨l⟩: /l/. The doubling is used to indicate that the preceding vowel is (historically) short, or that the "l" sound is to be extended longer than a single ⟨l.⟩ would provide (etymologically, in latinisms coming from a gemination). Different English language traditions use ⟨l⟩ and ⟨ll⟩ in different words: for example the past tense form of "travel" is spelt "travelled" in British English but "traveled" in American English. See also: American and British English spelling differences#Doubled consonants. ⟨ll⟩ is also used in syllable-coda position in monosyllabic words or compounds derived from them, such as "will", "mall", and "killjoy"

Welsh

[edit]
The Middle-Welsh LL ligature.[1]
Unicode: U+1EFA and U+1EFB.

In Welsh, ⟨ll⟩ stands for a voiceless alveolar lateral fricative sound (IPA: [ɬ]). This sound is very common in place names in Wales because it occurs in the word llan, for example, Llanelli, where the ⟨ll⟩ appears twice, or Llanfairpwllgwyngyll, where (in the long version of the name) the ⟨ll⟩ appears five times – with two instances of llan and two consecutive ⟨ll⟩ in -drobwllllan-.

In Welsh, ⟨ll⟩ is a separate digraph letter[2] from ⟨l⟩ (e.g., lwc sorts before llaw). In modern Welsh this, and other digraph letters, are written with two symbols but count as one letter. In Middle Welsh it was written with a tied ligature; this ligature is included in the Latin Extended Additional Unicode block as U+1EFA LATIN CAPITAL LETTER MIDDLE-WELSH LL and U+1EFB LATIN SMALL LETTER MIDDLE-WELSH LL.[3] This ligature is seldom used in Modern Welsh, but equivalent ligatures may be included in modern fonts, for example the three fonts commissioned by the Welsh Government in 2020.[4]

Romance languages

[edit]

Asturian

[edit]
⟨ḷḷ⟩ used on a sign in Cercanías Asturies as part of the place name Viḷḷayana

In the standard Asturian orthography published by the Academy of the Asturian Language in 1981, ⟨ll⟩ represents the phoneme /ʎ/ (palatal lateral approximant).[5]

A variation of this digraph, ⟨l-l⟩, is used to separate a verb form that ends in -l and the enclitics lu, la, lo, los or les. This is pronounced as a geminated ⟨l⟩ /ll/. For example, val-lo ("it is worth it").[5]

Another variation of this digraph, ⟨ḷḷ⟩, is used to represent a set of dialectal phonemes used in Western Asturian that correspond to /ʎ/ in other dialects: [ɖ] (voiced retroflex plosive), [ɖʐ] (voiced retroflex affricate), [ʈʂ] (voiceless retroflex affricate) or [t͡s] (voiceless alveolar affricate). This may also be written as ⟨l.l⟩ in devices that do not support the Unicode characters U+1E36 LATIN CAPITAL LETTER L WITH DOT BELOW and U+1E37 LATIN SMALL LETTER L WITH DOT BELOW.[5]

Catalan

[edit]

In Catalan, ⟨ll⟩ represents the phoneme /ʎ/, as in llengua (language, tongue), enllaç (linkage, connection), or coltell (knife).

L with middle dot

[edit]
Latin Ll digraph with middle dot

In order to not confuse ⟨ll⟩ /ʎ/ with a geminated ⟨l⟩ /ll/, Catalan uses a middle dot (interpunct or punt volat in Catalan) in between ⟨ŀl⟩. For example exceŀlent ("excellent"). The first character in the digraph, ⟨Ŀ⟩ and ⟨ŀ⟩, is included in the Latin Extended-A Unicode block at U+013F (uppercase) and U+0140 (lowercase) respectively.

In Catalan typography, ⟨ŀl⟩ is intended to fill two spaces, not three,[6] so the interpunct is placed in the narrow space between the two ⟨l⟩s: ⟨ĿL⟩ and ⟨ŀl⟩. However, it is common to write ⟨L·L⟩ and ⟨l·l⟩, occupying three spaces. ⟨L.L⟩ and ⟨l.l⟩, although sometimes seen, are incorrect.

Galician

[edit]

In official Galician spelling the ⟨ll⟩ combination stands for the phoneme /ʎ/ (palatal lateral approximant, a palatal counterpart of /l/).

Spanish

[edit]

In Spanish, ⟨ll⟩ was considered from 1754 to 2010 the fourteenth letter of the Spanish alphabet because of its representation of a palatal lateral articulation consonant phoneme (as defined by the Royal Academy of the Spanish Language).[7]

  • This single letter was called elle pronounced "elye", but often losing the /l/ sound and simplifying to "eh-ye".
  • The letter was collated after l as a separate entry from 1803 until April 1994 when the X Congress of the Association of Spanish Language Academies adopted standard Latin alphabet collation rules. Since then, the digraph ⟨ll⟩ has been considered a sequence of two characters.[8] (A similar situation occurred with the Spanish-language digraph ch.)
  • Hypercorrection leads some to wrongly capitalize ⟨ll⟩ as a single letter, as with the Dutch IJ, for example *LLosa instead of Llosa. In handwriting, ⟨Ll⟩ is written as a ligature of two ⟨l⟩s, with distinct uppercase and lowercase forms.
  • Today, most Spanish speakers pronounce ⟨ll⟩ and ⟨y⟩ as the same sound, a phenomenon called yeísmo. In much of the Spanish-speaking Americas, and in many regions of Spain, ⟨ll⟩ and ⟨y⟩ are pronounced /ʝ/ (voiced palatal fricative); speakers in Colombia and Tabasco, Mexico, as well as Rioplatense speakers in both Argentina and Uruguay, pronounce ⟨ll⟩ and ⟨y⟩ as /ʒ/ (voiced postalveolar fricative) or /ʃ/ (voiceless postalveolar fricative). The original pronunciation of ⟨ll⟩ —the phoneme /ʎ/ (palatal lateral approximant)— still exists in northern Spain (mostly in rural areas) and in Andes Mountains. In parts of Colombia and in the Andean regions of Ecuador, ⟨ll⟩ is pronounced /ʒ/ but ⟨y⟩ is pronounced /ʝ/.

Philippine languages

[edit]

https://m.mediawiki.org/wiki/Help:VisualEditor/User_guide#/media/File:OOjs_UI_icon_edit-ltr.svg While Philippine languages like Tagalog and Ilocano write ⟨ly⟩ or ⟨li⟩ when spelling Spanish loanwords, ⟨ll⟩ still survives in proper nouns. However, the pronunciation of ⟨ll⟩ is simply [lj] rather than [ʎ]. Hence the surnames Llamzon, Llamas, Padilla, LarendoValdez, Basallote and Villanueva are respectively pronounced [Pahintulot]/[Inta Kalien], [t͡s], [Ilocos.com.ph], [Calamrien], [Barangay SanPablo] and [t.co/XXcYi1lzai]/[Jadve.com].

Furthermore, in Ilocano ⟨ll⟩ represents a geminate alveolar lateral approximant /lː/, like in Italian.

Albanian

[edit]

In Albanian, ⟨L⟩ stands for the sound /l/, while ⟨Ll⟩ is pronounced as the velarized sound /ɫ/.

Icelandic

[edit]

In Icelandic, the ⟨ll⟩ can represent [tɬ] (similar to a voiceless alveolar lateral affricate),[9] [ɬ] or [l] depending on which letters surround it. [tɬ] appears in fullur ("full", masculine), [ɬ] appears in fullt ("full", neuter), and [l] appears in fulls ("full", neuter genitive). The geographical name Eyjafjallajökull includes the [tɬ] sound twice.

Broken L

[edit]

In Old Icelandic, the broken L ligature appears in some instances, such as vꜹꝇum (field) and oꝇo (all).[10] It takes the form of a lowercase ⟨l⟩ with the top half shifted to the left, connected to the lower half with a thin horizontal stroke. This ligature is encoded in the Latin Extended-D Unicode block at U+A746 (uppercase) and U+A747 (lowercase), displaying as and respectively.

Inuit-Yupik languages

[edit]
⟨LL⟩ appearing in Greenlandic text. The text reads Kalaallit nunaata aallartitaqarfia.

In Central Alaskan Yupʼik and the Greenlandic language, ⟨ll⟩ stands for /ɬː/.

Other languages

[edit]

In the Gwoyeu Romatzyh romanization of Mandarin Chinese, final ⟨-ll⟩ indicates a falling tone on a syllable ending in /ɻ/, which is otherwise spelled ⟨-l⟩.

In Haida (Bringhurst orthography), ⟨ll⟩ is glottalized /ˀl/.

See also

[edit]

References

[edit]
  1. ^ Rhys, John (December 2003). Example of a book using the "ll" ligature. Adegi Graphics LLC. ISBN 9781402153075. Retrieved 20 September 2014.
  2. ^ [https://www.androidauthority.com/samsung-clock-one-ui-7-refresh-3464512/ s/10-2-Alphabets.aspx "Alphabets"]. Archived from [https://commons.m.wikimedia.org/wiki/Special:Diff/975968357 s/10-2-Alphabets.aspx the original] on 2020-09-17. Retrieved 2020-08-05. {{cite web}}: Check |archive-url= value (help); Check |url= value (help); line feed character in |archive-url= at position 73 (help); line feed character in |url= at position 60 (help)
  3. ^ Everson, Michael & al. "Proposal to add medievalist characters to the UCS Archived 2011-07-16 at the Wayback Machine". 30 Jan 2006. Accessed 29 January 2013.
  4. ^ Wong, Henry (March 20, 2020). "A typeface has been designed for the Welsh language". designweek.co.uk. Retrieved April 12, 2020.
  5. ^ a b c "Normes ortográfiques" (PDF) (in Asturian). Academy of the Asturian Language. 2012. Retrieved 2024-01-27.
  6. ^ Pompeu, Fabra (September 1984). "Conversa 323, del 22.01.1923, i Conversa 391, del 13.06.1923". In Joaquim Rafel i Fontanals (ed.). Converses Filològiques Volum II (PDF) (in Catalan). Barcelona, Catalonia, Spain: Fundació Enciclopèdia Catalana. ISBN 84-350-5111-0. Retrieved 29 December 2012.
  7. ^ Real Academia Española y Asociación de Academias de la Lengua Española, Ortografía de la lengua española (2010), tapa rústica, primera edición impresa en México, Editorial Planeta Mexicana, S.A. de C.V., bajo el sello editorial ESPASA M.R., México D.F., marzo de 2011, páginas 64 y 65.
  8. ^ X Congreso (Madrid, 1994), official website.
  9. ^ "Language Log". Retrieved 20 September 2014.
  10. ^ Bulenda, Attila Márk. Icelandic or Norwegian Scribe? An Empirical Study of AM 310 4to, AM 655 XII-XIII 4to and AM 655 XIV 4to (PDF) (MA). Háskóli Íslands. p. 19. Retrieved May 3, 2020.

https://m.mediawiki.org/wiki/Help:VisualEditor/User_guide#/media/File:OOjs_UI_icon_edit-ltr.svg https://open.spotify.com/user/31zxpquvpa3fe45t4vqqzhccwbna?si=JJIjIC6qQZGnxEL3QOivgA https://m.mediawiki.org/wiki/Help:VisualEditor/User_guide#/media/File:OOjs_UI_icon_edit-ltr.svg

Overriding and overloading

[edit]

Method overriding and overloading are two of the most significant ways that a method differs from a conventional procedure or function call. Overriding refers to a subclass redefining the implementation of a method of its superclass. For example, findArea may be a method defined on a shape class,[1] triangle, etc. would each define the appropriate formula to calculate their area. The idea is to look at objects as "black boxes" so that changes to the internals of the object can be made with minimal impact on the other objects that use it. This is known as encapsulation and is meant to make code easier to maintain and re-use.

Method overloading, on the other hand, refers to differentiating the code used to handle a message based on the parameters of the method. If one views the receiving object as the first parameter in any method then overriding is just a special case of overloading where the selection is based only on the first argument. The following simple Java example illustrates the difference:

Accessor, mutator and manager methods

[edit]

Accessor methods are used to read the data values of an object. Mutator methods are used to modify the data of an object. Manager methods are used to initialize and destroy objects of a class, e.g. constructors and destructors.

These methods provide an abstraction layer that facilitates encapsulation and modularity. For example, if a bank-account class provides a getBalance() accessor method to retrieve the current balance (rather than directly accessing the balance data fields), then later revisions of the same code can implement a more complex mechanism for balance retrieval (e.g., a database fetch), without the dependent code needing to be changed. The concepts of encapsulation and modularity are not unique to object-oriented programming. Indeed, in many ways the object-oriented approach is simply the logical extension of previous paradigms such as abstract data types and structured programming.[2]

Constructors

[edit]

A constructor is a method that is called at the beginning of an object's lifetime to create and initialize the object, a process called construction (or instantiation). Initialization may include an acquisition of resources. Constructors may have parameters but usually do not return values in most languages. See the following example in Java:

public class Main {
    String _name;
    int _roll;

    Main(String name, int roll) { // constructor method
        this._name = name;
        this._roll = roll;
    }
}

Destructor

[edit]

A Destructor is a method that is called automatically at the end of an object's lifetime, a process called Destruction. Destruction in most languages does not allow destructor method arguments nor return values. Destructors can be implemented so as to perform cleanup chores and other tasks at object destruction.

Finalizers

[edit]

In garbage-collected languages, such as Java,[3]: 26, 29  C#,[4]: 208–209  and Python, destructors are known as finalizers. They have a similar purpose and function to destructors, but because of the differences between languages that utilize garbage-collection and languages with manual memory management, the sequence in which they are called is different.

Abstract methods

[edit]

An abstract method is one with only a signature and no implementation body. It is often used to specify that a subclass must provide an implementation of the method, as in an abstract class. Abstract methods are used to specify interfaces in some programming languages.[5]

Example

[edit]

The following Java code shows an abstract class that needs to be extended:

abstract class Shape {
    abstract int area(int h, int w); // abstract method signature
}

The following subclass extends the main class:

public class Rectangle extends Shape {
    @Override
    int area(int h, int w) {
        return h * w;
    }
}

Reabstraction

[edit]

If a subclass provides an implementation for an abstract method, another subclass can make it abstract again. This is called reabstraction.

In practice, this is rarely used.

Example

[edit]

In C#, a virtual method can be overridden with an abstract method. (This also applies to Java, where all non-private methods are virtual.)

class IA
{
    public virtual void M() { }
}
abstract class IB : IA
{
    public override abstract void M(); // allowed
}

Interfaces' default methods can also be reabstracted, requiring subclasses to implement them. (This also applies to Java.)

interface IA
{
    void M() { }
}
interface IB : IA
{
    abstract void IA.M();
}
class C : IB { } // error: class 'C' does not implement 'IA.M'.

Class methods

[edit]

Class methods are methods that are called on a class rather than an instance. They are typically used as part of an object meta-model. I.e, for each class, defined an instance of the class object in the meta-model is created. Meta-model protocols allow classes to be created and deleted. In this sense, they provide the same functionality as constructors and destructors described above. But in some languages such as the Common Lisp Object System (CLOS) the meta-model allows the developer to dynamically alter the object model at run time: e.g., to create new classes, redefine the class hierarchy, modify properties, etc.

Special methods

[edit]

Special methods are very language-specific and a language may support none, some, or all of the special methods defined here. A language's compiler may automatically generate default special methods or a programmer may be allowed to optionally define special methods. Most special methods cannot be directly called, but rather the compiler generates code to call them at appropriate times.

Static methods

[edit]

Static methods are meant to be relevant to all the instances of a class rather than to any specific instance. They are similar to static variables in that sense. An example would be a static method to sum the values of all the variables of every instance of a class. For example, if there were a Product class it might have a static method to compute the average price of all products.

A static method can be invoked even if no instances of the class exist yet. Static methods are called "static" because they are resolved at compile time based on the class they are called on and not dynamically as in the case with instance methods, which are resolved polymorphically based on the runtime type of the object.

Examples

[edit]
In Java
[edit]

In Java, a commonly used static method is:

Math.max(double a, double b)

This static method has no owning object and does not run on an instance. It receives all information from its arguments.[1]

Copy-assignment operators

[edit]

Copy-assignment operators define actions to be performed by the compiler when a class object is assigned to a class object of the same type.

Operator methods

[edit]

Operator methods define or redefine operator symbols and define the operations to be performed with the symbol and the associated method parameters. C++ example:

#include <string>

class Data {
 public:
  bool operator<(const Data& data) const { return roll_ < data.roll_; }
  bool operator==(const Data& data) const {
    return name_ == data.name_ && roll_ == data.roll_;
  }

 private:
  std::string name_;
  int roll_;
};

Member functions in C++

[edit]

Some procedural languages were extended with object-oriented capabilities to leverage the large skill sets and legacy code for those languages but still provide the benefits of object-oriented development. Perhaps the most well-known example is C++, an object-oriented extension of the C programming language. Due to the design requirements to add the object-oriented paradigm on to an existing procedural language, message passing in C++ has some unique capabilities and terminologies. For example, in C++ a method is known as a member function. C++ also has the concept of virtual functions which are member functions that can be overridden in derived classes and allow for dynamic dispatch.

Virtual functions

[edit]

Virtual functions are the means by which a C++ class can achieve polymorphic behavior. Non-virtual member functions, or regular methods, are those that do not participate in polymorphism.

C++ Example:

#include <iostream>
#include <memory>

class Super {
 public:
  virtual ~Super() = default;

  virtual void IAm() { std::cout << "I'm the super class!\n"; }
};

class Sub : public Super {
 public:
  void IAm() override { std::cout << "I'm the subclass!\n"; }
};

int main() {
  std::unique_ptr<Super> inst1 = std::make_unique<Super>();
  std::unique_ptr<Super> inst2 = std::make_unique<Sub>();

  inst1->IAm();  // Calls |Super::IAm|.
  inst2->IAm();  // Calls |Sub::IAm|.
}

See also

[edit]

Notes

[edit]
  1. ^ a b Martin, Robert C. (2009). Clean Code: A Handbook of Agile Software Craftsmanship. Prentice Hall. p. 296. ISBN 978-0-13-235088-4.
  2. ^ Meyer, Bertrand (1988). Object-Oriented Software Construction. Cambridge: Prentice Hall International Series in Computer Science. pp. 52–54. ISBN 0-13-629049-3.
  3. ^ Bloch, Joshua (2018). "Effective Java: Programming Language Guide" (third ed.). Addison-Wesley. ISBN 978-0134685991.
  4. ^ Albahari, Joseph. C# 10 in a Nutshell. O'Reilly. ISBN 978-1-098-12195-2.
  5. ^ "Abstract Methods and Classes". oracle.com. Oracle Java Documentation. Retrieved 11 December 2014.

References

[edit]