Hot answers tagged

21

If the data never changes and is read only, then just put it in a code file as a list of constants. public readonly string AppStartUpData = "MyAppNeedsThis"; If this data is different per deployment, then an external file is fine. .Net comes with built in .config files (App.Config). One should use those as there are standard ways (built in to the ...


13

You can always add a file into your project and set its build type to Embedded Resource so that it is embedded directly into the application itself. Alternatively a file that is encrypted and placed in an accessible location.


11

A binary file would be the obvious answer, but it depends on how you are loading it - you might as well make life easy for yourself if you can. XML might be a good choice as there are built in methods in C# for reading this. You could add a checksum to your data, so that if the user alters it, the checksum will no longer match (you need to add a check to ...


6

If you don't want the user to even peek at the data, you should serialize it into a binary data file. Only the app would know the length of the chunks to read from it. I don't know C# but in Java you would create the file like this: FileOutputStream fos = new FileOutputStream(file); ObjectOutputStream oos = new ObjectOutputStream(fos); oos....


4

Static class methods are basically global functions, and are considered a bad idea in OO design. The reason why they are considered bad is hard to see in a simple code example where you are just comparing the difference between calling the same method on an instance or on the class itself. But when you get into slightly more complicated design global ...


3

Frameworks/SDK's probably use instantance methods because it makes dependency injection possible, which is not really the case for static methods. However, if you don't use DI, a static method is the simplest way. KISS.


2

"Exception Handling". Two little words but which is more important? I would argue, it's the latter. In a critical piece of code, should exceptions describing a situation which does not makes sense be handled? Counter-question: If a situation occurs which "does not make sense", what can you[r code] do about it? If the answer is "something useful"...


1

I have little mathematical background but I do see an approach that might work. I would assign a value to each coordinate in the grid that is determined by the amount and closeness of dotted neighbors. Then apply a threshold: only keep the coordinates that exceed the threshold value. Those will form the result path.


1

Have a look at Activator.CreateInstance. It will allow you to instantiate arbitrary classes at runtime based on a string representing the name of the assembly and class you want to instantiate. You can then plug in any class that conforms to the Interface you've specified, and configure it using an XML file accessible to your consumers. You should also ...


1

Is it significantly easier, faster, better for testing and management, etc. to write the code in C# on the server than in JS on the client? It depends entirely on your Developmental ecosystem. If you write and test lots of JavaScript code, then there might be some gain in doing so. If, however, you spend all your time cutting server-side, C# code and ...


1

Would that be considered as a bad practice/idea? Enh? My first instinct is that you wouldn't gain much in performance. Spinning up a new process and sending in the data is a bit heavyweight. My second instinct is I'm not sure how general you're going to be able to do it. Just because methods return no data doesn't mean they don't work with data. You're ...


1

To be fair, I wrote my own, very simple, MVVM-Framework (just for the sake of learning purposes) and you know what? I don't need this Implementation anymore: A very small code weaving tool named Fody.Propertychanged https://github.com/Fody/PropertyChanged does this for me. I can even set this on my base class and never have to care again about it.



Only top voted, non community-wiki answers of a minimum length are eligible