Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is a Degenerate Class?

Since no one has asked yet, and I've yet to find a suitable answer; simply put: What is a Degenerate Class?

Examples of various languages would be helpful...Except UML. :P

like image 967
Casey Avatar asked Jul 25 '11 01:07

Casey


People also ask

What is a degenerate example?

Degenerate is defined as a person who is immoral, corrupt or sexually perverted. An example of a degenerate is a thief.

What does degenerate mean in mathematics?

In mathematics, something is called degenerate if it is a special case of an object which has, in some sense, “collapsed” into something simpler. For example: A degenerate triangle has all three of its vertices lying on the same straight line, so the triangle is squashed completely flat.

What is a degenerate set?

In mathematics, a degenerate case is a limiting case of a class of objects which appears to be qualitatively different from (and usually simpler than) the rest of the class, and the term degeneracy is the condition of being a degenerate case.

What does degenerate mean in biology?

As a descriptive term, degenerate describes the redundancy of the genetic code. A degenerate code refers to any of the codon combinations that lead to the same amino acid. In other words, an amino acid may be specified by more than one type of codon. A codon is a set of three adjacent nucleotides in mRNA.


2 Answers

I'm also looking for a definitive answer, here's how I've understood it so far from google:

In mathematics, degeneracy signifies the limiting case in which a class of object changes its nature so as to belong to another, usually simpler, class.

  • the point is a degenerate case of the circle as the radius approaches 0
  • the circle is a degenerate form of an ellipse as the eccentricity approaches 0

In programming, following this concept of 'collapsing' into something simpler, degeneracy seems to be used in a number of ways:

1. A class with no methods or just a main method:

Big Java:

Finally, you have seen classes with only a main method. Their sole purpose is to start a program. From a design perspective, these are somewhat degenerate examples of classes.

Effective Java 2nd edition:

Item 14: In public classes, use accessor methods, not public fields

Occasionally, you may be tempted to write degenerate classes that serve no purpose other than to group instance fields:

// Degenerate classes like this should not be public!
class Point {
  public double x;
  public double y;
}

2. A class with less specificity that causes it to behave like another simpler class:

Learning Java:

For example, the class of List and List share the plain old Java class List. List is called the raw type of the generic class. Every generic has a raw type. It is the degenerate, “plain” Java form from which all of the generic type information has been removed and the type variables replaced by a general Java type like Object.

Effective Java 2nd edition:

// The worst possible legal hash function - never use!
@Override public int hashCode() { return 42; }

It’s legal because it ensures that equal objects have the same hash code. It’s atrocious because it ensures that every object has the same hash code. Therefore, every object hashes to the same bucket, and hash tables degenerate to linked lists.

3. The simplest, emptiest instance of a class possible:

Big Java:

However, sometimes you get into philosophical questions dealing with degenerate inputs: empty strings, shapes with no area, and so on.

like image 158
mallardz Avatar answered Nov 02 '22 08:11

mallardz


From here I'm guessing that it's a class with no behavior (i.e. no methods).

like image 42
user541686 Avatar answered Nov 02 '22 09:11

user541686