473,795 Members | 2,847 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Extending intrinsic classes

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.prototyp e.mySplit(myArg s){...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.
Nov 21 '05 #1
7 1644
"A Traveler" <hi************ *********@yahoo .com> wrote in message
news:Oj******** ******@TK2MSFTN GP15.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.prototyp e.mySplit(myArg s){...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.
Nov 21 '05 #2
| 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.
Nov 21 '05 #3
> 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.supe rnews.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.

Nov 21 '05 #4
| 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)...th is 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
Nov 21 '05 #5
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******** ******@TK2MSFTN GP15.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.prototyp e.mySplit(myArg s){...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.

Nov 21 '05 #6
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.supe rnews.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)...th is 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

Nov 21 '05 #7
gotcha.

good luck.
Nov 21 '05 #8

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

Similar topics

5
2943
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 context, but the author gave it in such a matter that it appears experience folks will know what it means to say a class is abstract and extended. Thanks.
5
3180
by: Alan Ho | last post by:
What are intrinsic objects of asp.net? thx
1
2283
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 classes so we can add our own methods and properties? We have an application that passes a deep hierarchical structure (four nodes deep) between a webservice and a smart client. We have built the web service using the Contract First Web Service...
9
2188
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); }
9
5789
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, EventArgs e) { Data_List(); } }
13
2125
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(); } // interface IB
7
3391
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 python developers. II want to add some more KEYWORDS and DATATYPES into the python script apart from the existing ones. It would be really great if anybody could guide me as which files and
5
2126
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 have to write one new class for each Control like MyTextBox, MyLabel, MyComboBox implementing IMyControlInterface. The Code for each Control is exactly the same but C# offers no way to "include" some code.
8
2377
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, edit link, show linklist), comments (add comment, show commentlist) etc. I do not need all this functionality on every page. Ideally I could just extend the controller like this
0
10448
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
10217
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
9046
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7544
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
5440
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5566
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4114
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
2
3730
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2922
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.