Jump to content

Talk:Class (programming)/Archive 1

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

HTML/XML/JavaScript

Discussion of how HTML and XML classes (such as for CSS markup) are similar or different might be interesting. They also have the notion of attributes and instantiation; an analog for "methods" might be JavaScript functions which operate on particular markup blocks. -- Beland (talk) 18:53, 12 October 2008 (UTC)

Classes, as traditionally seen in computer science, are a specialization of the common definition of class. The class attribute in HTML is based off that common definition, not the specialized one here. --Maian (talk) 06:39, 13 October 2008 (UTC)

Introduction - cohesive and layer?

I was responsible for the reorganization of this article several months ago (I was Special:Contributions/72.177.38.5 and Special:Contributions/72.177.62.3). The following two statements in the intro were originally there:

a class is a cohesive package that consists of a particular kind of metadata

a class is the most specific type of an object in relation to a specific layer

I'm not familiar with those concepts, and they were only mentioned in the intro without being detailed in the rest of the article, so I considered removing them. But I left them as they were, moving the statements around in the intro to try to make them fit as well as they could.

So now, I'm wondering if anyone who knows about these two concepts can elaborate on them, or at the very least, inform us if they are relevant to the article.

--Maian (talk) 20:04, 9 November 2008 (UTC)

Class methods

Maian said "class methods aren't an integral part of the class concept, so removing that from the 1st paragraph." But in my opinion, object creation is not an integral part of the class concept either. Many process classes, such as the Math class, are used without creating any objects. In terms of an object, a class is indeed a blueprint for that object. But on the other hand, this is not the Wikipedia article about objects, it's about classes. The concept of a class was originally used in Simula to refer to not only the object, but also it's actions. See [1]. Therefore, it is correct to say that a class is a blueprint for an object. But a class is so much more: all actions of the machine are defined by classes; where no object is present, actions can still be performed, e.g. the Math class. I think that what is missing is a distinction between "process class" and "object class", where this article seems to introduce only the "object class" and sidelines the "process class" as a non-integral part of the class concept.

This problem is: an object is created by a class. A class is thus a blueprint for an object. But not all classes are blueprints for objects. Therefore, I think that this page on class can use some tweaking. Twocs (talk) 16:35, 20 June 2009 (UTC)

Not all languages have the concept of "class methods" or "static methods". For example, Scala, another JVM language (since you're apparently coming from a Java standpoint), doesn't have static methods in the same vein as Java. Why? Because if you consider that the class itself is an object, than its "class methods" can be thought of as either instance methods of the metaclass that created that class, e.g. methods of a MathClass class that creates the Math class object, or as object-specific methods (not sure what the correct terminology is here) on the Math object itself. --Maian (talk) 18:51, 7 July 2009 (UTC)

Examples section is bloated and inconsistent

The examples section for this article is large and very inconsistent. There are typically two formats for example sections for programming articles: 1) an example or two in pseudo-code; and 2) examples for a variety of languages. This article uses the latter format. The main reason for there to be multiple examples across each language is for readers to compare and contrast between the syntax each language provides. However, if the examples are so inconsistent, it's hard for the reader to draw any conclusions.

So, I suggest standardizing on set of features that most OOP languages can support (or emulate): methods, static vs. instance, single inheritance, public vs. private. Any deviations from that set should be explicitly explained in comments.

--Maian (talk) 06:20, 12 December 2008 (UTC)

Reasons for using classes - contains weseal words and unverifiable statements in support of OOP

This section contains weasel words, phrases, unsupported statements and a clearly cherry-picked example

  • 'solid work' - weasel
  • 'programming is generally much easier...' - POV, unverifiable
  • 'Classes can accelerate development...' - unsupported, unverifiable
  • 'it is typically the case that using or extending the well-tested class will reduce the number of bugs - as compared to the use of freshly-developed or ad hoc code - in the final output'
