4 ms·
a bigger culprit is a lack of first-class functions. Objects in Java basically exist to be structs and to hold onto methods.
by rtpg 11y ago
a bigger culprit is a lack of first-class functions. Objects in Java basically exist to be structs and to hold onto methods.
- Chris2048 11y agoIn my early days - I once found a Tuple library for Java, and added it to the codebase. Senior devs soon instructed me to remove it - Back to a multitude of container objects...
- gravypod 11y agoWouldn't using a tuple in Java be like using inserting things into a Object[] and pulling them back out casting to the object you want to use? What library was this?
- Chris2048 11y agohttp://www.javatuples.org/ http://www.javatuples.org/
- V-2 11y agoHard to say without knowing more context, but they could have been right. Personally I'd prefer clearly named, domain-specific container objects with adequately named properties than having to deal with "anonymous" Tuples all over the codebase, and being forced to remember what the first element was, what the second one was etc.
- Chris2048 11y agoWhat makes a container object domain-specific? If I just have to pass data through the application, the anonymity may be appropriate.
- jaggederest 11y agoIf you look at the history of object orientation, it starts as slots for function pointers in structs in C, with some preprocessor statements to make it easier to use. Literally the object is just a struct which holds data and function pointers. Pretty interesting when you think about it - java hasn't moved that conceptually far from C preprocessor statements.
- reycharles 11y agoC++ isn't the start of object orientation.
- sklogic 11y ago> it starts as slots for function pointers in structs in C It was built around lambdas in Smalltalk long before that. Simula (about 4 years older) had a more typical class-based OO with vtables and a proper subtyping already. Long before any C.