|
On really busy/complex forms, I make heavy use of partial classes, separating constructors, event handlers, and helper methods. On objects, I do the same thing when something complex is a viably separate concern. I try to keep line counts to less that 1000 where practical.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
#realJSOP wrote: On really busy/complex forms, I make heavy use of partial classes, separating constructors, event handlers, and helper methods. On objects, I do the same thing when something complex is a viably separate concern. I try to keep line counts to less that 1000 where practical.
«One day it will have to be officially admitted that what we have christened reality is an even greater illusion than the world of dreams.» Salvador Dali
|
|
|
|
|
Been there, done that, I feel your pain.
|
|
|
|
|
If I am paid per file I create, then 1 line per file.
If I am paid by size of file, everything in one file with a novel about my life in comments.
If I am paid to write a decent piece of code, then whatever makes logical sense.
"It is easy to decipher extraterrestrial signals after deciphering Javascript and VB6 themselves.", ISanti[ ^]
|
|
|
|
|
First place I worked at had a huge codebase, where files between 100k-200k lines were the rule, rather than the exception. And no, that's not a typo, I'm talking six figures line count - and with pretty much no comments that could take up space.
This was code that, before my time there, went through at least two translations from different programming languages, done by automated tools and only touched up where it broke after that.
I don't know if it was a direct consequence, but there were also a lot of constructs like
function a(x, y)
{
return b(x, y);
}
function b(x, y)
{
return c(x, y);
}
function c(x, y)
{
return d(x, y);
}
function d(x, y)
{
return mysteriousStuff;
}
which added some, but not all of the length.
There's a *lot* more there I could rant about, but I'll stick to unnecessary length. Suffice it to say, there's a reason that a) I went somewhere else and b) the company apparently doesn't exist anymore.
|
|
|
|
|
The largest file I've ever encountered was 32,000 lines. The true horror was that it was a partial class extension with nothing but ONE method that implemented a giant switch statement. Yes, a 32,000 line switch statement. 32,000 lines!
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
how many cases within the switch?
|
|
|
|
|
It was years ago, and I never counted, but "hundreds" comes to mind. There were a handful with 300-500 lines.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
Same issue faced me mine win-forms cs file has 33k lines of code. It is a nightmare to work on it, anything here and there whole form breaks down.
|
|
|
|
|
I converted the government CCDA XML spec into a C# class. Over a quarter million lines of C# code with classes of classes of classes...yet I did figure it out and VS could actually handle it.
|
|
|
|
|
Arbitrary rules are arbitrary. There is no maximum file size. If "huge" it what it takes to get the job done, then huge it is--as long as everything logically goes together.
That's really what the notion of "some max file size" is trying to encapsulate--if you have huge files, it's likely that you've crossed some logical boundaries.
By breaking things into a bunch of smaller files, you have systematic complexity which needs to be managed.
There is no hard-and-fast rule. It's really around trying to define functional areas (tiers), and trying to ensure that code in each tier 'fits' there.
That being said, from your description, it sounds as if refactoring is in order to separate the concerns a bit.
For example, each tab might be represented by a control. Simplify the main form just to be a controller of each sub-control, showing/hiding the right thing(s) based on selected tab.
Then, you might want to add a data-access tier, etc, etc.
I imagine your co-workers will then complain about "how hard it is to follow", having to talk to some factory-type method to execute SQL instead of directly querying/executing. Sigh.
|
|
|
|
|
A function should never be taller than my screen (~100 lines). Other than that, there's no real need to set these arbitrary numbers. SLOC can be indicative of an issue, but it's not an issue in and of itself.
if a lot of repetition was required
Repetition is never required.
|
|
|
|
|
Asday wrote: Repetition is never required.
You can say that again.
|
|
|
|
|
You need to cease.
Especially seeing as that email notification somehow got to me twice.
|
|
|
|
|
I agree with the "size is arbitrary" view. My beef is that large files tend to collect multiple sets of application work. On a project with multiple developers, it becomes difficult to manage everyone pounding on the same source code. True, today's version control systems make it easier to merge, but my preference is break up the processing logically (into separate files) which aids in tracking changes through the system.
Charlie Gilley
<italic>Stuck in a dysfunctional matrix from which I must escape...
"Where liberty dwells, there is my country." B. Franklin, 1783
“They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759
|
|
|
|
|
|
Hi All,
I spent most of yesterday changing account details after some scally tried to use my account to buy some phone screens. I think I have update my account... to use the non dodgy one!
Could someone reply to this message...
|
|
|
|
|
Hello. Someone here.
|
|
|
|
|
And someone else.
But .. I'm not replying for security reasons.
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
|
I can neither confirm nor deny that I got this.
But I did get a message, an email, and a notification with your name on.
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Dear sucker customer,
This is the Amazon accounts team, and definitely not a scally.
In order to process your refund request, please write your bank account details, PIN, and passport number on the back of a postcard, and send it to:
General Sani Abacha
Totally Amazon Dot Com And Definitely Not Scallies Inc
419 Letsbe Avenue,
Scamtown,
Crooksville
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Nuts, not working, I'll get to it tomorrow!
|
|
|
|
|
Do shoes eat sole food?
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Ok, that's it I'm putting my foot down someone needs to explain the missing sock conundrum.
|
|
|
|
|