this statement would be likely be true for most extensions to ANY well tested code in ANY paradigm so what is the point in stating it other than to convince us that OOP is superior to earlier paradigm?

The particular example given (a GUI drawing subroutine for a window), could be consdidered to be 'cherry picked' merely to promote the subject of OPP without imparting verifiable information.

multiple calls

  • '...can't be acheived in imperative program paradigms without 'repeatedly' calling a user interface?'
Where is the evidence for this statement? Asyncronous processes existed long before OOP that could operate semi-autonomously with changed parameters via a list or control block setting using a single call. If multiple calls to an interface were previously required to draw a window, the interface is obviously badly designed in the first place and nothing whatsoever to do with the emergence of OOP and classes as suggested.

intuitiveness

  • '...it is more intuitive to represent the window as an object and tell it to draw itself as necessary'
There is nothing at all intuitive about windows 'drawing themselves' - in fact it could be considered a miracle if this was really what occured!ken (talk) 12:37, 15 October 2009 (UTC)
Archive 1

References

This article cites zero (yes, zero) references. It's been around for a few years... it's about time someone got in there and added something, anything in. Jess (talk) 03:18, 1 August 2010 (UTC) it is a logical description of an object — Preceding unsigned comment added by 210.212.56.34 (talk) 06:52, 14 January 2012 (UTC)

Mumbo jumbo nonsense

"the class name is used as the name for the class" — Preceding unsigned comment added by 69.119.158.11 (talk) 05:50, 17 September 2020 (UTC)

Agree. There is nonsense in this article and that is one example. That the name is the used as the name adds no value ;) ... Further, the text is in a thing called 'efn' which is new to me and seems to be extra text that shows at the bottom and when hover. I think that sort of organization of info is bad in general. If it's important, put the info in the body of the text; not in a footnote. ... I will try to improve it. I suggest you do that same. It's easy to criticize but more useful to improve the content. Stevebroshar (talk) 14:55, 21 June 2024 (UTC)

The whole article is nonsense. Azbookmobile (talk) 03:50, 22 September 2022 (UTC)

Examples

The examples on this page were severely lacking in that they previously did not demonstrate why one would wish to use a class. (The PHP example is still poor, but I don't know enough about objects in PHP to fix it.)

In general, when you have multiple language examples then they should be functionally equivalent and demonstrate the property about which you are speaking. In this case, classes as a medium for data encapsulation and abstraction.

The comment about the Java example showing object instantiation is irrelevant, because both the Ruby and Lisp examples also instantiate objects. 62.253.228.193 (talk) 08:09, 31 August 2010 (UTC)

We don't want all the examples to be functionally equivalent. On the contrary, we want them to all be different. This article isn't about comparing languages, it's about demonstrating what a class is. We want a few examples highlighting classes, and some of the features generally associated with OOP. It's good for us to use multiple languages for those examples since 1) they're simple enough to be considered pseudocode anyway, and 2) we want to keep this article general, and not cater to one language only.
Each of the examples shows different things, and in different ways. In the long-run, it would be good to have an example within each section which highlights what's being talked about in that section... but for now a list of examples at the end is how the article was written, so that'll have to do. Jesstalk|edits 08:42, 31 August 2010 (UTC)
That's not useful in any way whatsoever. None of the examples to date have even shown data encapsulation, inheritance, abstract base class, composition. By your own reasoning the examples are lacklustre - there's hardly any point having them. The moronic "hello world" Java class has exactly zero value.
You have suggested how to improve the examples by moving them to the relevant sections. Until then, I don't believe these changes reduce the quality of the article. Learn to let go.
"That'll have to do." -- Yep, that pretty much sums up the Wikipedia experience. 62.253.228.193 (talk) 09:06, 31 August 2010 (UTC)
Please read WP:Civil and WP:AGF. You're quickly approaching a civility barrier which is making collaboration difficult. As I stated, the examples as they are now are less useful than they could be, and should be expanded upon and moved into specialized sections. However, that hasn't been done yet... so for right now they do very much serve a purpose at the end of the article. Changing all the examples so that they do the same thing eliminates that purpose. If we're just showing one thing, we should just have one example. Jesstalk|edits 09:30, 31 August 2010 (UTC)

