473,387 Members | 1,863 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

String vs. GUID object

ME
I am developing a kind of plugin framework that I can use for several
applications I want to make. In order to identify individual plugins I am
currently doing something like the code below (example only. Note that the
host has a collection of IPlugin's from which to look for the ID.).
Obviously you can tell that each plugin object will have the overhead of the
ID. The question is, which consumes more overhead? A string object or a
GUID struct? Should I use a GUID instead?

Thanks,

Matt

public interface IPlugin
{
string ID
{
get;
}
}
public class TestPlugin : IPlugin
{
// used to identify this object through the host from another
object in THIS assembly
public static readonly string testPlugin =
"{80369426-3FA8-457e-A0DD-4D8399114088}";

// Used to identify this object through the host from another
object NOT in this assembly
Public string ID
{
get
{
return testPlugin;
}
}
}
Jul 21 '05 #1
3 2121
Hello,

I did the almost the same thing for our app package and I went for
Guid structs. They are smaller than Strings holding guids and in the end it
is
quite easy to check format and stuff with help of the Guid
structurememberfuntions for parsing etc.

Size: Guid struct = 128 bit integer => 16 bytes
String Guid = 32 unicode character (32 x 16 bit ) || ( 32 x 2 byte ) => 64
byte

Greets, Sebastian Dau
"ME" <tr*********@comcast.netREMOVETHIS> wrote in message
news:fI********************@comcast.com...
I am developing a kind of plugin framework that I can use for several
applications I want to make. In order to identify individual plugins I am
currently doing something like the code below (example only. Note that the
host has a collection of IPlugin's from which to look for the ID.).
Obviously you can tell that each plugin object will have the overhead of
the ID. The question is, which consumes more overhead? A string object or
a GUID struct? Should I use a GUID instead?

Thanks,

Matt

public interface IPlugin
{
string ID
{
get;
}
}
public class TestPlugin : IPlugin
{
// used to identify this object through the host from
another object in THIS assembly
public static readonly string testPlugin =
"{80369426-3FA8-457e-A0DD-4D8399114088}";

// Used to identify this object through the host from another
object NOT in this assembly
Public string ID
{
get
{
return testPlugin;
}
}
}

Jul 21 '05 #2
You'll never see a difference in performance here...

I would use a GUID. With a string, the user of your fra mewokr will be
able to use whatever he wans included trings such as "test" and if you try
to use this as GUID it could lead to possible problems...

Patrice

--

"ME" <tr*********@comcast.netREMOVETHIS> a écrit dans le message de
news:fI********************@comcast.com...
I am developing a kind of plugin framework that I can use for several
applications I want to make. In order to identify individual plugins I am
currently doing something like the code below (example only. Note that the host has a collection of IPlugin's from which to look for the ID.).
Obviously you can tell that each plugin object will have the overhead of the ID. The question is, which consumes more overhead? A string object or a
GUID struct? Should I use a GUID instead?

Thanks,

Matt

public interface IPlugin
{
string ID
{
get;
}
}
public class TestPlugin : IPlugin
{
// used to identify this object through the host from another object in THIS assembly
public static readonly string testPlugin =
"{80369426-3FA8-457e-A0DD-4D8399114088}";

// Used to identify this object through the host from another
object NOT in this assembly
Public string ID
{
get
{
return testPlugin;
}
}
}

Jul 21 '05 #3
In size, the string will be 2 Bytes per character. The GUID is 128 bit, or 16
bytes. In addition, the GUID struct can be reused while strings are
immutable. I would shy away from the string for both of these reasons.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************
"ME" wrote:
I am developing a kind of plugin framework that I can use for several
applications I want to make. In order to identify individual plugins I am
currently doing something like the code below (example only. Note that the
host has a collection of IPlugin's from which to look for the ID.).
Obviously you can tell that each plugin object will have the overhead of the
ID. The question is, which consumes more overhead? A string object or a
GUID struct? Should I use a GUID instead?

Thanks,

Matt

public interface IPlugin
{
string ID
{
get;
}
}
public class TestPlugin : IPlugin
{
// used to identify this object through the host from another
object in THIS assembly
public static readonly string testPlugin =
"{80369426-3FA8-457e-A0DD-4D8399114088}";

// Used to identify this object through the host from another
object NOT in this assembly
Public string ID
{
get
{
return testPlugin;
}
}
}

Jul 21 '05 #4

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

Similar topics

1
by: Jeffrey B. Holtz | last post by:
I'm trying to get the Name of the USB device pluged in from the RegisterDeviceNotification that I've used P/Invoke to marshal. I have seen a similar posting on the VisualBasic newgroups but I do...
1
by: Arjen | last post by:
Hi, I have a Guid value. I want to save this inside the memory. What is the best way: save it as a Guid? Or as string? Thanks!
10
by: Crirus | last post by:
Is there a function that return some random ID like string alphanumeric? Like this: A35sDsd1dSGsH Thanks Crirus
2
by: Lucas Tam | last post by:
Hi all, I'm using the command GetType(MyObject).GUID to return a GUID. Is the GUID a CRC type calculation on the object, or is it a pre-assigned value on the object? I was hoping to have a...
7
by: Desmond Cassidy | last post by:
Hi, I have being trying to get a grip of HTML data manipulation and am using the mshtml class and System.Net to retriver HTML pages. Now as far as I can see, one can read HTML in different ways....
6
by: ME | last post by:
I am developing a kind of plugin framework that I can use for several applications I want to make. In order to identify individual plugins I am currently doing something like the code below...
10
by: Charles Hunt | last post by:
Hi, When running this code in VB2003 Sub guidtest() Dim gstring As String Dim gid As Guid
4
by: simon | last post by:
hi, I would like to separate my javascript completely from my xhtml. in the end there should be only <script type="text/javascript" src="javalib.js"></script> in the head-tag to my javascript....
5
by: Anders Borum | last post by:
Hi! While implementing a property manager (that supports key / value pairs), I was wondering how to constrain T to a struct or string type. Basically, I guess what I'm looking for is the common...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
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,...
0
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...
0
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...

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.