What does "ad-hoc" mean in the context of computing?

Asked

Viewed 100 times

5

Eventually I see some terms preceded by "ad-hoc", but I still can’t quite understand what it means.

When used "ad-hoc" in a term related to computation, is there a common meaning? What does it mean "ad-hoc"?

For example, ad-hoc polymorphism would be a name in which "ad-hoc" does not have special meaning? Or is there a common meaning in "ad-hoc" which can also be used in other situations?

  • I think a good start is to understand the locution. https://dicionario.priberam.org/ad%20hoc - ad-hoc is "specific purpose", "specific purpose".

2 answers

4


The term means that something exists for a specific purpose, which has a characteristic only for the object of which it deals there.

I believe, but I’m not sure ad hoc polymorphism indicates that it is the most specific form of polymorphism, which is opposed to the more generic form, which in fact is called Generics. I explain about polymorphism, including the ad hoc in Polymorphism in procedural language (also and yet, follow the links), but I guess the question isn’t about this.

Terms can always be used in their own context and new ones can even arise.

I found 3 specific definitions on Wikipedia, there may be more:

In software engineering, the ad hoc expression is used for designate complete cycles of software construction that were not properly designed because of the need to take account of a user-specific demand, linked to time, quality or cost. A expression is also cited at level 1 of the CMMI, when data collection for indicators is made ad hoc, ie to solve determined problem or perform a specific task.

Informal models used by software developers be ad hoc, how to scribble an idea for greater clarity and simplification of reality. However, these models do not offer a basic language that can be shared with other people easily.

In computer network technology, communication is ad hoc when two or more devices communicate directly over the network wireless, not requiring an intermediate node (server, point access, station, etc).

One of them is corroborated by English version which is a little more reliable.

The idea of doing something that works, that solves, or breaks a bug, a Gambi, or a code throw away is defended in the Soen. But there are those who call written code on the fly of ad hoc.

There are those who said including that the term is used to oppose the shelf software (COTS), which here called even specific.

3

Taking advantage of the link that @Bacco commented: https://dicionario.priberam.org/ad%20hoc

(latin speech which means "for this") which is intended to an end specific.

I’ve heard that term often related to cheese database, which gives to understand well its application also in computer:

Any system allows consulting a product by name, so we have a "generic" query that is applied to all product queries by name, which even because it is so, can be encapsulated in a stored Procedure:

SELECT * FROM PRODUTO WHERE NOME='BATATAS'

Where we only inform the value of "POTATOES". Now if you have a situation that needs to consult a product by name, but also a product that is active, that has been registered on a specific date, etc., that would be a query Ad hoc, ie, will be used for a specific purpose, different from the "generic" query that has a "general" purpose".

About Ad hoc polymorphism, the concept would be the same, a "specific polymorphism" or "for a certain purpose". And how would that be?

Well, polymorphism (or many forms) is one of the object orientation concepts where a method can behave differently, having the same contract, in different classes.

We can apply polymorphism with interfaces or only classes:

public class Calculo
{
    public int Calcular(int num1, int num2)
    {
        return num1 + num2;
    }
}


public class CalculoAlternativo : Calculo
{
    public int Calcular(int num1, int num2)
    {
        return num1 - num2;
    }
}

Here we see the polymorphism of the method Calcular, it has the same signature (name and parameters), but behaves differently in the class Calculo and CalculoAlternativo.

The polymorphism ad hoc is one that is created for a specific purpose, that is, the parameters are different and it must have a different behavior to meet a specific purpose. This can be implemented through overload, or overloading:

public class Calculo
{
    public int Calcular(int num1, int num2)
    {
        return num1 + num2;
    }

    public int Calcular(int num1, int num2, bool soPositivo)
    {
        var resultado = num1 - num2;
        
        if (soPositivo && resultado < 0)
        {
            resultado = 0;
        }

        return resultado;
    }
}

In this case, the method has the same name, but behaves differently, and takes different parameters.

References:

https://www.geeksforgeeks.org/ad-hoc-inclusion-parametric-coercion-polymorphisms/

http://www.btechsmartclass.com/java/java-polymorphism.html

https://catonmat.net/cpp-polymorphism

Browser other questions tagged

You are not signed in. Login or sign up in order to post.