|
Can i quote you in my skype please ?
Microsoft ... the only place where VARIANT_TRUE != true
|
|
|
|
|
It's nice when developers know more than just how to copy and paste and tweak code. It's nice when they actually know how the computer works.
Nice quick thinking.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
Application startup creates a
SqlConnection for each database it uses, and opens it, and this is then passed as a parameter from one module to the next for the lifetime of the application....to save the time opening and closing the connection.
|
|
|
|
|
See, I told you already. With smart programmers like this, we don't need connection pooling.
|
|
|
|
|
This is actually valid in certain, rather unusual circumstances (e.g. a networked database running an old engine or configured such that it doesn't pool connections from different processes). But it's almost guaranteed that the coder just didn't know what he was doing ...
|
|
|
|
|
..actually connection pooling is enabled and on (because we are using the ADO.NET client for SQL Server it is on by default and set to a pool size of 100 conenctions). The code is just not using it.
|
|
|
|
|
Duncan Edwards Jones wrote: Conscious perma-coupling for the lifetime Maybe an author of the idea couldn't find a proper woman, and wanted to make it up by designing a "couply" system... Maybe he should break up with Anna.avi and get merried.
|
|
|
|
|
A RichTextBox has an Rtf property, and a SelectedRtf property.
Even when all text is selected, their values differ.
Just try:
string rtf1 = richTextBox1.Rtf;
richTextBox1.SelectAll();
string rtf2 = richTextBox1.SelectedRtf;
System.Diagnostics.Debug.Assert(rtf1 == rtf2);
|
|
|
|
|
|
No, it does not. By the way, this is the Weird and Wonderful , or Coding Horrors forum - I really intended to place it here, because it is quite a WTF, and I do not expect a sensible answer for it (OK, if you know it, let me here it).
It rather looks like a philisophical design decision: since Rtf is always longer than SelectedRtf , the whole is more than the sum of its parts...
|
|
|
|
|
Try this test to get a better Idea.
Create a test project with a richtextbox and a normal text box.
two buttons and a label to show the length
In VB.net it would look like.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim selLen As Integer
Dim selectedRtf As String = RichTextBox1.SelectedRtf
selLen = selectedRtf.Length
Label1.Text = selLen.ToString
TextBox1.Text = selectedRtf
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim selLen As Integer
Dim selectedRtf As String = RichTextBox1.Rtf
selLen = selectedRtf.Length
Label1.Text = selLen.ToString
TextBox1.Text = selectedRtf
End Sub
Using a converter to convert to C# it would look like this.
private void Button1_Click(System.Object sender, System.EventArgs e)
{
int selLen = 0;
string selectedRtf = RichTextBox1.SelectedRtf;
selLen = selectedRtf.Length;
Label1.Text = selLen.ToString;
TextBox1.Text = selectedRtf;
}
private void Button2_Click(System.Object sender, System.EventArgs e)
{
int selLen = 0;
string selectedRtf = RichTextBox1.Rtf;
selLen = selectedRtf.Length;
Label1.Text = selLen.ToString;
TextBox1.Text = selectedRtf;
}
Next create some text in wordpad with different formating. Copy paste to the richtextbox (ctl+V)
what this code does is gets the length of the string, the entire string with the hidden formating and copies it to the plain textbox to view all of it.
You can add the line to select all or just select it on the RTF box.
After going back and forth between the buttons you may notice that the second one shows more formatting and thus it is longer.
|
|
|
|
|
I'm not certain, but suspect it is due to the fact that an RTF document contains various sections in addition to the formatting codes needed. Here's one version of the spec: RTF 1.7[^] (not the latest, but most should be similar).
A bit like copying HTML to clipboard - if just the markup is copied, other information supplied in the header section may be omitted, so styles etc. wouldn't work correctly. The SelectedText may contain just enough of these for the selection, while the Rtf property will, presumably, include all those in the entire RTF "document" including standard "document level" header sections (a bit like the <head> section in HTML).
"If you don't fail at least 90 percent of the time, you're not aiming high enough."
Alan Kay.
|
|
|
|
|
Agree.
|
|
|
|
|
Sometimes I have the impression to work for Augeas[^] Stables Inc, but actually I am expected to produce more dung than to get rid of it...
In the 13395 lines of code of the main window of one of our applications, I found this little gem (really little - only 320 loc) whose functionality I'll need in a new application (a little anonymized):
private void DoSomething()
{
...
#region do X
...
#endregion
#region do Y
...
#endregion
#region do Z
...
#endregion
#region do A
...
#endregion
#region do B
if (some condition)
{
#region do C
...
#endregion
}
else
{
#region do D
...
#endregion
}
#endregion
...
#region do E
try
{
switch (some swicth)
{
#region do F
case ...
break;
#endregion
#region do G
case ...
break;
#endregion
#region do H
case ...
break;
#endregion
#region do I
case ...
break;
#endregion
}
...
#endregion
}
Of course with some extra try...catch inside the regions or other try...catch.
Well, at least, it looks like the functionality I need to transfer to the new application is - with the exception of some member variables - in that one single function, and not scattered all over the class...
"Have you heard of 'Clean Code' by Robert C. Martin? You can download it from the web", said the guy who uses to write such functions.
|
|
|
|
|
#region wow
Console.Writeline("Wow!");
#endregion
|
|
|
|
|
It's a form of modular code: each module goes in it's own region so you don't get the visual clutter associated with methods...
Find a new job! Life is too short...
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
Why? In order to get experience with even more styles of WTF used in those different places?
|
|
|
|
|
So you're saying "better the crap you know"?
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
I'm guessing it's a regional issue.
What do you get when you cross a joke with a rhetorical question?
|
|
|
|
|
I guess stupidity is not regional, it's universal
|
|
|
|
|
To write that and then quote Clean Code is a special level of genius!
|
|
|
|
|
If a little of something is good, then a whole lot of it must be better, right?
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
|
Bernhard Hiller wrote: In the 13395 lines of code of the main window
Bernhard Hiller wrote: In the 13395 lines of code
Bernhard Hiller wrote: 13395
What?
|
|
|
|
|
That's clean code, isn't it?
|
|
|
|