473,770 Members | 1,642 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Class or Type?

Hi All!

Instead of calling an object definition a class in JavaScript, should we say
that it is a type or definition or something like this?

So I might say "The object type is defined by its constructor."

Thanks for any advice!

Rob
:)

--
Robert Mark Bram
Doctor of Philosophy Student
School of Network Computing
Monash University, Frankston, Australia
Email: ro*********@you rshoesinfotech. monash.edu.au
Remove your shoes to reply
Jul 20 '05 #1
2 1864
Robert Mark Bram wrote:
Hi All!

Instead of calling an object definition a class in JavaScript, should we say
that it is a type or definition or something like this?

So I might say "The object type is defined by its constructor."

Thanks for any advice!


I think whatever you need to make your decision is on pp. 3-4 of the
EcmaScript standard, available for download at:

http://www.ecma-international.org/pu...s/ECMA-262.HTM

Note, if you download the standard in Adobe format, this would be pp.
15-16 of the PDF.

G

Jul 20 '05 #2
"Robert Mark Bram" <ro*********@yo urshoesinfotech .monash.edu.au> wrote
in message news:3f******** **************@ news.optusnet.c om.au...
Instead of calling an object definition a class in
JavaScript, should we say that it is a type or definition
or something like this? So I might say "The object type is defined by its constructor."


Terminology is all about being understood. You can call anything by any
name you like but if you stray too far from excepted definitions and
meanings you may as well keep quiet. But understanding goes both ways
and the person on the receiving end has to be willing to engage in the
process in order to understand what is being said.

I don't have a big problem with using the term "class" to describe a
particular aggregation of JavaScript constructs that go towards
determining the nature of an instantiated JavaScript object (The
constructor, any associated custom prototype, function definitions
assigned to object properties or prototype members, etc.).

The term is reasonably questionable because (at minimum) unlike
class-based languages the code that defines an object is open to
modification at any point so one object created with a constructor can
be very different from another object created with the same constructor
at some subsequent point in terms of its structure and behaviour (and
all object instances are open to independent modification).

That means you would have to say "The object "type" is defined by its
constructor, prototype, etc, etc, at the moment it was constructed plus
the influence of any relevant modifications." . Which makes "type" or
"class" seem like fairly pointless concepts to attempt to apply.

In reality, though that wonderful mutability of JavaScript objects opens
up some interesting possibilities (particularly in terms of conception
related to OO programming in JavaScript), it is not something that you
will want to do in the normal course of events. Usually you will write
your object code and instantiate your objects and the one thing that you
would not then do is set about modifying the code structure that would
constitute the "class" while the script was executing.

So, if the code that defines an object is constant you can practically
talk of that object having a "type" or belonging to a "class". It might
not be the "correct" description of the situation but it is terminology
that is understood as relating to a concept that is pertinent to the
code being described. The people who understand class-based languages
will grasp the concept and the people who understand JavaScript (ECMA)
script will know the discrepancy but they will also understand the
concept. And if you want to author objects that change behaviour as a
script executes you will have to find some different terminology to
explain the concept to other people.

This problem extends to other bits of terminology that are borrowed from
class-based languages such as "private" and "private static" members.
Neither exist in JavaScript, but that wonderful flexibility means that
JavaScript can emulate both (there doesn’t appear to be much that
JavaScript can't emulate, you just have to work out how). So once you
have written an object that implements an emulation of a "private"
instance member do you describe it as "a function local variable
preserved in a closure formed by assigning an inner function to a public
object member during the execution of the constructor" and be
technically correct in terms of the mechanism, or do you short-cut to
"private instance member" and get the concept across? I would let the
context decide that for me.

I am going to continue using terminology from class-based languages to
describe concepts implemented in JavaScript if I think that those terms
are applicable to the code that I am describing. If it is useful to
describe a particular code structure as a "class" then that is what I
will call it.

I am willing to listen to (and possibly adopt) suggestions for
alternative terminology but I don’t see "type" as sufficiently different
in concept from "class" to make it applicable to a larger (or different)
sub-set of JavaScript objects/structures.

Richard.
Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
9600
by: Fernando Rodriguez | last post by:
Hi, I need to traverse the methods defined in a class and its superclasses. This is the code I'm using: # An instance of class B should be able to check all the methods defined in B #and A, while an instance of class C should be able to check all methods #defined in C, B and A. #------------------------------------------------
3
2695
by: George Sakkis | last post by:
I'm trying to write a decorator similar to property, with the difference that it applies to the defining class (and its subclasses) instead of its instances. This would provide, among others, a way to define the equivalent of class-level constants: class Foo(object): @classproperty def TheAnswer(cls): return "The Answer according to %s is 42" % cls.__name__
2
2041
by: dinks | last post by:
Hi, I'm new to C++ and have been assigned a task which i dont completely understand. Any help would be greately appreciated. Here is the problem: The class "linkedListType" use the "assert" facility. I am to get rid of them and replace them with exceptions. I need to create a "linkedListException" class that's declared and implemented in my "linkedListType" class. This class needs to inherit from the base "exception" class and return...
0
3030
by: keith bannister via .NET 247 | last post by:
(Type your message here) -------------------------------- From: keith bannister Hi, I'm new to .net (as of last week) but here goes. I want to serialize/deserialize a file the conforms to an XML schema (xsd).
5
7288
by: Keith Bannister | last post by:
I'm new to .net so here goes. I'm tying to deserialize a class that is associated with an XML schema. I created the C# class with xsd.exe as below: xsd.exe /c /n:somenamespace properties.xsd this creates properties.cs
5
1966
by: Rob | last post by:
In many articles related to VB.net the word "class" is used... How many meanings are there to this word ? "possible to derived a class from another" "forms are full-fledged classes" "base class"
38
2055
by: looping | last post by:
For Python developers around. >From Python 2.5 doc: The list of base classes in a class definition can now be empty. As an example, this is now legal: class C(): pass nice but why this syntax return old-style class, same as "class C:", and not the new style "class C(object):" ?
3
3758
by: Hamilton Woods | last post by:
Diehards, I developed a template matrix class back around 1992 using Borland C++ 4.5 (ancestor of C++ Builder) and haven't touched it until a few days ago. I pulled it from the freezer and thawed it out. I built a console app using Microsoft Visual C++ 6 (VC++) and it worked great. Only one line in the header file had to be commented out. I built a console app using Borland C++ Builder 5. The linker complained of references to...
5
3174
by: JH | last post by:
Hi I found that a type/class are both a subclass and a instance of base type "object". It conflicts to my understanding that: 1.) a type/class object is created from class statement 2.) a instance is created by "calling" a class object.
20
4043
by: tshad | last post by:
Using VS 2003, I am trying to take a class that I created to create new variable types to handle nulls and track changes to standard variable types. This is for use with database variables. This tells me if a variable has changed, give me the original and current value, and whether the current value and original value is/was null or not. This one works fine but is recreating the same methods over and over for each variable type. ...
0
9595
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9432
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10232
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10059
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9873
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7420
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6682
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5454
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3974
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.