Store it in the cloud! The cloud is magic. It does everything but the dishes! X|
Kabwla Phone
Posts
-
What technique do you use to persist state? -
What technique do you use to persist state?Hi, I have been a developer for many years now, and I support this message to the fullest. So should YOU! Seriously, settings are such a hassle. The 'Appconfig' likes to forget them. If you roll your own you have to be backward compatible. Even VS has a 'reset to defaults button' for the interface because it can get stuck in a bad layout you can not manually correct anymore. If you provide too many options your application becomes 'too difficult' Fortunately I was able to convince my coworkers of this. Our application remembers the sizes of the screens, when a screen is shown, it checks if the position is a valid desktop position (making multi-monitor compatible even if you remove a monitor). That's it. Whenever a customer ask for more setting, we say: Tell us exactly what settings you want. For which screens? How should remember them? Is it ok to break it with future changes. But before you do this, remember that each setting cost 1 hour to develop, 1 hour to deploy, 1 hour to test. Plus the square root (in hours) of all settings combined for additional testing where settings may interfere with each other. Then multiply that with out hourly wage and ask yourself this question: "Do you really want that setting?" Maybe, one day, one of our clients will say yes... Then we'll slap them with a 200% 'we really do not want to do this' bonus fee.
-
artificial inteligence is a myth!!!impeccable (Sorry I'm late, I missed the train.)
-
Variable Names*ONLY when you are talking about co-ordinates. Fixed that for you.
-
Do you not understand booleans?(edit: I posted this as a reply to a message that is now now longer there, oh well) I do not write out the boolean, but I do write each condition on a new line. In addition to that, I start the new line with the operator, this way, it is very easy to see at the beginning of the line that it is a continuation of the previous line, and what the operation is:
if( flag1
&& (someOtherFlagThatWillSqrewWithTheLayout == MagicNumbers.Ten)
&& (flag3 == somethingElseCompletely))
{
...
}I use this style with anything that will make a line of code too long:
//Contrived Deep Nesting, line too long
var firstChildRow= SomeTypedDataSetWithSillyLongNameThatFillsTheEntireCodeWindow.Tables[0].ChildRelations[0].ChildTable.Rows[0];
//Broken up for readability. Note that I start with the 'dot'.
var firstChildRow= SomeTypedDataSetWithSillyLongNameThatFillsTheEntireCodeWindow
.Tables[0]
.ChildRelations[0]
.ChildTable
.Rows[0]; -
Bug of the dayTo feed the trolls and have the string fit in the variable, you might consider increasing the length of said troll variable. Other problems in the code, using 'lower' to do a string comparission in SQL, which is case insensitive (unless you start toying with the collation).
-
Maximum number of columns that can be added in a dataset tableThe DotNet helpfile does not explicitly state a limit on the number of columns. Some time ago I had the same questions 'how many columns can I add' so I wrote a simpel loop. I was able to add more than 10,000 columns with unique names and of object type, so your 3,000 should be possible. So the question becomes, how is it failing? What is the error message you are getting? Without this information we are just playing a guessing game. So please let us know... Here are a few simple things to check: Are you sure all your columnnames are unique? Are you running out of memory? (How much memory are you consuming when the addition fails.) Do you have any rows in the table already is is the table empty? Thanx. (EDIT: So I was a little slow typing this response, not changing the text though)
-
For peer review: InputBox.If I have come off as offensive, I am sorry. My point, aptly indicated by 'bold statements' were meant to be a lighthearted overexageration of the problem at hand. I merely wanted to provide the requested peer review and give some pointers on how to write quality code. I thank you for your feedback and will consider this when writing another review. If you feel a need to bash on me, or some of my code, then I kindly invide you to visit my programming tip at: Extension method to determine if control is visible in complex hierarchy[^]
-
For peer review: InputBox.The class InputBox is static and there is nothing wrong with that, but it creates multiple instances of non-static (public!!!) class InputForm. These instances need to be disposed otherwise you are leaking memory (and handles). Also in this scenario, I imagine that the point of having a static-class is to hide the implementation of the actual form. In which case the form class should be made private, and the instance should not be returned. If the form is part of a complex mechanism, and you have code that actually needs to be able to reach the form, make it 'internal'. But considering the usage shown, I think this is not the case. You could also consinder making the constructor internal so only the assembly with InputBox can creates an instance of it. Changning the modifiers for the form does not in any way solve any of the other points I mentioned.
-
For peer review: InputBox.I could not find your code under 'tips & tricks' so I will shoot you here... This code has some flaws. You are lying to the user of the code Method "Create" does not only create the form, it also shows it. The showing of the form will halt program execution while a caller of the code might not expect this. You are confusing the user of the code You have a method that is called "Create" it returns a form that has already been shown, and you use the form in a direct comparission with an integer. This will earn you an article on: http://thedailywtf.com/[^]. You are leaky (well the code is) You are creating a form, but never disposing it, this is easily fixed in "ShowDialog" by using a 'using'. But "Create" is returning the form, so who will be responsible for that? Things can get fckd up.
var form1 = InputBox.Create("Multiply by 2:", "1");
// so form one is created, shown, not disposed and still in this reference (with a value of 9)
//get second value.
var form2 = InputBox.Create("Multiply by 2:", "6");
// lets asume that form2 had entered "6"
bool areSame = (int)form1 == (int)form2;
//This is actually true. (on review, have not actually run the code)Better rethink your strategy to something like:
public static class AskUserForValue
{
public int GetInt() { etc. }
public string GetString() { etc. }
public long GetLong() { etc. }
} -
.NET Source....And we will all love you if you are willing to share that application. Or, Sourcecode or it did not happen!
-
From where should the index start?Let me reverse your question... Where do you want your index to end? Suppose the character/element you are looking for is the last in the string/list. Should retrieving the value be implemented as: zero based: List[List.Count -1]; One based : List[List.Count];
-
The "Aha! Moment"I started fiddling with Aspose.Words for document generation. They claim this is easy because you can program to a objectmodel. Well, what I needed was a "MergeField" in a table cell. And their clever 'builder' kept telling me, "you can not add this", "Table already ended.".. Fun stuff. Finally after much fiddling i found something that worked:
Cell cellStart = CreateCell(rowMergeValues, false);
builder.InsertField("MERGEFIELD " + MYVALUE, "«MergeField»");
var current = builder.CurrentParagraph;
current.Remove();
cellStart.Paragraphs.Add(current);
builder.MoveToDocumentEnd();Yes, add, remove, add, move pointer... Aha! The sad part about problems like these is, it's just a few lines of code.. How could that have taken so much time? Also, reading the book "Code Complete 2.0". (Code is read more often that written.) It really changed the way I program now.
-
The purpose of error messagesRob, I like how you use arguments to support your opinion. Makes it easier for me to disagree with you. Stephan, Very good thought, nicely put too. I totally agree, but then again, I am a developer. From my exeprience many programmers suffer from the "There is an error message"-syndrome too. It makes me agry because it always forces me to ask: "Well, what is the message". I have notified those colleges that I will no longer respond to those reports that do not include the actual message. Makes life much easier. :laugh:
-
Regions: Love or HateI think this is a good example of good usage. The advantage a region has over a comment is that a region can signal the end of your logical block. With a comment you would have to asume that the comment is valid until the next comment. And as you know, assumtion makes an ... out of u and me.