4 ms·
It's also really useful to add naming conventions that convey how expensive something is. For example: myObject() // Returns immediately always getMyOb
by e0m 10y ago
It's also really useful to add naming conventions that convey how expensive something is. For example:
myObject() // Returns immediately always
getMyObject() // Might do some light calculation
fetchMyObject() // Doh, better cache this!
Names can be extremely useful to convey expected usage as well.
- icebraining 10y ago+1. Another one I use is "generateX()", usually for heavy calculations like image processing or PDF rendering.
- Kristine1975 10y agoMacOS's Core Foundation API has naming conventions related to object ownership: "create"/"copy" = you own the object returned by the function, you have to release it after you're done with it. "get" = you don't own it. https://developer.apple.com/library/mac/documentation/CoreFoundation/Conceptual/CFMemoryMgmt/Concepts/Ownership.html https://developer.apple.com/library/mac/documentation/CoreFo...