As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
Edit -- I'll try to make my question more to the point
I am working with the DataContractSerializer. I noticed that when I instance the serializer, I can specify the Namespace and the Name. Is there any guidance out there (or maybe a best-practice) to describe when I might want to take control of the name and namespace, and what I might want to use for the values?
I was tempted to use the namespace and class name of the class that I am serializing deserializing. Is that a good or bad practice?
DataContractSerialializer is a contract-based serializer, so forwards compatibility shouldn't a huge problem as long as you are adding - and if you do want to rename, you can hide that by adding the old name via attributes. As such, I would say "keep it simple" - trying to get clever is the cause of many bugs.
Re "What do you think?" (comments) - I think I'd rather use protobuf-net, but I'm somewhat biased :p
Related
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I have class with method that inside of it i take complex object and
from it I create new object with simple structure user can work with it
in more convenient way .I store this object instance in the memory and
and provide simple api to it.
I give it name Serializable but I'm not sure that this is the right name.
Transform
TransformToX (where X is the name of the resulting object)
ToX (you see that a lot, for instance, ToString, ToInt32)
I name methods like that using names like asThing(). I suppose in C# it should be AsThing(). Another choice might be to follow the example of Java's Number class: Number.intValue(), etc.
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I am using System.Runtime.Caching for memory cache, but I would like to have a filecache aswell. I am having some trouble, seeing how to do this.
Of course, I can create my own, simply method of doing this. Save to disc, get from disc if it exists. BUT, can I do something more clever, with System.Runtime.Caching? Get expiration on the items, as an example?
I don't really see how to implement expiration, on my simple save-to-disc cache.
Serialization is the key with which you can achieve this sort Caching on the FileSystem. First of all you must be having some object to Cache on the FileSystem. Include the Expiration time factor in it to check for its expiry (can be implemented using Timer) then you just need to design those objects to support Serialization.
To understand more about Serialization use following references:
What is [Serializable] and when should I use it?
.NET Serialization (using BinaryFormater, SoapFormatter and XmlSerializer)
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
So far I understand that its good practice to XML comment a classes methods but is there a standard for how much you should use XML comments?
Should I be using them to document field variables, properties & constructors or is that just overkill?
Had a look about the web but can't see any hard and fast rules for this sort of thing.
There are two reason to use XML comments opposed to plain English:
If the comments follow the correct format they will show up in IntelliSense, meaning when I use your class I can see that int a is supposed to be the count or whatever the same way I see helpful info when I'm using .NET methods,
If you use the XML formats Microsoft supports you can create html (or other formats of) documentation using SandCastle or similar third party utilities.
So, if you're taking the time to write comments, you may as well make them the XML ones that VS encourages.
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
Would it be classed as bad practise to have a solution called "Importer" and then have several projects called Importer.[projectname]
Imagine project name is like Importer.Model etc.
Is that good or not?
I want to confirm my thoughts with other developers
Thanks
No, it's not bad practice, as long as you choose appropriate names.
Visual Studio will assume that the project name provides the default namespace, so for a project named Foo.Bar you'll have Foo.Bar as your namespace.
This is useful when you're working on a set of libraries that fit under a parent namespace. For example, you might want to use your company name as the first part of the namespace, and the library name for the latter part, e.g. MyCorp.MailLib, MyCorp.ReportsLib, etc.
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
A simple question: Why there isn't any NotImplementedAttribute in C#?
You can always throw the exception, but I think it would be nice for this to work as the
ObsoleteAttribute -> you get an warning for using that method.
Ok, you have a method with this attribute, and when you implement it you have to remove the attribute by hand, but I think this is safer than using methods with throw new NotImplementedException() inside...and wait for them to get called.
I remember reading that the Obsolete is hard coded into the compiler, but maybe there is some spare room for this one :)
This is just my opinion, maybe I am wrong. But it's something that I would like to see.
Thanks