One in which I get to remove a lot of code. Here is a particularly interesting tidbits, SqlStatement is one of the core classes in NH Prof, look what I did to it:
For those of you not used to reading diffs, the orange marking on the side bars are removed lines. It dropped from a 484 lines to 153.
So obviously that means it does 30% less now. Or that you put 30% of the code on one line. Oh, I know ... the curley braces are no longer on their own line! Because, of course, there is no way to get rid of or refactor code.
Sometimes, putting stuff on one line makes the whole more readable. I often use that with properties, to cut down on the curly-braces-porn that's going on in there:
public string Whatever { get { return whatever; } set { whatever = value; } }
public string Whenever { get { return whenever; } set { whenever = value; } }
public string However { get { return however; } set { however = value; } }
Or, if you don't like it like that:
public string Whatever
{
get { return whatever; }
set { whatever = value; }
}
En then continue using proper spacing in the rest of the code. Those properties are SO obvious that you don't really need to space it out over 8 lines.
Either way, I don't think Ayende just removed whitespace, else he wouldn't be so happy with it ;-)
> Email-style angle brackets
> are used for blockquotes.
> > And, they can be nested.
> #### Headers in blockquotes
>
> * You can quote a list.
> * Etc.
Horizontal Rules
Three or more dashes or asterisks:
---
* * *
- - - -
Manual Line Breaks
End a line with two or more spaces:
Roses are red,
Violets are blue.
Fenced Code Blocks
Code blocks delimited by 3 or more backticks or tildas:
```
This is a preformatted
code block
```
Header IDs
Set the id of headings with {#<id>} at end of heading line:
## My Heading {#myheading}
Tables
Fruit |Color
---------|----------
Apples |Red
Pears |Green
Bananas |Yellow
Definition Lists
Term 1
: Definition 1
Term 2
: Definition 2
Footnotes
Body text with a footnote [^1]
[^1]: Footnote text here
Abbreviations
MDD <- will have title
*[MDD]: MarkdownDeep
FUTURE POSTS
Partial writes, IO_Uring and safety - about one day from now
Configuration values & Escape hatches - 5 days from now
What happens when a sparse file allocation fails? - 7 days from now
NTFS has an emergency stash of disk space - 9 days from now
Challenge: Giving file system developer ulcer - 12 days from now
And 4 more posts are pending...
There are posts all the way to Feb 17, 2025
RECENT SERIES
Challenge
(77): 20 Jan 2025 - What does this code do?
Answer
(13): 22 Jan 2025 - What does this code do?
Comments
I tend to say that the best line of code is the one you never wrote, but this is the next best thing.
So obviously that means it does 30% less now. Or that you put 30% of the code on one line. Oh, I know ... the curley braces are no longer on their own line! Because, of course, there is no way to get rid of or refactor code.
BTW: not liking that I have to fire up an alternate browser to IE8 to post comments - not even compat mode works
Oh, and there was a </sarcasm> tag at the end of the first post; but I guess it got eaten.
YUICompressor for CSharp :-)
Clearly this:
class SqlStatement { public string Whatever { get { return whatever; } set { whatever = value; } } private string whatever; ... }
is much better than this:
class SqlStatement {
public string Whatever {
}
private string whatever;
...
}
So did some of the functionality move to other classes or were you really able to remove ~300 lines and maintain similar functionality?
@configurator:
Sometimes, putting stuff on one line makes the whole more readable. I often use that with properties, to cut down on the curly-braces-porn that's going on in there:
public string Whatever { get { return whatever; } set { whatever = value; } }
public string Whenever { get { return whenever; } set { whenever = value; } }
public string However { get { return however; } set { however = value; } }
Or, if you don't like it like that:
public string Whatever
{
get { return whatever; }
set { whatever = value; }
}
En then continue using proper spacing in the rest of the code. Those properties are SO obvious that you don't really need to space it out over 8 lines.
Either way, I don't think Ayende just removed whitespace, else he wouldn't be so happy with it ;-)
Admit it Ayende, you moved 300+ lines of code to static methods in a SqlStatementHelper class? ;-)
Jeremy,
I create a separate class for handling that
Ian,
Almost, it is called SqlStatementProcessor, and it is a command object
Ah, so the refactoring was geting SqlStatement to be more focused. I'm always a big fan of those types of refactorings. :-)
So you didn't just randomly comment lines out and cross your fingers when hitting compile?
I remember going from a prototype to a 'v0.1' the code was about a fifth the size, was faster, easier to program against and was far more extensible..
I don't think thats so uncommon for a prototype to be 'obese' but it was really nice that its evolution was so much smaller and yet tons better.
(usual day for a dev right? I always enjoy that feeling anyway, I do a lap around the office for high fives borat style).
Comment preview