Example of object-class relationship

The example given at the end of the introduction of the relationship of classes to objects is misleading, it's really talking about a type relationship between two classes. A better example might be that Jimmy Wales is an object of the class person. — Preceding unsigned comment added by Tomcrocker (talkcontribs) 22:31, 16 October 2011 (UTC)

I agree. I changed the example to the following: For example, a "Banana" class would represent the properties and functionality of bananas in general. A single, particular banana would be an instance of the "Banana" class, an object of the type "Banana". Ben.d.zimmer (talk) 16:31, 17 April 2012 (UTC)

Lack of language syntax examples

I came to this topic to refresh myself with the syntax of a C++ class or a Java class. I see no syntax examples. C++ has Structs but this has no syntax example. C++ has Class Interfaces but this has no syntax example. This article mentions Member accessibility but gives no C++ or C or Java syntax examples. There are several languages mentioned in this article such as C, C++, Objective-C, Python, Ruby, Java, etc but no syntax examples of any of those languages. I am not looking for a stroustrup treatise. I am looking for a syntax example to refresh my memory. I know that there are hundreds of programming languages in existence and that you cannot give examples of them all. Certainly, you can give examples for the languages that you mention in the article...without picking favorites. If you are undecided about how many then give an example for the top 5. I am sure that CNET or Dr Dobbs can assist this topic editor in determining what the top 5 programming languages are. Not all of them carry object-oriented syntax. The syntax for C AND C++ and Java are very similar.Patnclaire (talk) 14:52, 11 April 2012 (UTC)

I think the main reason of a lack of syntax examples is that this article is meant to explain classes in general. I don't think an encyclopaedia is a good repository for examples in (all of) the world's programming languages. The article is already long as it is. ;-) ctxppc (talk) 14:10, 28 January 2013 (UTC)

Article overhaul

In the next couple of weeks, I'm planning on editing and rewriting this article for clarity, as well as finding some better sources to cite. I will also be working on some related articles, including Method, Interface, and Inheritance. If anyone has any suggestions, especially for high quality yet accessible sources that this article could cite, I would be happy to hear them. Thanks. Ben.d.zimmer (talk) 17:04, 12 April 2012 (UTC)

  • I think this page is coming along well. In particular, I would suggest adding a clearer description of "interface" as opposed to "structure". You should also make Example a sub-header under "class interface" instead of its own header. Libertyernie2 (talk) 16:33, 26 April 2012 (UTC)

I finished my first pass at overhauling this article. I editing and rewrote the article for clarity and cited sources throughout. Weasel words and uncited claims are now confined to a few particular sections, specifically the "Definitions of subclass", "Partial", "Benefits", and "Run-time representation" sections. I believe that with the exception of the "Run-time" section, these sections could be removed, but I don't want to do it myself. Thanks! Ben.d.zimmer (talk) 15:37, 10 May 2012 (UTC)

Partial classes

Partial classes are over-represented in this article (long section with examples in VB.NET and Objective-C), particularly given that this is a physical (file management) issue rather than a logical (conceptual) issue. Robbiemorrison (talk) 09:57, 28 August 2012 (UTC)

Incomprehensible Opening Sentence

This sentence at the beginning is poorly written; "The class is instantiated into instances of itself". While many programmers might understand this, somebody new to "classes" would find it incomprehensible. The word "instantiated" needs definition somewhere. How can this be made more clear?? If there is no response after a while, I will change it. Nodekeeper (talk) 00:34, 30 July 2013 (UTC)

Purpose and use of a class

