473,394 Members | 1,841 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,394 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 2122
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: 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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
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...
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
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...
0
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,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...

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.