Jump to content

Talk:Class (computer programming)

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Ctxppc (talk | contribs) at 14:10, 28 January 2013 (Lack of language syntax examples). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

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)[reply]

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)[reply]

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)[reply]
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)[reply]
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)[reply]

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)[reply]

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)[reply]

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)[reply]

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)[reply]

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)[reply]

  • 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)[reply]

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)[reply]

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)[reply]