Click here to Skip to main content
15,068,164 members

Comments by jfriedman (Top 30 by date)

jfriedman 16-Oct-13 1:51am View
Reason for my vote of 1 \n You don't cache the field lokup so if you call this function 100 times you have 99 iterations where you are using the same field info however you will waste time locating that same field info on the type 99 times.
jfriedman 13-Mar-13 22:17pm View
Reason for my vote of 5 \n Excellent advice, great article for showing an example of useless code with bad habits :P
jfriedman 5-Dec-12 21:02pm View
Reason for my vote of 2 \n Forgot about Reading the BMP Palettes and made your own..

The whole thing could be done like this private void button1_Click(object sender, EventArgs e)
using (FileStream file = new FileStream("face.bmp", FileMode.Open, FileAccess.Read))
this.pictureBox1.Image = Image.FromStream(file);
jfriedman 13-May-12 9:57am View
Reason for my vote of 4
Sweet, Simple and to the Point. I would have given you the extra point if you completed it by having the methods being Extensions to Directory. Good job otherwise.
jfriedman 6-May-12 11:49am View
Reason for my vote of 3
See improvement
jfriedman 5-May-12 14:59pm View
Reason for my vote of 1
For the love of money, family, pride or sanity in general please see the Distinct method @

jfriedman 30-Apr-12 19:27pm View
Reason for my vote of 3
Great code but how is this better or worse or even different than Lazy<t> ? A small comparison might be in order IMHO.
jfriedman 27-Apr-12 10:28am View
Reason for my vote of 4
For situations in which multiple queries will be run on the XML document over a period of time this is a very good example. In addition you may even be able to hash searches and use an additional hashTable or array to make lookups even faster.
jfriedman 13-Jan-12 17:53pm View
terinary operations such as (true ? 0 : 1) are basically nested if statements and some can ever short circuit as pointed out below in the alternates. What's insane is not using a TimeSpan when it is a Framework construct.
jfriedman 12-Jan-12 20:39pm View
Reason for my vote of 3
I would have used Enum.HasFlag and I would have used a single switch statement with goto for each case not a if else with nested if statements. Additionally you could just use the result of the time - anotherTime and use TotalSeconds or similar... e.g. someTime - anotherTime >= TimeSpan.FromSeconds(1.5)
jfriedman 27-Apr-11 17:06pm View
In hind sight you dont actually need a timer if you have the philsopher instances.

You can store a lastWorkTime variable and determine from that weather or not you need to work further.
jfriedman 25-Feb-11 14:41pm View
may want to fix your formatting though :)
jfriedman 25-Feb-11 8:32am View
Reason for my vote of 3
Cleaner than last time...
jfriedman 22-Feb-11 18:10pm View

It seems you are not familiar with GoF Principles. Google 'Chain of Responsibility' and 'Gang of Four'... It will greatly help you in the future to understand these principles so that you do not back yourself into these types of corners.
jfriedman 22-Feb-11 18:09pm View
It seems you are not familiar with GoF Principles. Google 'Chain of Responsibility' and 'Gang of Four'... It will greatly help you in the future to understand these principles so that you do not back yourself into these types of corners.
jfriedman 22-Feb-11 18:03pm View
Very nice answer SA, beautiful response & beautiful analyzation of the question. You have forced me to rethink the way I answer questions in general.

jfriedman 17-Feb-11 17:38pm View
Reason for my vote of 1
Because you are trying to appear as if you know what you are doing. This maybe would have been valid about 20 years ago in c and still might hold true for a unoptomized C compiler however for .Net you clearly display you lack of understanding of the CLR.
jfriedman 17-Feb-11 17:30pm View
Dr. Abell,

Please stop.

You are just causing stack overflows and wasting cycles with your code

We appreciate your post, your comments have been summarily noted and dually overruled.

Thank you for yout time.
jfriedman 15-Feb-11 10:03am View
Dr.Abell, int is a value type which can never be null. The bit work you perform with AND and OR and the multiple branches of the code result is a less optimzed function call which utilizes more stack space. These are the hard facts of the matter.

Thank you for your article.

jfriedman 15-Feb-11 5:25am View
1.) You are claiming that if both numbers are equal the Euclid part does not need to be run however I am arguing that rather than performing a binary AND followed by a jump if equal or just the jump if equal call you just perform the modulo which will result in a single operation and get the required result which will be much easier for the JITTER to optimize due to less possible branches of code paths to evaluate.
2.) I did not write alternate 1 so I do not care to make points about it.
3.) I have also made this discovery when working on a brain teaser at my work.
4.) Due to recursive calling there is more stack space utilized in your function call.
jfriedman 14-Feb-11 16:37pm View
I am not sure how correct your assertation is... I dont' use var once. I accept the point about the two numbers being the same but I would like to see how that realtes to the problem mathematically. E.g. so what if I pass 1,1? is this not the point of the algorithm...
jfriedman 8-Feb-11 18:48pm View
How this classifies as a "Article" is beyond me.... Totally beyond me.

Fortunately I watched Bambi as a child and I took away a valuable lesson, "If you don't have anything nice to say don't say anything at all".

I guess for people who are new to programming this is very helpful... Good Job!
jfriedman 20-Jan-11 18:19pm View
Should we not be using ++i (prefix) to prevent the overhead of the temporary copy of the variable which occurs when you use the postfix increment operator?
jfriedman 2-Jan-11 18:17pm View
Even without unsafe there is no denying that the methods I have shown here and have been shown by others are more efficient then the posted methods... Unsafe code will only marginally increase the performance anyhow. Thank you for the readability edits.
jfriedman 16-Dec-10 15:22pm View
Dooper Super
jfriedman 2-Dec-10 13:36pm View
Manipulates i, thus losing the origional value. What is i's value is needed later?
jfriedman 2-Dec-10 13:35pm View
The only joke about this is that since there are only 2 viable states for a bool You can manipulate circuit based on conditionals and you only need the iif... Whats funny about that :p
jfriedman 16-Sep-10 15:11pm View
Your code wont compile... You return false without assigning to the result variable. You probably meant:

else return result = false;
jfriedman 13-Aug-10 16:30pm View
Thank you for clarifying however...

Whitespace variants can be matched with a RegEx and are outside the scope of the name of the functions which implies Whitespace not WhiteSpace Variants...

The name of the function is not IsNullOrWhitespaceOrNewLineorTabOrSomeOtherCharacterWhichTakes0Space()
jfriedman 12-Aug-10 12:19pm View
Reason for my vote of 5
Because its just a fast and does the same thing! (Obviously Sarcastic)