Hello all,
i was just curious if anyone whos been playing with VS2005 could tell me...
In javascript (and java??) you can alter the prototypes for an object in
your project. I dont remember the syntax exactly, but basically you do
something like:
function String.prototype.mySplit(myArgs){...do something...}
and then any instance of a String object in that project has a new method
called "mySplit".
This isnt something by some chance that we will be able to do with intrinsic
objects in the framework in VS2005, is it?
I know it can be done by inheriting the intrinsic and extending it with a
new class in my project, but thats a lot heavier and more convoluted.
Cheers,
- Arthur Dent. 7 1621
"A Traveler" <hi*********************@yahoo.com> wrote in message
news:Oj**************@TK2MSFTNGP15.phx.gbl... Hello all,
i was just curious if anyone whos been playing with VS2005 could tell me...
In javascript (and java??) you can alter the prototypes for an object in your project. I dont remember the syntax exactly, but basically you do something like:
function String.prototype.mySplit(myArgs){...do something...}
and then any instance of a String object in that project has a new method called "mySplit". This isnt something by some chance that we will be able to do with intrinsic objects in the framework in VS2005, is it?
I know it can be done by inheriting the intrinsic and extending it with a new class in my project, but thats a lot heavier and more convoluted.
Most people would disagree and say that the prototype mechanism used in
JavaScript (but not Java) is the convoluted method they used of avoiding the
"normal" OO technique of inheritance.
----
John Saunders
BTW, you are probably aware that there is no relationship between Java and
JavaScript (nee LiveScript) except for the name, which sounded "cool", so
they changed it.
| I know it can be done by inheriting the intrinsic and extending it with a
| new class in my project, but thats a lot heavier and more convoluted.
actually, the former is a lot heavier since *all* string objects will now
carry the prototype extentions rather that just the one's you declare as the
new extended type class that inherits from string. as far as convolution,
again the former looses out. ever try and track down which js file actually
contains the prototype definition when there are several js files
included/referenced in a web page? add to that, prototypes of your prototype
of the original string object (spread among multiple files)...or a prototype
of a prototype of a prototype of the original string object (spread among
multiple files)...ad nausium.
i don't know why you'd want to do this in vb.net and don't think that you
can. it would be a maintainence nightmare.
> ever try and track down which js file actually contains the prototype definition when there are several js files
True, anything can be misused, and im not saying its something to go crazy
with.
But sometimes it could be useful. For example. Something i do Quite
frequently with
my strings is a port of Oralce's NVL function, but for strings so
essentially it pseudo-codes as:
If strVal = "" Then Return NullValue Else Return strVal
This is something i do very frequently in my code, and it would be nice
instead of having to make a
new class (or module), and writing this function, then having to imports the
module when i need it,
to just extend the String object for the project scope to have a new method
NVL(NullValue as String)
But, its not a big deal. I was just curious.
Thanks.
"steve" <a@b.com> wrote in message
news:10*************@corp.supernews.com...| I know it can be done by inheriting the intrinsic and extending it with a | new class in my project, but thats a lot heavier and more convoluted.
actually, the former is a lot heavier since *all* string objects will now carry the prototype extentions rather that just the one's you declare as the new extended type class that inherits from string. as far as convolution, again the former looses out. ever try and track down which js file actually contains the prototype definition when there are several js files included/referenced in a web page? add to that, prototypes of your prototype of the original string object (spread among multiple files)...or a prototype of a prototype of a prototype of the original string object (spread among multiple files)...ad nausium.
i don't know why you'd want to do this in vb.net and don't think that you can. it would be a maintainence nightmare.
| If strVal = "" Then Return NullValue Else Return strVal
|
| This is something i do very frequently in my code, and it would be nice
| instead of having to make a
| new class (or module), and writing this function, then having to imports
the
| module when i need it,
| to just extend the String object for the project scope to have a new
method
| NVL(NullValue as String)
this is a big deal when you have multiple developers on a project expecting
strings to behave like strings but now have to track down why they just set
strVal = "" and the next line calls to get strVal and it returns something
other than "". this is why there are well defined oop standards that most
languages follow...even php. all objects should build off of a base
definition where the new derivative must be referenced to get the new
functionality. "" is not nothing/null anyway...and, what happens when the
NullValue is itself "" (watch your processor go crazy on that one)! if you
could prototype your string object in this manner, then setting a string to
"" would cause your nvl function to validate and reset the variable to a nvl
of "" (were that the NullValue)...this would start the validate/reset loop
again...and again...and again...those are the types of issues you get when
considering the alteration of an object by javascript methodology where the
actual base class is altered and not a derivative thereof.
hth,
steve
Arthur,
Prototypes as found in javascript (but not java) are not in VB.NET 2005, nor
C# 2005. I know it can be done by inheriting the intrinsic and extending it with a new class in my project, but thats a lot heavier and more convoluted.
You do realize that all the "intrinsic" types are either NotInheritable
(String) or value types (which are inherently NotInheritable) so this is not
an other either.
Hope this helps
Jay
"A Traveler" <hi*********************@yahoo.com> wrote in message
news:Oj**************@TK2MSFTNGP15.phx.gbl... Hello all,
i was just curious if anyone whos been playing with VS2005 could tell me...
In javascript (and java??) you can alter the prototypes for an object in your project. I dont remember the syntax exactly, but basically you do something like:
function String.prototype.mySplit(myArgs){...do something...}
and then any instance of a String object in that project has a new method called "mySplit". This isnt something by some chance that we will be able to do with intrinsic objects in the framework in VS2005, is it?
I know it can be done by inheriting the intrinsic and extending it with a new class in my project, but thats a lot heavier and more convoluted.
Cheers, - Arthur Dent.
Nah, you misunderstood my code. It wouldnt be to reset the value of the
object if it went 'null'. It would more likely be a method or property,
something like
Class String
...........
Public ReadOnly Property NVL(NullValue As String) As String
Get
If Me.Value = "" Then Return NullValue Else Return Me.Value
End Get
End Function
...........
End Class
But since its not possible, its not really an issue anyway.
Thanks. :)
"steve" <a@b.com> wrote in message
news:10*************@corp.supernews.com... | If strVal = "" Then Return NullValue Else Return strVal | | This is something i do very frequently in my code, and it would be nice | instead of having to make a | new class (or module), and writing this function, then having to imports the | module when i need it, | to just extend the String object for the project scope to have a new method | NVL(NullValue as String)
this is a big deal when you have multiple developers on a project expecting strings to behave like strings but now have to track down why they just set strVal = "" and the next line calls to get strVal and it returns something other than "". this is why there are well defined oop standards that most languages follow...even php. all objects should build off of a base definition where the new derivative must be referenced to get the new functionality. "" is not nothing/null anyway...and, what happens when the NullValue is itself "" (watch your processor go crazy on that one)! if you could prototype your string object in this manner, then setting a string to "" would cause your nvl function to validate and reset the variable to a nvl of "" (were that the NullValue)...this would start the validate/reset loop again...and again...and again...those are the types of issues you get when considering the alteration of an object by javascript methodology where the actual base class is altered and not a derivative thereof.
hth,
steve
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: needin4mation |
last post by:
Hi, I read this in a book about the Xml classes in c#:
"These classes are abstract and therefore must be extended."
I just wanted to know what this statement means. I know it is not in...
|
by: Alan Ho |
last post by:
What are intrinsic objects of asp.net?
thx
|
by: Sarge |
last post by:
Hi all,
tough question. Apologies for the cross posting but it is an interesting
architectural problem and I think deserves a wide audience.
What is the best way to extend web service proxy...
|
by: Robert |
last post by:
Hi,
I thought it would be a good idea to make specialised error objects. So
I did something like this:
function IndexOutOfBoundsException(message)
{
Error.call(this, message);
}
|
by: Fat Elvis |
last post by:
I'd like to extend some of my Asp.net pages by using Partial Classes.
Example ASP.Net Page:
public partial class Admin_Customer : System.Web.UI.Page
{
protected void Page_Load(object sender,...
|
by: interec |
last post by:
I have some code in Java that I need to translate into C++. My Java
code defines a class hierarchy as follows:
// interface IA
public interface IA
{
public abstract void doA();
}
//...
|
by: Maximus Decimus |
last post by:
HI all,
I am using python v2.5 and I am an amateur working on python. I am
extending python for my research work and would like some help and
guidance w.r.t this matter from you experienced...
|
by: Wolfgang Hanke |
last post by:
Hello,
I want to extend multiple Controls like TextBox, Label, ComboBox etc. with
the same new featureset (for Example all need a Method getSomething())
Because I cant alter their Base-Class I...
|
by: Floortje |
last post by:
Hi i have been struggeling with this question for quite some time now.
I have some helper classes that handle images (upload an image, create
thumbnails and show a imagelist), links (add link,...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
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,...
|
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...
|
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...
| |