Click here to Skip to main content
15,885,914 members

Articles by Kabwla.Phone (Tip/Tricks: 14)

Tip/Tricks: 14

RSS Feed

Average article rating:

No articles have been posted.

Average blogs rating:

No blogs have been submitted.

Average tips rating: 3.99

Database Development
SQL Server
18 Oct 2011   Updated: 18 Oct 2011   Rating: 5.00/5    Votes: 2   Popularity: 1.51
Licence: CPOL    Views: 5,610     Bookmarked: 1   Downloaded: 0
Please Sign up or sign in to vote.
You also might want to look into the "LOCAL" keyword.This limits the scope of the cursor to the context in which it is created.DECLARE IdCursor CURSOR LOCAL FOR SELECT Id FROM MyTableThis is beneficial for many reasons.
Ienumerable
8 Nov 2011   Updated: 8 Nov 2011   Rating: 0.00/5    Votes: 0   Popularity: 0.00
Licence: CPOL    Views: 7,820     Bookmarked: 0   Downloaded: 0
Please Sign up or sign in to vote.
Implemented with a queue and some newfangled yields.Since a queue does not have an 'EnqueueRange', we will still have to do a loop. Of course, enqueue range would be a nice extension method.Excusing the overhead created by the yield, this might use less memory if there are many controls. (Or...
1 Nov 2011   Updated: 25 Nov 2011   Rating: 5.00/5    Votes: 3   Popularity: 2.39
Licence: CPOL    Views: 14,026     Bookmarked: 0   Downloaded: 0
Please Sign up or sign in to vote.
Ha! I get it....I am actually using an adaptation of this technique in production code.But the adapted code required a dept-first search and this original pattern is width-first.Which brings us these new and improved versions:public static List FindControlsWidthFirst( Control...
Programming Languages
C#
1 Dec 2011   Updated: 1 Dec 2011   Rating: 5.00/5    Votes: 1   Popularity: 0.00
Licence: CPOL    Views: 5,650     Bookmarked: 2   Downloaded: 0
Please Sign up or sign in to vote.
So here is a tip on how to improve upon this code. Do not silently catch exceptions! Instead, create a very simple logging mechanism that allows you to inspect the exception, either from code or during debugging.public static class InputBox{ public static Exception LastError {get; private...
1 Dec 2011   Updated: 1 Dec 2011   Rating: 0.00/5    Votes: 0   Popularity: 0.00
Licence: CPOL    Views: 11,380     Bookmarked: 1   Downloaded: 0
Please Sign up or sign in to vote.
Consider the scenario where the input value must be valid.public static double? GetDouble(string caption, string defaultValue, bool mustBeValid = false){ ClearLastError(); using (InputForm inForm = new InputForm(caption, defaultValue)) { while (true) { ...
1 Dec 2011   Updated: 25 Dec 2011   Rating: 0.00/5    Votes: 0   Popularity: 0.00
Licence: CPOL    Views: 6,560     Bookmarked: 0   Downloaded: 0
Please Sign up or sign in to vote.
You have introduced a Globalization / Regional problem by requiring the default value to be a string.double? value = InputBox.GetDouble("xyz", "1.0"); //Note the dotdouble? value2 = InputBox.GetDouble("xyz", "1,0"); //Note the commaOne of these two will fail, but not on every machine or...
8 Nov 2011   Updated: 13 Nov 2011   Rating: 0.00/5    Votes: 0   Popularity: 0.00
Licence: CPOL    Views: 7,540     Bookmarked: 0   Downloaded: 0
Please Sign up or sign in to vote.
I have made some improvements without making a change to the methodology.Note: Yes, the performance difference between string.format and concat is negligable when you are working with File-IO. Still we are here to educate.public static class FolderManager{ public static Exception...
1 Dec 2011   Updated: 25 Dec 2011   Rating: 0.00/5    Votes: 0   Popularity: 0.00
Licence: CPOL    Views: 21,520     Bookmarked: 4   Downloaded: 0
Please Sign up or sign in to vote.
Set visibility in complex (or composite) form.
1 Nov 2011   Updated: 1 Nov 2011   Rating: 0.00/5    Votes: 0   Popularity: 0.00
Licence: CPOL    Views: 9,650     Bookmarked: 0   Downloaded: 0
Please Sign up or sign in to vote.
Create a custom eventargs to make the eventhandling simpler.Any code interested in the change in the tractbar is very likely interested in its value..../// /// Custom event arguments class so we can push the value of the trackbar/// to any interested subscribers./// public class...
1 Nov 2011   Updated: 6 Nov 2011   Rating: 1.91/5    Votes: 5   Popularity: 1.33
Licence: CPOL    Views: 10,781     Bookmarked: 0   Downloaded: 0
Please Sign up or sign in to vote.
Make it a generic class and fix your problem forever. This works because the compiler turns the generic into a new class (something like SigletonManagerOfTypeParamterTypeName). So the static variables are not shared amongst instances...public static class Singleton where...
26 Nov 2011   Updated: 25 Dec 2011   Rating: 5.00/5    Votes: 1   Popularity: 0.00
Licence: CPOL    Views: 24,023     Bookmarked: 0   Downloaded: 0
Please Sign up or sign in to vote.
Determine visibility in complex (or composite) form
C# 3.5
18 Oct 2011   Updated: 18 Oct 2011   Rating: 1.00/5    Votes: 1   Popularity: 0.00
Licence: CPOL    Views: 22,380     Bookmarked: 2   Downloaded: 0
Please Sign up or sign in to vote.
Which will crash if the datatype of the column is not a string.You might also want to note that this only works for typed datasets.This version works for all datasets, can handle any datatype, and handles null values: table.Rows.AsQueryable() // make...
Web Development
ASP.NET
1 Nov 2011   Updated: 6 Nov 2011   Rating: 0.00/5    Votes: 0   Popularity: 0.00
Licence: CPOL    Views: 7,181     Bookmarked: 0   Downloaded: 0
Please Sign up or sign in to vote.
Tip: Change your loop to the following to also support derived classes:foreach (var item in controlList ){ GridView asGridView = item as GridView; if (asGridView != null) { Utilities.RenderControlInExcel(asGridView, workBook); } DetailsView asDetailsView =...
HTML
1 Nov 2011   Updated: 6 Nov 2011   Rating: 5.00/5    Votes: 1   Popularity: 0.00
Licence: CPOL    Views: 4,550     Bookmarked: 0   Downloaded: 0
Please Sign up or sign in to vote.
Tip - Never use type equality because that does not support derived classes:if (item.GetType() == typeof(Image)) //this is bad, mkay.Instead use the following which does support derived classes:if (item is Image)The Microsoft prefered pattern (when you actually need the cast object)...

Average reference rating:

No reference articles have been posted.

Average project rating:

No projects have been posted.
Software Developer (Senior)
Netherlands Netherlands
Doing that 'computer thing' ever since the C64.

Sometimes I feel that being a programmer is much like being a doctor: You just have to know everything and if you don't, something dies.

Either being an application or a patient.

Oddly enough, more people care about the death of their application, than the massacre of people...