Click here to Skip to main content
15,886,963 members

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
GeneralRe: The changing landscape of OOP (from class to struct) Pin
Chris Baker 202127-Sep-23 8:36
Chris Baker 202127-Sep-23 8:36 
GeneralRe: The changing landscape of OOP (from class to struct) Pin
Jeremy Falcon27-Sep-23 11:58
professionalJeremy Falcon27-Sep-23 11:58 
GeneralRe: The changing landscape of OOP (from class to struct) Pin
k505427-Sep-23 12:20
mvek505427-Sep-23 12:20 
GeneralRe: The changing landscape of OOP (from class to struct) Pin
Jeremy Falcon27-Sep-23 15:14
professionalJeremy Falcon27-Sep-23 15:14 
GeneralRe: The changing landscape of OOP (from class to struct) Pin
trønderen25-Sep-23 8:13
trønderen25-Sep-23 8:13 
GeneralRe: The changing landscape of OOP (from class to struct) Pin
raddevus25-Sep-23 8:29
mvaraddevus25-Sep-23 8:29 
GeneralRe: The changing landscape of OOP (from class to struct) Pin
haughtonomous26-Sep-23 21:53
haughtonomous26-Sep-23 21:53 
GeneralRe: The changing landscape of OOP (from class to struct) Pin
Jon McKee25-Sep-23 10:26
professionalJon McKee25-Sep-23 10:26 
I've been working a lot lately with Spring Webflux/Reactor and they liberally use the Duration class for any time specs.
//so instead of
long ticks
long ms
long s
//etc, etc, you see
Duration t
//and you create values using stuff like
Duration.ofSeconds
Duration.ofMilliseconds

By not obsessing over primitives, they made it so that all methods that use times can accept any time. You don't have to constantly remind yourself what the context for that time value is (e.g. seconds, milliseconds, etc), because the method doesn't specify the context, you do. So I love the idea of better contextualizing values beyond their strict storage type. As long as there's a useful context that adds value.

From your example, I think an Angle abstraction that handled both radians and degrees could prove useful in a similar manner to Duration, for example. As given, I'm not sure abstracting a double to an Angle solely to remove the primitive is a good pattern though. My assumption is that the intention is to force the developer to explicitly contextualize the double value, but the thing is if the developer didn't care about the context before, they aren't going to care now. They'll just wrap the double they have and move on (e.g. ex.handleAngle(new Angle(someDoubleThatIsntAnAngle))). Elevating a primitive in this way doesn't actually achieve anything that variable naming and/or named arguments couldn't already do. Just having a nondescript Angle with a double size property does nothing to further describe a double angle parameter. There has to be more sauce to it to make the abstraction worth it in my opinion.
GeneralRe: The changing landscape of OOP (from class to struct) Pin
raddevus25-Sep-23 10:36
mvaraddevus25-Sep-23 10:36 
GeneralRe: The changing landscape of OOP (from class to struct) Pin
Jeremy Falcon25-Sep-23 12:33
professionalJeremy Falcon25-Sep-23 12:33 
GeneralRe: The changing landscape of OOP (from class to struct) Pin
Jon McKee26-Sep-23 9:53
professionalJon McKee26-Sep-23 9:53 
GeneralRe: The changing landscape of OOP (from class to struct) Pin
Jeremy Falcon25-Sep-23 12:33
professionalJeremy Falcon25-Sep-23 12:33 
GeneralRe: The changing landscape of OOP (from class to struct) Pin
Jon McKee26-Sep-23 9:51
professionalJon McKee26-Sep-23 9:51 
GeneralRe: The changing landscape of OOP (from class to struct) Pin
Jeremy Falcon27-Sep-23 2:36
professionalJeremy Falcon27-Sep-23 2:36 
GeneralRe: The changing landscape of OOP (from class to struct) Pin
Jon McKee28-Sep-23 14:17
professionalJon McKee28-Sep-23 14:17 
GeneralRe: The changing landscape of OOP (from class to struct) Pin
Richard Deeming25-Sep-23 22:02
mveRichard Deeming25-Sep-23 22:02 
GeneralRe: The changing landscape of OOP (from class to struct) Pin
trønderen26-Sep-23 9:31
trønderen26-Sep-23 9:31 
GeneralRe: The changing landscape of OOP (from class to struct) Pin
Jeremy Falcon27-Sep-23 3:17
professionalJeremy Falcon27-Sep-23 3:17 
GeneralRe: The changing landscape of OOP (from class to struct) Pin
RainHat26-Sep-23 0:02
RainHat26-Sep-23 0:02 
GeneralRe: The changing landscape of OOP (from class to struct) Pin
charlieg26-Sep-23 7:42
charlieg26-Sep-23 7:42 
GeneralRe: The changing landscape of OOP (from class to struct) Pin
trønderen26-Sep-23 9:47
trønderen26-Sep-23 9:47 
GeneralRe: The changing landscape of OOP (from class to struct) Pin
Nelek27-Sep-23 9:12
protectorNelek27-Sep-23 9:12 
GeneralRe: The changing landscape of OOP (from class to struct) Pin
haughtonomous26-Sep-23 21:11
haughtonomous26-Sep-23 21:11 
PraiseRe: The changing landscape of OOP (from class to struct) Pin
Jeremy Falcon27-Sep-23 4:17
professionalJeremy Falcon27-Sep-23 4:17 
GeneralRe: The changing landscape of OOP (from class to struct) Pin
Peter Adam26-Sep-23 22:20
professionalPeter Adam26-Sep-23 22:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.