|
We could wish them not to sink.
"Five fruits and vegetables a day? What a joke!
Personally, after the third watermelon, I'm full."
|
|
|
|
|
Is it really lightweight, or "JetBrains lightweight"?
|
|
|
|
|
Forget about the toasters, for there is a new frontier in Doom trivia: training up rodents to wander its mazes and blow away imps. Oh sure, teach them how to run mazes and kill people. What could go wrong?
|
|
|
|
|
The analyst firm, IDC, has said that classical computing will run out of steam over the next decade as quantum computing comes to the fore. Does this mean we're entering the romantic period of computing?
|
|
|
|
|
Neowin wrote: IDC, a firm with too much venture capital and too little brains, has said that classical computing will run out of steam over the next decade as quantum computing comes to the fore. Someone with more brains says that databases will still run on classical computers and keep the world running long after IDC runs out of money.
|
|
|
|
|
I thought that we were in the Baroque period.
Freedom is the freedom to say that two plus two make four. If that is granted, all else follows.
-- 6079 Smith W.
|
|
|
|
|
Almost every software engineer fights a never-ending fight: we strive to make our codebase simpler and thus more readable every day. If you don't guard your clauses, who knows what may happen to them
Yeah, very lame. It's Sunday, and my brain isn't working right now.
|
|
|
|
|
Guard clauses cause clustering complexity collapse. Claus that's the way they roll!
:rimshot: - followed by deathly silence.
|
|
|
|
|
It's brief and recommends putting guards in their own if statements. It will trigger those who cleave to the shibboleth that a function should only have one return statement.
|
|
|
|
|
I cleave to that shibboleth.
".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
|
|
|
|
|
Agreed.
Software Zen: delete this;
|
|
|
|
|
Like PC-Lint and MISRA standards.
GCS d--(d-) s-/++ a C++++ U+++ P- L+@ E-- W++ N+ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t+ 5? X R+++ tv-- b+(+++) DI+++ D++ G e++ h--- r+++ y+++* Weapons extension: ma- k++ F+2 X
|
|
|
|
|
Quis custodes custodit?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
A completely stupid idea. It adds a thrown exception that functions solely as a goto .
Software Zen: delete this;
|
|
|
|
|
At least with a GOTO you can get back to where you were - much more difficult with exceptions.
TTFN - Kent
|
|
|
|
|
True, but then I'm a purist. I haven't used a goto statement in over 20 years. I will admit I use break and continue , but they are 'structured' to my way of thinking.
Software Zen: delete this;
|
|
|
|
|
Did I miss something?
An exception is more than a goto , because it can jump outside of the current scope. This is very useful for aborting work that has run into a serious error, when it is appropriate to exit a chain of function calls and recover from a known point well down the stack. That's actually the only thing I use exceptions for. In most cases, such as a bad argument, the function should simply return a failure result instead.
EDIT: It looks like the code could well be overusing exceptions when returning a failure result would be more appropriate, so that's probably what I missed.
|
|
|
|
|
The 'guard' code from the article was this:
fun guard() {
if (!condition1) {
throw Exception1()
}
doThings1()
if (!condition2) {
throw Exception2()
}
doThings2()
if (!condition3) {
throw Exception3()
}
doThings3()
} This call needs to be surrounded by a try...catch in order to exactly reproduce the functionality of the original. I'm not sure which language is used for the original code; I think it may be Javascript, but the fun keyword is odd.
In any case, throwing an exception in lieu of nested conditionals or a goto is overly complicated and error-inducing. Imagine debugging this sort of nonsense when the catch misses one of the exceptions thrown.
Software Zen: delete this;
|
|
|
|
|
It's so sad that other programmers that I may end up working with at some point read that drivel and adopt it.
|
|
|
|
|
Freedom is the freedom to say that two plus two make four. If that is granted, all else follows.
-- 6079 Smith W.
|
|
|
|
|
Hi Marc, Perhaps my memory is flawed, but, I seem to recall eyeballing code of yours that used preventive filters in this way.
I'd appreciate your comments on my post below !
«The mind is not a vessel to be filled but a fire to be kindled» Plutarch
modified 30-Nov-21 0:13am.
|
|
|
|
|
I believe in anticipating/handling errors in parameter data before you get to the juicy parts, and I think guard clauses are a good example of a strategy for that. I also think liberal use of Try/Catch for things like file-ops is a good thing.
Guard clauses' "virtual isolation" at the start of a method is, imho, "separation of concerns." You can easily comment them out, remove them, as conditions/state management require.
However, there are other strategies.
What I'd like to see is a radical extension of Attributes in C# that do AOP-like transformations, and, internally generate the equivalent of guard clauses: there's already an example of that in the semantics of the Nullable attributes: [^].
A "wedding" of unit-tests and attributes
«The mind is not a vessel to be filled but a fire to be kindled» Plutarch
|
|
|
|
|
BillWoodruff wrote: What I'd like to see is a radical extension of Attributes in C# You always did strike me as a radical!
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
The breakthrough compresses light into a nano-scale spot. "Mama's got a squeeze box, Daddy never sleeps at night"
|
|
|
|
|
The Joy of Cryptography is a free undergraduate textbook that introduces students to the fundamentals of provable security. One of these things is not like the other
|
|
|
|