473,657 Members | 2,395 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2157
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
structuremember funtions 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*********@co mcast.netREMOVE THIS> wrote in message
news:fI******** ************@co mcast.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*********@co mcast.netREMOVE THIS> a écrit dans le message de
news:fI******** ************@co mcast.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
11223
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 not know how to translate the ReDim that occurs there into C#. Or wither this will actually give me what I'm looking for. The code I'm posting seems to work although I don't know how to set the length of the name correctly in the...
1
4084
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
2612
by: Crirus | last post by:
Is there a function that return some random ID like string alphanumeric? Like this: A35sDsd1dSGsH Thanks Crirus
2
4193
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 way to do a CRC type calculation on an object to see if it has changed or has been tampered with. Thanks.
7
5896
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. 1. Using the WebBrowser and loading the HTML into the mshtml.HTMLDocument class and then step through the various tags (input, a), tables etc. 2. Use System.Net.WebRequest/Response to load the data into a HTML string using a Stream Reader. Now...
6
267
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 (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...
10
4377
by: Charles Hunt | last post by:
Hi, When running this code in VB2003 Sub guidtest() Dim gstring As String Dim gid As Guid
4
2375
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. Because I want to use some ajax-requests and other javascript-functions on my xhtml, I need to dynamically add event handlers to any possible dom-elements. All solutions I found so fare are for specific, pre-known
5
4599
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 denominator for structs and strings and while looking through the SDK I only noticed the IEquatable<T> interface. So I implemented the class with methods such as the following, but I'm aware that this is not the right approach.
0
8394
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8306
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8503
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7327
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
6164
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
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4304
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
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
1955
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.