From intro:

  • a class is a construct that is used to define a distinct type. The class is instantiated into instances of itself – referred to as class instances, class objects, instance objects or simply objects.

That's not the purpose of a class. Computer programmers will write a class because they want to create objects. Let's separate the formal, computer science definitions from the way OOP is actually used in the field. If anyone wants the ivory tower stuff, it can be found, but please do not clutter up the intro with hyper-geeky stuff that turns off beginners. --Uncle Ed (talk) 11:56, 22 October 2013 (UTC)

Class and Inheritance are not Orthogonal

Currently there is a section titled "Orthogonality of the class concept and inheritance" I agree with everything in that section but I think the title is wrong. "Orthogonal" (literally at right angles to each other) in my experience means two things that may have an intersection point but are different things. That's not the case with Object-based and object-oriented. Object-based is a superset of object-oriented (all object-oriented languages are object-based but some are only object-based and not object-oriented, e.g. Visualbasic). MadScientistX11 (talk) 03:56, 16 December 2013 (UTC)

@MadScientistX11 Agree that orthogonal is inaccurate there. It's also a bit obtuse in general. I agree that object-oriented (with inheritance) is a subclass :) of object-based. ... It's been 11 years since your comment yet it's still that way. You changed you mind about changing it? Stevebroshar (talk) 15:24, 21 June 2024 (UTC)
@Stevebroshar Sorry for the late reply. Don't check nearly as often as I used to. Not so much changed my mind as just don't have much time anymore. Also, I kind of got burned out on editing tech articles. Maybe it was just my bad luck but several times I would make what seemed to me a very obvious change and someone who had just read the intro to "OOP for Dummies" would change it back and I got kind of burned out having debates with people that IMO just didn't know what they were talking about. I have no time to change it right now. Have to prepare a presentation on an article that was accepted in a journal and I got invited to present at a workshop!!! Kind of psyched about that. Please if you feel like it have at it but I'll try and give editing another shot when I have a bit more time. Thanks for the nudge. MadScientistX11 (talk) 16:18, 7 July 2024 (UTC)
@MadScientistX11 thanks for the reply. sounds like you are busy doing important work. good for you. i too struggle with the human interaction aspect of wp sometimes. it's a pleasure to talk with someone like you who is courteous and collaborative I'll take a swing at updating the text. ... i discovered that some folks use "orthogonal" in unusual ways. maybe it has other meanings or maybe it's often misused. i think it best to avoid the term since it leads to confusion. Stevebroshar (talk) 13:31, 26 July 2024 (UTC)

Planning to rewrite Definition of Subclass section

That section currently starts out like this: "Conceptually, a superclass should be considered as a common part of its subclasses. " I usually don't make that big a deal about language but that is really expressed poorly and is either hard to understand at best or fundamentally wrong about what a class is at worst. A superclass is not a part of its subclass. Words like "part" and "kind" have specific meanings in OO and a subclass is a kind of its superclass but not a part of it. Vehicle could be a superclass with truck and car as subclasses but it would be a conceptual error (which unfortunately is a common error among new and even not so new OO developers) to model the bill of materials as a subclass. I.e., a car is also a body, engine, tires, etc. but those aren't subclasses of car they are parts of it and are modeled as object properties. Anyway, I'm going into too much detail it's just such a fundamental error I was surprised to see it here but I'm going to change it and add some references. I've also seen other sections in this article that aren't clear on the distinction between subparts and subclasses and I plan to edit those as well. MadScientistX11 (talk) 20:11, 20 December 2013 (UTC)

Can't see justification for independent article for "Open class". a couple of sentences in this article would suffice. Polyamorph (talk) 20:25, 16 May 2018 (UTC)

absolutely agree, they should be merged. I think someone should be bold and just do it. --MadScientistX11 (talk) 03:41, 17 May 2018 (UTC)
 Done. Polyamorph (talk) 08:08, 17 May 2018 (UTC)