4 ms·
Several of these are generally applicable to programming: * Keep functions small and composable * Keep functions at a consistent level of abstraction * Use c
by atrk 13y ago
Several of these are generally applicable to programming:
* Keep functions small and composable
* Keep functions at a consistent level of abstraction
* Use constructors to ensure objects always exist in a complete, usable state
* Use meaningful method names in place of comments
It is nice to see that other people struggle with functions with lots of parameters + lots of partial state variables. I don't suppose anyone here has a better solution?
- collyw 13y agoComments should explain why you are doing something while method names are a guide to what they are doing. I see them as for different purposes and one should not replace the other.
- mercurial 13y agoAbsolutely, unless you're writing end-user documentation.
- collyw 13y agoI was playing about in Django recently, having written previous views as functions, I wrote some new ones as class based views. I felt that the OOP approach kept it cleaner and inheritance could be used in the same way as currying could for the function based views (but less complex - maybe because I understand OOP concepts better).