Programming's Foul Language
-
Unless you're suggesting replacing it with a new keyword eg
singlefile
that does the opposite I'm strongly opposed because it means I don't have any mandatory information about if a class is fully contained in a single file or if it's got implementation spread among several. If you are suggestingsinglefile
instead ofpartial
then I disagree because you're changing the implicit behavior of legacy code. The only change I'd make would be to add a warning if there was *not* a second instance of a partial class eg if you ooopsed and only renamed/renamespaced the class in one of the files instead of all of them.The European Way of War: Blow your own continent up. The American Way of War: Go over and help them.
dan neely wrote:
a new keyword eg singlefile
No.
dan neely wrote:
if a class is fully contained in a single file or if it's got implementation spread among several
I don't need that information. And it doesn't tell you which other files anyway so I don't see the benefit. The main thing is, I may post some code here and someone may want to add something to it for their own purposes. If I include partial (even though my code doesn't need it), they don't have to touch my file. If I leave off partial, they have to add it even though they're using partial in an effort to not alter my file. Partial classes enable such easy additions to code, but the
partial
keyword hinders that ease. All classes should be partial without needing a new keyword. -
dan neely wrote:
a new keyword eg singlefile
No.
dan neely wrote:
if a class is fully contained in a single file or if it's got implementation spread among several
I don't need that information. And it doesn't tell you which other files anyway so I don't see the benefit. The main thing is, I may post some code here and someone may want to add something to it for their own purposes. If I include partial (even though my code doesn't need it), they don't have to touch my file. If I leave off partial, they have to add it even though they're using partial in an effort to not alter my file. Partial classes enable such easy additions to code, but the
partial
keyword hinders that ease. All classes should be partial without needing a new keyword.PIEBALDconsult wrote:
I don't need that information. And it doesn't tell you which other files anyway so I don't see the benefit.
I disagree about it's utility; and while I'll admit that's annoying and an obvious place for intellisence improvement, but having to search for
partial class MyClass
with a partial class to find the rest of it is less of a hassle than having to search forclass MyClass
with every class to find out if it's partial or not.PIEBALDconsult wrote:
The main thing is, I may post some code here and someone may want to add something to it for their own purposes. If I include partial (even though my code doesn't need it), they don't have to touch my file.
Within my codebase; if anything I see this as a feature since the changelog for my class will indicate that it's no longer contained in a single file. If anything I think the weakness is that adding a 3rd+ partial class file doesn't do anything to obviously indicate that the class has changed in the repositories history. So far it's never been an issue for me since I've only used partial to isolate my code from code autogenerated by a tool/designer of some sort.
The European Way of War: Blow your own continent up. The American Way of War: Go over and help them.
-
goto can actually be useful (if used extremely sparingly - so sparingly that I haven't used it in over 10 years!) One example where goto is very helpful is in programming an efficient state-machine. Oh, I know you can do it without gotos by using functions and/or block escapes, but the goto is much more efficient -- and, in the case of a state-machine, actually HELPS understanding of what is going on.... FWIW (getting ready for all the thumbs-down).
Since I barely knew Dartmouth Basic when I started designing state machines for hardware controllers i didn't know there was anything like "goto" or "gosub". In all of the microcontrollers I've ever coded all we had were JMP, CALL, and sometimes SKIP for controlling program flow. Goto and Gosub were all higher level code which had to be interpreted or compiled into code the CPU could understand. I've also made state machines with NO ALU at all and one in particular out of PLD's that had NO compiler at all. I had to design the program flow by burning fuses in the PLD. No memory, no eproms, no disks, no keyboard and no display. Also, mine is bigger than yours. :-) Edwin
-
Microsoft
-
Since I barely knew Dartmouth Basic when I started designing state machines for hardware controllers i didn't know there was anything like "goto" or "gosub". In all of the microcontrollers I've ever coded all we had were JMP, CALL, and sometimes SKIP for controlling program flow. Goto and Gosub were all higher level code which had to be interpreted or compiled into code the CPU could understand. I've also made state machines with NO ALU at all and one in particular out of PLD's that had NO compiler at all. I had to design the program flow by burning fuses in the PLD. No memory, no eproms, no disks, no keyboard and no display. Also, mine is bigger than yours. :-) Edwin
-
throws Exception
,throws MyCustomExceptionWhichWrapsEverything
, and lack of a throws statement; are equally useless at providing meaningful information to the consumer.The European Way of War: Blow your own continent up. The American Way of War: Go over and help them.
Maybe you're getting this confused with C++ - in Java, if a method doesn't have a throws statement, it can't throw anything. You think having a list of exceptions a method can throw is worthless? :~
Cheers, Vikram. (Proud to have finally cracked a CCC!)
-
One defense for the goto I've heard is from people whose programming policies require that functions have a single exit point. Aiming for a single Exit Sub/Function/Return point without goto can easily make for some complex and hard to maintain control paths, often with multiple levels of nested if/then blocks.
Unnecessary if you have try/finally constructs in your language.
-
Maybe you're getting this confused with C++ - in Java, if a method doesn't have a throws statement, it can't throw anything. You think having a list of exceptions a method can throw is worthless? :~
Cheers, Vikram. (Proud to have finally cracked a CCC!)
Vikram A Punathambekar wrote:
Maybe you're getting this confused with C++ - in Java, if a method doesn't have a throws statement, it can't throw anything.
Not quite true - there are checked and unchecked exceptions. (NullPointer exception are unchecked...they can always be thrown)
-
Vikram A Punathambekar wrote:
Maybe you're getting this confused with C++ - in Java, if a method doesn't have a throws statement, it can't throw anything.
Not quite true - there are checked and unchecked exceptions. (NullPointer exception are unchecked...they can always be thrown)
Yes, I know, but we are talking about checked exceptions.
Cheers, Vikram. (Proud to have finally cracked a CCC!)
-
COBOL!
------------------------------------ "When Belly Full, Chin Hit Chest" Confucius 502BC
"alter goto" Variables with two-character names An IT department that makes both of the above mandatory. Yes, I am that old, and the programs I was working on were even older.