6 ms·
Isn't also limiting the potentially boundless array of (mostly irrelevant) functions to relevant data types also relevant? I'd venture to say it is. Ooooh... t
by oblio 12y ago
Isn't also limiting the potentially boundless array of (mostly irrelevant) functions to relevant data types also relevant? I'd venture to say it is.
Ooooh... that's a Point object - no way the AddAccount function does anything relevant with it! In OO you don't even actually need to think that since Point has a limited set of methods.
- deleted 12y ago[deleted]
- sbov 12y agoI'd be willing to bet that the Point object in any given language is going to have more methods that take it as an argument than methods the class itself has.
- oblio 12y agoTrue. But I still go looking for the "Point" class first. Then I start looking for things which accept "Point" parameters. Big difference from procedural programming languages.
- colanderman 12y agoIn C, I look in "point.h" first, then start looking for other things. Not really different.
- hrjet 12y agoA natural way to separate those two types of methods is: * methods that do something *to* a Point object * methods that do something *with* a Point object The former are better to be declared inside the Point object so that they have access to internal state. The latter shouldn't typically access internal state of the Point object. This separation can help immensely while analyzing a code base.
- colanderman 12y agoThis applies to any language with static types. Or that allows code to be separated in multiple files, for that matter. In Haskell, I can literally ask the editor to list me all functions that operate on type X. Even in C written with a modicum of coding discipline, 90% of the functions relevant to type X will be defined in X.h, wherein 100% of the functions in X.h are relevant to type X. (And the 10% of functions relevant to type X that aren't in X.h? Well, in Java, they also wouldn't be part of class X anyway.)