3 ms·
There are lots of usecases where the things you mention are either not important or outright bad. My code also allows for extra data processing steps in betwee
by yellowapple 7y ago
There are lots of usecases where the things you mention are either not important or outright bad. My code also allows for extra data processing steps in between should the use case evolve beyond mere copying.
The code above could, however, just deal with references to some file handle and not actually read or write the contents (though ReadFile() or WriteFile() would be less-than-ideal names for such functionality).
- kedean 7y agoThat completely ignores the purpose of the abstraction. Copy is a high level concept that, yes, can sometimes be reduced to a read/write pipeline, but in many cases cannot. Interfaces and abstractions are important concepts that you shouldn't naively discard. You're also focusing too much on the example, and missing the greater problem. There are other cases that fit the original problem, such a sending an email (who is the sender and who is the receiver?)
- yellowapple 7y ago> Copy is a high level concept My point is that the high-level concept is not always appropriate. Sometimes it's overkill. Sometimes it's outright wrong. > sending an email (who is the sender and who is the receiver?) The sender is already encoded in the message itself in that case. The receiver is specified as a specific SMTP message, last I checked. So this problem wouldn't really apply here. Even if it did, though, the separated functions would still be useful here: msg = NewMessageFrom("sheev.palpatine@senate.gov") AddSubject(msg, "Did you ever hear the tragedy of Darth Plagueis the Wise?") AddBody(msg, "I thought not. It's not a story the Jedi would tell you.") Send(msg, "anakin.skywalker@jedi.mil")