Abstraction principle (computer programming): Difference between revisions

Content deleted Content added
AnomieBOT (talk | contribs)
m Dating maintenance tags: {{Citation Needed}}
Line 26:
Inexperienced programmers may be tempted to introduce too much abstraction in their program—abstraction that won't be used more than once. {{Citation needed|date=March 2013}} A complementary principle that emphasize this issue is "[[You Ain't Gonna Need It]]" and, more generally, the [[KISS principle]].
 
Since code is usually subject to revisions, following the abstraction principle may entail [[refactoring]] of code. The effort of rewriting a piece of code generically needs to be amortized against the estimated future benefits of an abstraction. A rule of thumb governing this was devised by [[Martin Fowler (software engineer)|Martin Fowler]], and popularized as [[Rule of three (programming)|the rule of three]]. It states that if a piece of code is copied more than twice, i.e. it would end up having three or more copies, then it needs to be abstracted out.
 
== Generalizations ==