471,357 Members | 1,046 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,357 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 1967
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Arjen | last post: by
7 posts views Thread by Desmond Cassidy | last post: by
6 posts views Thread by ME | last post: by
10 posts views Thread by Charles Hunt | last post: by
reply views Thread by XIAOLAOHU | last post: by

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.