• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

Have you ever added the comment 'Very Cool' to your own code?

 
Ranch Hand
Posts: 974
11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you ever added the comment 'Very Cool' to your own code? And is there maybe also an idea that you can overuse generics? I know there is a programming paradigm that says containment is preferred over inheritance. The reason is that inheritance can make extensive layers of descendants and ancestors, and you do not know anymore what the effects will be in changing a class in the top of the tree.

Now, I working with a guy here that in my opinion does something like that with generics. And even worse, I have just read a piece of code he has written, which took me ~~ five minutes to understand, and which he has commentated himself as: // very cool!!!

Is there something that says you can overuse generics when not necessary, or is it me that has to catch up with the latest technologies. Or probably more likely both. Nevertheless, reading his very cool comment he has made to his own code made me somewhat depressed this morning.
 
Ranch Hand
Posts: 10192
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Would you mind posting that piece of "Very Cool" code?
 
Bartender
Posts: 1952
7
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Seen as generics were introduced in SE 5 around 10 years ago, I hardly think 'catching up to the latest technologies' applies here
 
Sheriff
Posts: 4720
309
IntelliJ IDE Python Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Jan de Boer wrote:Have you ever added the comment 'Very Cool' to your own code?

Never, for fear of ridicule by my colleagues. Guaranteed to attract the attention of The Crab.

Jan de Boer wrote:is there maybe also an idea that you can overuse generics?

Absolutely yes. A colleague and I spent a good deal of time earlier this year undoing a bunch of unnecessary generics in some legacy code. It wasn't pretty. I reckon the author of that code had just learned about Generics and wanted to have a play with it, regardless of whether it was the right design or not.
 
Jan de Boer
Ranch Hand
Posts: 974
11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Jelle Klap wrote:Seen as generics were introduced in SE 5 around 10 years ago, I hardly think 'catching up to the latest technologies' applies here



Right, right, even passed the exam on it with high score. Make that: is it me being too stupid to understand his cunning code.
 
Jan de Boer
Ranch Hand
Posts: 974
11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Tim Cooke wrote:Absolutely yes. A colleague and I spent a good deal of time earlier this year undoing a bunch of unnecessary generics in some legacy code. It wasn't pretty. I reckon the author of that code had just learned about Generics and wanted to have a play with it, regardless of whether it was the right design or not.



Yes. The guy is very smart, but sometimes I have the idea he wants to show off and demonstrate he can use something, like in this case generics . Even when it has no use, and only makes things more complicated. I am tempted to change his comment to something now, something funny, don't what yet. Can you think of something? But I will just ask him to explain what he wanted to do with the code, that is more effective of course. Not polite teasing colleagues by comments in the source code.
 
Tim Cooke
Sheriff
Posts: 4720
309
IntelliJ IDE Python Java Linux
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Using something when it has no use doesn't sound very smart to me.

I wouldn't recommend exchanging snarky comments in the code. It doesn't help to build a lasting relationship with that person. If you have a genuine concern, and readability and maintainability qualifies as a genuine concern, then consider discussing it as part of a code review.
 
Jan de Boer
Ranch Hand
Posts: 974
11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes. I completely agree with you there Tim. I wont do that. Dont worry, I am not that dumb to start flame wars through the code base.

Added: It was actually the very thing I did, just ask him what the code was about. The last thing I would do is communicate through the code base to a person sitting next to me. We had an informative chat. Like said, he knows about stuff too. I just thought the comment was remarkable.
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Jan de Boer wrote:Have you ever added the comment 'Very Cool' to your own code?


I've written code that I was proud of, that was ingenious and very good. But I don't add "Very Cool" in the comments in my code.

Jan de Boer wrote:And is there maybe also an idea that you can overuse generics?


Almost any language feature can be overused or misused. Years ago I worked on a project and one of my colleagues had just discovered generics. He thought it was a great idea to make everything generic, so he started refactoring (or maybe, ref*cktoring) classes, and we ended up with classes with 7 type parameters for no good reason at all.

Good code is simple code, which does what it needs to do and nothing more, in an efficient way, which is extensible and flexible in the right way (this is often one of the most difficult aspects of writing good code, because often you don't know in advance in which way it needs to be extensible).

Trying to make code ultra-extensible, ultra-flexible and ultra-generic makes it much more complicated than necessary.
 
lowercase baba
Posts: 12792
51
Chrome Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
isn't a "very cool" comment similar to a "end of for loop" comment?

If it is true, then it is obvious and un-necessary, and simply clutters up the code. If it is not true, then it does nothing but confuses the reader who can't help but think (even if just for a moment) "am I missing something?"
 
Jan de Boer
Ranch Hand
Posts: 974
11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Jesper de Jong wrote:we ended up with classes with 7 type parameters for no good reason at all.



We are refacturing too and we got classes with 4 type parameters that implement 5 different interfaces, and have 6, 7 layer deep inheritance trees.

Jesper de Jong wrote:Trying to make code ultra-extensible, ultra-flexible and ultra-generic makes it much more complicated than necessary.



Well I thought our old cold at some point was more readable, although it were more source code files. The counter argument is that if you do it generic you can do it one time right for all classes implemented by the generic class' functionality. But at this moment, I honestly think we are overdoing it. I am not that fanatic in trying to make everything generic, if it works it works. If it causes performance problems, if it is something used more than five-six times, then I will think about rewriting it. But not to...well, tap myself on the back and write very cool as comment to my own cunning tricks.

On the other hand, there are smart and good ideas implemented in the new code too, but as always, it is not black and white. Trying yet to make another thing generic that is used twice, that is going over the top indeed. The thing is though, if I try to say that, I got a sort of comment like, exaggerating, 'you are too stupid for my smart programming skills'.
 
Tim Cooke
Sheriff
Posts: 4720
309
IntelliJ IDE Python Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Jan de Boer wrote:'you are too stupid for my smart programming skills'.


Sometimes the 'lone wolf' style genius can be just as damaging to a development team as incompetence.
 
Marshal
Posts: 67340
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Tim Cooke wrote:

Jan de Boer wrote:'you are too stupid for my smart programming skills'.


Sometimes the 'lone wolf' style genius can be just as damaging to a development team as incompetence.


I'd personally say that "sometimes" is too mild a word; I'd say "almost always".
 
Jan de Boer
Ranch Hand
Posts: 974
11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Bear Bibeault wrote:

Tim Cooke wrote:

Jan de Boer wrote:'you are too stupid for my smart programming skills'.


Sometimes the 'lone wolf' style genius can be just as damaging to a development team as incompetence.


I'd personally say that "sometimes" is too mild a word; I'd say "almost always".




It is like this, I am here with one other guy close to retirement and the young genius. My contract is not getting renewed, the other guy will soon retire I think, so the 'lone wolf' can do everything by himself pretty soon if he wants to. There is of course the, 'what if he runs under a tram', situation, where probably a programmer taking over his job after he is gone would have the same problems as I do. But the fact is, we are really small, we will soon have only one programmer doing PC software, hence the situation is rather good for someone who wants to have all the code in his own hands. He would be the development team.

 
For my next trick, I'll need the help of a tiny ad ...
Sauce Labs - World's Largest Continuous Testing Cloud for Websites and Mobile Apps
https://coderanch.com/t/722574/Sauce-Labs-World-Largest-Continuous
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!