String vs. GUID object

M

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;
}
}
}
 
S

Sebastian Dau

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
 
P

Patrice

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
 
G

Guest

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!
***************************
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top