Style Police (a rant)

A

Andreas Leitgeb

Arne Vajhøj said:
I see it otherwise.
But it could be because I have an implicit assumption that
developers hired to maintain code in language Xyz will know
Xyz - mainstream or not mainstream.

Depends if the boss actually allows the original programmer
to program in anything else than Java. He'd have some reason
not to allow it - like the prospects of potentially having to
find a successor programmer able to maintain Xyz programs,
versus the rather easy task of finding a Java programmer...

Otoh., I see some motivation for a programmer to switch to some
Xyz language apart from improved aptness for a task: Making himself
less dispensable...
 
A

Andreas Leitgeb

Wanja Gayk said:
(e-mail address removed) says...
Hm, I can't really say that this is the case. It's just in the past few
years that I'm adopting rather functional paradigms, But using "final"
a lot has hardly anything to do with functional programming in my opinion.

Creating new (final) variables all the way, rather than reusing/overwriting
existing ones appears to me typical for functional paradigms...

Actually that is merely a consequence of FP's avoiding of side effects,
so my reverse assumption (lotsa final's => FP) was no more sound than
concluding a past rain from seeing a wet road - merely a rather safe
bet, but not necessarily always true.
which means I can forget about most of the variables when
analyzing code.

To me, making a reference to a mutable type (like Iterator) final
is rather harmful than good. Ok, the iterator won't be replaced by
another one, but I wouldn't expect that to happen anyway in that
code. The mutable state within the iterator is essentially part
of the mutable state of that piece of code, thus cannot be
"forgotten" during analysis of the code.
The above code is by no means functional, is it?

You're right. Afterall, it didn't contain all that many finals.
That probably wasn't yet the kind of code that would convince one to
have "final" as default and another keyword for non-final variables.
 
A

Andreas Leitgeb

Lew said:
No, it isn't. A variable type of 'List<String>' is entirely reasonable.

Reasonable to write by hand, but not reasonable to have it inferred
from an ArrayList<String>-typed expression. That was the particular
context.

While a *non*-final List<String> typed variable could later be assigned
an instance of LinkedList<String>, a final can't. It hardly ever hurts
to have a final variable carry the most specific subtype. That could
even go as far as (currently impossible/forbidden):

final actor = new Object() { public void foo() { ...; } };
actor.foo();

If it is undesired to carry the specific subtype, then you'd just specify
the type as you do now.
 
A

Andreas Leitgeb

Arne Vajhøj said:
I believe in some cases you just want to read the left side
and then move further down the code.
Having to read the right side to see what type it is
will just make it more difficult (in that case).

That is at least some argument for the current state.

Thanks for mentioning it.
 
R

Retahiv Oopsiscame

There's a way around that, and it's called Clojure. It compiles to JVM
bytecode and has both lazy lists and a special operator for doing tail
recursion (the compiler turns it into an iteration).

*googles*

Bleah!

You could have saved everyone a lot of time if you'd said up front
that it was a fucking Lisp, Cthun. :p
 
A

Andreas Leitgeb

Well, is it?
I have a hard time believing that.

Not sure, what is so hard to believe. Does "handle" mean something
specific to you that isn't compatible with my line?
[...]
final Job jobAnnot=method.getAnnotation(Job.class);
assert jobAnnot != null;
final Schedule lifecycle=jobAnnot.value();
[ ... further code doesn't use jobAnnot ...]

That's about what I meant by "handle".
jobAnnot is merely a handle for the result of method.getAnnotation(...).
It is then used twice (assert and retrieving some value) and then
forgotten. If it weren't for the assert, you might have written:
final Schedule lifecycle= method.getAnnotation(Job.class).value();
(this particular assert seems rather useless anyway, as the NPE would
definitely be thrown, anyway. assert makes more sense, if failure of
the checked condition could otherwise go unnoticed until much later.)

I admit that your coding style isn't really as "functional" as I had
believed it to be from your complaint about so many "final"s...

Most of my code would look quite similar, but I wouldn't bother
adding finals, where the variable is only used in the following two
or three lines of code. I would, however, still care to make those
variables final whose scope contains a complete loop or more than
say 10 lines of code.
 
A

Arne Vajhøj

To me, making a reference to a mutable type (like Iterator) final
is rather harmful than good. Ok, the iterator won't be replaced by
another one, but I wouldn't expect that to happen anyway in that
code. The mutable state within the iterator is essentially part
of the mutable state of that piece of code, thus cannot be
"forgotten" during analysis of the code.

Occasionally C++:
const X * const o
is missed.

Arne
 
A

Arne Vajhøj

I'm afraid the syntax of Scala suits me better - but then again, we were
talking about Java anyway.

Other languages have been mentioned in the thread.

Arne
 
C

Cthun

*googles*

Bleah!

You could have saved everyone a lot of time if you'd said up front
that it was a fucking Lisp, Cthun. :p

And what, pray tell, is wrong with Lisp, Oopsiscame? Let alone *so*
wrong as to be deserving of foul language for emphasis?
 
L

Lars Enderin

Lew skrev. It says right there.

It's short for «Lew skrev ett ganska smarta inlägg.»

(Not quite: s/smarta/smart/.) I sometimes forget to replace the Swedish
word in attributions.
What, you like vi better?

:-0

The nym-shifter gives us hints to his true identity:
Hates Lisp. Hates Emacs. Hates vi.
Who could that be?
 
C

Cthun

frogery alert!!

What does your forgery have to do with Java, murphy?
Really I should cancel my google accounts.

Last time I checked, you don't have any, murphy.

So much for "I'm going away and I'm never coming back", eh, murphy? Liar.
 
A

Arved Sandstrom

Creating new (final) variables all the way, rather than reusing/overwriting
existing ones appears to me typical for functional paradigms...

Actually that is merely a consequence of FP's avoiding of side effects,
so my reverse assumption (lotsa final's => FP) was no more sound than
concluding a past rain from seeing a wet road - merely a rather safe
bet, but not necessarily always true.

I'd think of FP as being primarily the avoidance of mutable program
state. You get that through expression evaluation rather than statement
evaluation. Everything is a value (expression) so functions are
first-class values too.

The real nuance of FP variables is that they are mathematical variables;
just names. In Algol-like languages a variable denotes a storage
location (dispensing with the technicalities of what modern
compilers/interpreters may do). An FP variable simply maps to an
expression; a Java final reference might be to a mutable object, so
definitely not even close to the same thing.
To me, making a reference to a mutable type (like Iterator) final
is rather harmful than good. Ok, the iterator won't be replaced by
another one, but I wouldn't expect that to happen anyway in that
code. The mutable state within the iterator is essentially part
of the mutable state of that piece of code, thus cannot be
"forgotten" during analysis of the code.
[ SNIP ]

I agree: make a reference to a mutable type final and all it does is
foster a false sense of security.

AHS
 
C

Cthun

Cthun said:
What does my forgery have to do with Java, murphy?


As far as I know you don't have any, murphy.

So much for "I'm going away and I'm never coming back", eh, murphy? Liar.


what does murphy have to do with Java, murphy?


you cannot win murphy! I have all these names to use
every time I turn my modem off and on. Just like you told me!


--- . ... ..- ... <[email protected]>
00101010 <[email protected]>
3k7e4intna <[email protected]>
3x+r4v4g4n <[email protected]>
Alice <[email protected]>
Arne Këndoj <[email protected]>
Boojum <[email protected]>
B1ll Gat3s <[email protected]>
Canuck <[email protected]>
Cthun <[email protected]>
Chad Carmichael <[email protected]>
dark-zark-fark <[email protected]>
Deep Green <[email protected]> (forgery)
Deeyana <[email protected]>
De Lurker <[email protected]>
Derek Yancey <[email protected]>
Extravagan <[email protected]>
Ferdinand the -14th <[email protected]>
Fuschia, President-Elect of the Bright Purplish-Green Council <[email protected]>
George Arctos <[email protected]>
Greg Kelly <[email protected]>
Greg Sandoval <[email protected]>
Gheerax IV <[email protected]>
Handkea fumosa <[email protected]>
Hieronymus S. Freely <[email protected]>
Hydrocon <[email protected]>
Henry Harrison <[email protected]>
Henderson <[email protected]>
Heike Svensson <[email protected]>
Harry Greer <[email protected]>
Janie Zanie <[email protected]>
Jerry Gerrone <[email protected]>
John Kirkpatrick XVII <[email protected]>
Katie Gerrolds <[email protected]>
Kevin Hadron <[email protected]>
kensi <[email protected]>
KitKat <[email protected]>
Meerkats <[email protected]> (forgery)
Mister Scott <[email protected]>
Mrs. Danforth <[email protected]>
Mike Faramis <[email protected]>
Mamac <[email protected]>
Nancy 3 <[email protected]>
Nancy 4 <[email protected]> (forgery)
Nebulous <[email protected]>
Nightcrawler <[email protected]>
Nougat Surprise <[email protected]>
Orange Green <[email protected]>
Paul Derbysh!re <[email protected]>
Purpleswandir <[email protected]>
RichB <[email protected]>
(e-mail address removed)
SFTV_troll <[email protected]>
Sulfide Eater <[email protected]>
<supercalifragilisticexpialadiamaticonormalizeringelimatisticantations@averylongandannoyingdomainname.com>
Spock <[email protected]>
Series Expansion <[email protected]>
Seamus MacRae <[email protected]>
Snicker-snack! <[email protected]>
Tim <[email protected]>
Thursday's Leftovers <[email protected]>
thoolen <[email protected]>
thoolen <[email protected]>
thoolen <[email protected]>
<[email protected]>
Willy Wonka <[email protected]>
 
C

Cthun

what does murphy have to do with Java, murphy?

Why are you talking to yourself, you fucking forging liar?
you cannot win murphy! I have all these names to use
every time I turn my modem off and on. Just like you told me!

Yeah, murphy aka phlatArse aka news in service aka Flash(r) aka glyph
aka eye aka Stefan Robacki aka David Liphtmon aka wurm aka FNTS-2011 aka
Yannick Wurm aka who knows how many other nyms.

Why don't you just do as you promised, make like a tree, and leave?
 
C

Cthun

Why are you talking to yourself, you fucking forging liar?

oh dear Boy Paul swore!
god will punish you priest fucker!
Yeah, murphy 0!
aka phlatArse 0!
aka news in service 0!
aka Flash(r) 0!
aka glyph aka eye aka Stefan Robacki aka David Liphtmon aka wurm aka FNTS-2011 aka
Yannick Wurm aka who knows how many other nyms.
hallucinate much?

must have been those 'shrooms from down Binbrook way!
phone a friend for quality 'shrooms!
preferably one on the same planet as you!

shek my names again.
anything else is forgery!

--- . ... ..- ... <[email protected]>
00101010 <[email protected]>
3k7e4intna <[email protected]>
3x+r4v4g4n <[email protected]>
Alice <[email protected]>
Arne Këndoj <[email protected]>
Boojum <[email protected]>
B1ll Gat3s <[email protected]>
Canuck <[email protected]>
Cthun <[email protected]>
Chad Carmichael <[email protected]>
dark-zark-fark <[email protected]>
Deep Green <[email protected]> (forgery)
Deeyana <[email protected]>
De Lurker <[email protected]>
Derek Yancey <[email protected]>
Extravagan <[email protected]>
Ferdinand the -14th <[email protected]>
Fuschia, President-Elect of the Bright Purplish-Green Council <[email protected]>
George Arctos <[email protected]>
Greg Kelly <[email protected]>
Greg Sandoval <[email protected]>
Gheerax IV <[email protected]>
Handkea fumosa <[email protected]>
Hieronymus S. Freely <[email protected]>
Hydrocon <[email protected]>
Henry Harrison <[email protected]>
Henderson <[email protected]>
Heike Svensson <[email protected]>
Harry Greer <[email protected]>
Janie Zanie <[email protected]>
Jerry Gerrone <[email protected]>
John Kirkpatrick XVII <[email protected]>
Katie Gerrolds <[email protected]>
Kevin Hadron <[email protected]>
kensi <[email protected]>
KitKat <[email protected]>
Meerkats <[email protected]> (forgery)
Mister Scott <[email protected]>
Mrs. Danforth <[email protected]>
Mike Faramis <[email protected]>
Mamac <[email protected]>
Nancy 3 <[email protected]>
Nancy 4 <[email protected]> (forgery)
Nebulous <[email protected]>
Nightcrawler <[email protected]>
Nougat Surprise <[email protected]>
Orange Green <[email protected]>
Paul Derbysh!re <[email protected]>
Purpleswandir <[email protected]>
RichB <[email protected]>
(e-mail address removed)
SFTV_troll <[email protected]>
Sulfide Eater <[email protected]>
<supercalifragilisticexpialadiamaticonormalizeringelimatisticantations@averylongandannoyingdomainname.com>
Spock <[email protected]>
Series Expansion <[email protected]>
Seamus MacRae <[email protected]>
Snicker-snack! <[email protected]>
Tim <[email protected]>
Thursday's Leftovers <[email protected]>
thoolen <[email protected]>
thoolen <[email protected]>
thoolen <[email protected]>
<[email protected]>
Willy Wonka <[email protected]>

got fries to go. I am so clever!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,815
Latest member
treekmostly22

Latest Threads

Top