|
I read somewhere:
The advantage of Hungarian notation is a reminder of the type of a variable.
In a true and pure OO language Hungarian notation would have no purpose. Here, variables are typeless - they contain an object, the type of which depends on the object itself, not the variable. There are no primitive types. In fact, Hungarian notation was developed for programming in C, which is not an object-oriented language.
If you have a type for a host variable, the proper way to name it is to use something like HostID. Then anyone can declare a variable to be of type HostID and use its operations without knowing or caring if it is a class, a structure, an integer, etc. This is called encapsulation and is a sign of good programming. It is one of the basic concepts of Object Oriented Programming. Notice that the HostID can be of any type and you don't care or want to know what type it is. You only need to know that it is the type required for a parameter to a function or what operations are available on the type.
Hungarian notation encodes type information into variable names. This is very useful in languages that don't keep track of types information for you. But in C#/Java it is completely redundant. Thus, the notation simply adds to obscurity.
Hungarian notation is, when all is said and done, a commenting technique. And the one great law of comments is that they lie. Comments are not syntax checked, there is nothing forcing them to be accurate. And so, as the code undergoes change during schedule crunches, the comments become less and less accurate.
In the .NET/Java environment, the development tool automatically detects the type of a variable when programming, so the need of viewing the type of a variable in the variable name disappears.
Ludwig
|
|
|
|
|
I want to have a group of 3 radio buttons and determine which one was checked without having to check if each one was checked. I am new to WinForms and have a web background where RadioButtons were indexed. Is there a way to do this? I will have many sets of these radio button groups and don't want to deal with the hassle of checking which one is checked with lots of code.
Thanks for your help.
c
|
|
|
|
|
anyone have a good book or reference or simply know how to do this:
im creating design time component that uses xml to populate a collection of control properties, which is then used to actually create and paste the controls to a form.
the difficult part is: once i have the collection of control definitions in the component, how do i actually paste them onto the form (ie: in the 'Component Designer generated code' area)?
do i open the cs file and write to it? that seems too crude.
how does msft do it?
im dying for a great (not good) book on advanced component and control coding in C#.
|
|
|
|
|
I believe you use Code DOM to do that, but I have no idea how to.
If you have a local bookshop (so you can thumb through it) take a look at .NET Windows Forms Custom Controls by Richard Weeks published by SAMS.
Here is a sample chapter.
Good luck,
James
Simplicity Rules!
|
|
|
|
|
I have created a C# messenger using .NET remoting to handle all the calls from the client apps. Now I`d like to add a "send file" option to the messenger. Is it possible using .NET remoting? Any suggestion?
|
|
|
|
|
[disclaimer]I know next to nothing about remoting[/disclaimer]
You could create a method which takes in pieces of the file; so you'd have something like this
BeginReceiveFile(long fileSize, string filename);
ReceiveFileChunk(byte [] bytes);
EndReceiveFile(string filename);
First you call BeginReceiveFile passing in the total file size and the filename, then you break the file into chunks; then when its all done you call EndReceiveFile to let the client/server know that its done.
Take what I say with a grain of salt though
James
Simplicity Rules!
|
|
|
|
|
Hi
I am first serialising an object and then to a *.dat
file
like this:
public void SerializeNow(DataSet dsout)
{
FileStream fs = new FileStream
(@"c:\scrpe1.dat",FileMode.Create);
BinaryFormatter b = new
BinaryFormatter();
b.Serialize(fs,dsout);
fs.Close();
}
and then I am trying to encrpt it using this Microsoft
code at
http://support.microsoft.com/default.aspx?scid=kb;EN-
US;q307010
Then I decrypt it which is good also.
Then I try to deserialise it where the problem occurs
and it gives me
an
error saying:
"Binary stream does not contain a valid BinaryHeader, 0
possible
causes,
invalid stream or object version change between
serialization and
deserialization"
If Do not do the inbetween encrypt and decrypt then
everything works
fine
no errors in deserialization.
What can be the problem???
Paresh.
|
|
|
|
|
When you decrypt how are you handling the second file? Did you change it to a memory stream or are you doing just what is listed?
James
Simplicity Rules!
|
|
|
|
|
hi there,
i'm exploring in the image-saving-in-different-formats direction and have got a question about the tiff-encoder:
the only two compression-modes, that i can use are EncoderValue.CompressionNone (wa-hey!) and EncoderValue.CompressionLZW(which works good) - anything else raises an System.ArgumentException: Invalid parameter used in the Image.Save(,,) method.
does someone know, if these encodervalues work as they should, somewhere? sometime?
:wq
|
|
|
|
|
ok, ccitt3 and ccitt4 can only be aplied to 1-bit (black/white) images - first part of the problem solved
so lets see, what the problem mit RLE is...
:wq
|
|
|
|
|
Can I find such a control (or similar) in C#?
Tomiga
|
|
|
|
|
There isn't anything built in; but you can always use the IE browser control and try to tie into its events.
Better yet You can use MC++ as your glue so you can use MFC and an MC++ class to communicate with your C# application.
HTH,
James
Simplicity Rules!
|
|
|
|
|
James T. Johnson wrote:
Better yet You can use MC++ as your glue so you can use MFC and an MC++ class to communicate with your C# application.
Sounds like a sticky mess.
Nick Parker
|
|
|
|
|
many xml have a DOCTYPE point to a dtd file in a far web site.
just like my download svg sample, it writes
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20001102//EN"
"http://www.w3.org/TR/2000/CR-SVG-20001102/DTD/svg-20001102.dtd">
well, either i use XmlDocument.Load(string) or
first open a XmlTextReader and then Load(XmlReader),
I face a long long wait(my internet link is rather slow). The reader try to get the dtd!
How can i instruct the reader to neglect it or tell it that the dtd sit in one of my hard disk's directory? Dont tell me to edit the DOCTYPE element manually to change the dtd url. That's the work the program should do.
Any way?
|
|
|
|
|
Jenny Li wrote:
That's the work the program should do.
Actually I think that is something it shouldn't be doing. It needs the DTD so how is it to know where one is except from the DOCTYPE. When you tell it to load an XML file it is going to do just that, if you don't want it to load the DTD then you should remove the DTD before telling it to load the document.
James
Simplicity Rules!
|
|
|
|
|
Can someone give some advice on how to use a webcam in a C# project?
|
|
|
|
|
Are you looking for an example on how to include the visual aspect of it in an application, or just ideas?
Nick Parker
|
|
|
|
|
I`m trying to connect two apps with a webcam, say like yahoo messenger or similar, but don`t really know where to start. I guess i`ll have to deal with COM components. If there is any idea, or example it`d be great
|
|
|
|
|
|
I would be surprised if there are any non-MS conventions out yet!
Nish
The posting stats are now in PDF:-
http://www.busterboy.org/codeproject/
Feel free to make your comments.
Updated - May 04th, Saturday
|
|
|
|
|
I'm assuming you're referring to naming conventions. If so, there aren't any that are written in stone at this point. I cover this in the first edition of Inside C#, but to summarise that information, a mixture of camel (lowercase) and Pascal (mixed case string with an upper case letter) casing are used. Pascal naming is generally used on method names and camel casing is used with variables.
Cheers,
Tom Archer
Author, Inside C#
Author, Visual C++.NET Bible
A total abstainer is one who abstains from everything but abstention, and especially from inactivity in the af
|
|
|
|
|
As Tom pointed out camel and Pascal casing are commonly used. I use camel casing for private objects (fields, properties, methods, and local variables). I use Pascal casing for protected/public objects (fields, properties, methods).
My style changes from time to time though; at one point I was prefixing private variables with an underscore.
James
Simplicity Rules!
|
|
|
|
|
On another note for notation...
I have read that Microsoft is dropping the idea of Hungarian notation for C#, all except for the i before the declaration of an interface.
Nick Parker
|
|
|
|
|
Yes, hungarian notation is definitely being played down by MS. Of course, since we don't see any source code any more (unlike with MFC) it really doesn't matter
Cheers,
Tom Archer
Author, Inside C#
Author, Visual C++.NET Bible
A total abstainer is one who abstains from everything but abstention, and especially from inactivity in the af
|
|
|
|
|
Tom Archer wrote:
since we don't see any source code any more (unlike with MFC) it really doesn't matter
I don't think this means we should start naming our variables strNumber and iWord however.
Nick Parker
|
|
|
|