Jump to content

Talk:Inner class

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia

Pyrofysh 11:17, 18 December 2005 (UTC)[reply]


Untitled

[edit]

This article needs a discussion of how inner classes are used in other languages - esp C++. And what the differences are, with specific examples.

Scala

[edit]

Scala supports a more semantically meaningful form of nested classes with type-dependent paths. It probably has the most sophisticated nested class of any language today with a significant number of users. —Preceding unsigned comment added by 64.134.134.22 (talk) 22:14, 28 March 2011 (UTC)[reply]

Section 3 (Why can't inner classes have static members)

[edit]

This section is written in broken English and looks like it may have been copied and pasted here from a blog site or mailing list. Either the original source should be identified and the copy cleaned up, or the section should be eliminated outright. 69.180.197.51 (talk) 14:23, 3 November 2011 (UTC)[reply]

What is this article about: nested classes or inner classes?

[edit]

The first paragraph currently says "In object-oriented programming (OOP), an inner class or nested class is a class declared entirely within the body of another class or interface. It is distinguished from a subclass." So this suggests that "inner class" and "nested class" are synonyms (which I don't think they are). Later the article says there are (in Java) 4 kinds of nested classes, of which 3 are "inner classes". I.e., it is implied that an inner class (in Java) is a nonstatic nested class (which I think is right). If the article's title were changed to "nested classes" and the first sentence dropped the words "inner class or", then it would (a) be self consistent and (b) agree with the use of the words "nested" and "inner" in the Java literature. Also I think it is a no-brainer that the section entitled "Types of inner classes" should be called "Types of nested classes". I'm just going to go ahead and change that. Theodore.norvell (talk) 19:47, 12 March 2013 (UTC)[reply]

Remove Ruby from the article

[edit]

I suggest removing any mention of Ruby from the article. Defining a class inside of another class definition is purely syntactical and does not create any relationship between the two classes. It simply makes the constant which refers to the "nested" class namespaced to the "outer" class, but that relationship is between the constant and the outer class, not the inner class and the outer class.

In general, the article seems to focus too much on the syntactic property of a class being syntactically defined inside of another class definition, instead of the semantic property of there being a containment relationship not only between the outer and nested class but also between instances of the outer class and the nested class.

Note: it would be possible to emulate nested classes in Ruby, by using methods that return classes:

class Outer
  def Inner
    @__inner__ ||= Class.new do
      # contents of inner class
    end
  end
end

But that′s certainly not a recognized idiom in the Ruby community.

jwmittag (talk) 08:57, 30 July 2014 (UTC)[reply]

Use of inner classes vs. standalone classes

[edit]

The "GUI code" section is rather subjective, especially the last paragraph using weasel words such as "messy", "better", and "considered." It's true that inner classes are common in Java, especially as event handlers, but that simply means this is a commonly used convention. There are many cases where using standalone classes is preferable.