Smart concepts in development
We often see these glib little phrases related to development, exhorting us to do this or not do that. Though the phrases may be glib, they are often representative of fundamental truths.
I've written down some of the ones I try to adhere to, mostly to remind myself when I get off track.
You aren't gonna need it (YAGNI). Always implement things when you actually need them, never when you just foresee that you need them., eXtreme Programming principle
This is excellent advice. When developing, it's easy to get carried away with enthusiasm for new ideas; "What if I added this? Wouldn't that be awesome!". The problem is that unless you actually need the code now, writing it is wasting time, and the more code you add the more maintenance is required as you refactor your code, encouraging code rot.
"Once and Only Once" (OAOO), eXtreme Programming principle
If you are aware of duplication in your code, remove it. This is such a basic concept that I'm surprised it isn't taught everywhere. For example, if you find yourself constantly needing to split a string into an array on a delimiter, and manually writing the code to do so, that is a perfect case for factoring out the existing instances.
The counter-point to this is that you should use common sense when applying this concept. My personal metric for this is three duplicates of short snippets of code (around 3-5 lines), or two duplicates of large sections of code (anything more than around 7 lines).
''Do the simplest thing that could possibly work.'' (DTSTTCPW), eXtreme Programming principle
This is another case for not over-engineering your code, stated succinctly. "Don't build a giant super-efficient object, sorted and hashed and linked together, if an Array will do the job."
"Premature optimization is the root of all evil", Donald Knuth
Dr. Knuth's point is that if you optimise early on in the development cycle, it will often interfere with the quality of the design and, I believe, hinder refactoring. Once you have a cleanly designed system, then start optimising if necessary.
Complexity that Empowers
A friend of mine once said that there are problems and there are difficulties. A problem is something you savor. You say, "Well that's an interesting problem. Let me think about that problem a while." You enjoy thinking about it, because when you find the solution to the problem, it's enlightening.
And then there are difficulties. Computers are famous for difficulties. A difficulty is just a blockage from progress. You have to try a lot of things. When you finally find what works, it doesn't tell you a thing. It won't be the same tomorrow. Getting the computer to work is so often dealing with difficulties.
The complexity that we despise is the complexity that leads to difficulty. It isn't the complexity that raises problems. There is a lot of complexity in the world. The world is complex. That complexity is beautiful. I love trying to understand how things work. But that's because there's something to be learned from mastering that complexity.
Ward Cunningham
