41 Commits

Author SHA1 Message Date
Dave Kerr
1af5af643c chore: fix indents 2019-06-01 17:23:32 +08:00
Dave Kerr
da8ec03813 docs: add link to korean version
Fixes #114.
2019-06-01 17:22:05 +08:00
Dave Kerr
23b016eb93 Merge pull request #71 from allingeek/master
feat: Dunbar's number
2019-05-29 21:42:52 +08:00
Dave Kerr
cff4951ae4 Merge pull request #105 from dwmkerr/docs/pareto-principle-edits
docs: minor edits of pareto princple
2019-05-22 23:36:38 +08:00
Dave Kerr
d8bd0d3675 docs: minor edits of pareto princple 2019-05-22 23:35:50 +08:00
Dave Kerr
814e357b97 Merge pull request #97 from rbalazs/add-pareto-principle
Pareto principle
2019-05-22 23:25:50 +08:00
Dave Kerr
afbb055ea3 Merge pull request #93 from jlozovei/master
add DRY Principle
2019-05-20 22:47:39 +08:00
Dave Kerr
2b9996292f Merge branch 'master' into master 2019-05-20 22:47:10 +08:00
Julio Lozovei
d2f4ad77f8 remove code sample + shorten text
- remove code sample
- reduce text size
- add `See also` section
2019-05-20 10:15:43 -03:00
Dave Kerr
64640cbe1a Merge pull request #94 from FaycalKhe/patch-1
Fixing grammar error
2019-05-19 21:29:00 +08:00
Dave Kerr
fef5ed33d9 Merge pull request #100 from nusr/add-book
feat: add reading list - 'godel,escher,bach:an eternal golden braid'
2019-05-19 21:17:07 +08:00
steve xu
0bef1c9a2c feat: add reading list - 'godel,escher,bach:an eternal golden braid' 2019-05-19 20:31:39 +08:00
Dave Kerr
0b01a12bce Merge pull request #98 from dwmkerr/feat/mythical-man-month
feat: added reading list - 'the mythical man month'
2019-05-18 21:14:04 +08:00
Dave Kerr
8e9409fb84 feat: added reading list - 'the mythical man month'
Closes #56.
2019-05-18 19:56:52 +08:00
Dave Kerr
f5b60daaac Merge pull request #96 from uberbrady/master
Replace "Object-Orientated" with "Object-Oriented"
2019-05-18 17:39:22 +08:00
Balázs Richer
0c1c4fa04d Added Pareto Principle to table of contents. 2019-05-18 10:43:56 +02:00
Balázs Richer
abfb8de55c Added Pareto Principle. 2019-05-18 10:42:22 +02:00
Brady Wetherington
cfa6b5c396 Match case on Object-oriented to Object-Oriented 2019-05-17 19:36:07 -07:00
Brady Wetherington
6544befce7 Replace "Object-Orientated" with "Object-Oriented" 2019-05-17 19:30:08 -07:00
Faycel
cbfe0d4ee4 Fixing grammar error
Fixing grammar error
2019-05-17 19:21:40 +01:00
Julio Lozovei
a42732db85 add DRY Principle
- add DRY definition and example
2019-05-17 14:02:12 -03:00
Jeff Nickoloff
d1503a9f7b Merge branch 'master' into master 2019-05-17 09:41:53 -07:00
Dave Kerr
019d1228aa Merge pull request #87 from dwmkerr/feat/chinese-link
feat: link for Chinese version
2019-05-16 14:01:43 +08:00
Dave Kerr
9c52cd8999 docs: added link to Chinese version 2019-05-16 14:00:18 +08:00
Dave Kerr
ed807c8fa9 Merge branch 'master' of github.com:dwmkerr/hacker-laws into feat/chinese-link 2019-05-16 13:59:24 +08:00
Dave Kerr
70847997be Merge pull request #88 from nusr/translate-to-chinese
docs: add chinese link
2019-05-16 13:59:03 +08:00
steve xu
6e727e1332 docs: add chinese link 2019-05-16 10:38:51 +08:00
Dave Kerr
1e840ed25e Merge pull request #74 from Hongarc/patch-1
Fix  typo
2019-05-16 10:38:10 +08:00
Dave Kerr
1aab510db4 feat: link for Chinese version 2019-05-16 10:29:21 +08:00
Hongarc
9b22df414c Merge branch 'master' into patch-1 2019-05-15 23:31:52 +07:00
Dave Kerr
74fad626fe chore: clean up formatting of quotes
And add reference for Hofstadter's Law
2019-05-15 23:35:41 +08:00
Dave Kerr
9e7993284b chore: clean up pr guideline text 2019-05-15 23:25:17 +08:00
Dave Kerr
8c36b424ea Merge pull request #66 from DillonAd/master
Hanlon's Razor
2019-05-15 23:24:36 +08:00
Dave Kerr
e9e3cde668 docs: mention twitter for sharing updates 2019-05-15 22:56:39 +08:00
Dillon Adams
d3a66b3324 Adding author's name to Hanlon's Razor section 2019-05-15 09:49:44 -05:00
Dillon Adams
47b5fa2c25 Correcting spelling of principle in Hanlon's Razor Section 2019-05-15 09:44:34 -05:00
Dave Kerr
d593ef07ab docs: improve contributor guide 2019-05-15 22:43:47 +08:00
Dave Kerr
97c511bb51 Merge pull request #79 from dwmkerr/add-code-of-conduct-1
docs: code of conduct
2019-05-15 22:31:32 +08:00
Hongarc
129a1a6e12 Fix typo 2019-05-15 12:47:34 +07:00
Jeff Nickoloff
4b6af52e60 feat: Dunbar's number
feat: Added Dunbar's number
2019-05-14 14:17:31 -07:00
Dillon Adams
32920982ba Adding section for Hanlon's Razor 2019-05-14 09:38:28 -05:00
3 changed files with 115 additions and 25 deletions

View File

@@ -11,6 +11,7 @@ The goal of this project is to have a set of _concise_ definitions to laws, prin
Some other tips: Some other tips:
- It is fine to include laws which are humorous or not serious. - It is fine to include laws which are humorous or not serious.
- If a law does not obviously apply to development or coding, include a paragraph explaining the relevance to technologists.
- Don't worry about managing the table of contents, I can generate it. - Don't worry about managing the table of contents, I can generate it.
- Feel free to include images, but aim to keep it down to one image per law. - Feel free to include images, but aim to keep it down to one image per law.
- Be careful not to copy-and-paste content (unless it is explicitly quoted), as it might violate copyright. - Be careful not to copy-and-paste content (unless it is explicitly quoted), as it might violate copyright.

View File

@@ -2,7 +2,7 @@
Please double check the items below! Please double check the items below!
- [ ] I have read the [Contributing Guidelines](./.github/contributing.md). - [ ] I have read the [Contributor Guidelines](./.github/contributing.md).
- [ ] I have not directly copied text from another location (unless explicitly indicated as a quote) or violated copyright. - [ ] I have not directly copied text from another location (unless explicitly indicated as a quote) or violated copyright.
- [ ] I have linked to the original Law. - [ ] I have linked to the original Law.
- [ ] I have quote the law (if possible) and the author's name (if possible). - [ ] I have quote the law (if possible) and the author's name (if possible).
@@ -12,3 +12,4 @@ And don't forget:
- I can handle the table of contents, feel free to leave it out. - I can handle the table of contents, feel free to leave it out.
- Check to see if other laws should link back to the law you have added. - Check to see if other laws should link back to the law you have added.
- Include your **Twitter Handle** if you want me to include you when tweeting this update!

136
README.md
View File

@@ -2,13 +2,20 @@
Laws, Theories, Principles and Patterns that developers will find useful. Laws, Theories, Principles and Patterns that developers will find useful.
- 🇨🇳 [中文 / Chinese Version](https://github.com/nusr/hacker-laws-zh) - thanks [Steve Xu](https://github.com/nusr)!
- 🇰🇷 [한국어 / Korean Version](https://github.com/codeanddonuts/hacker-laws-kr) - thanks [Doughnut](https://github.com/codeanddonuts)!
---
<!-- vim-markdown-toc GFM --> <!-- vim-markdown-toc GFM -->
* [Introduction](#introduction) * [Introduction](#introduction)
* [Laws](#laws) * [Laws](#laws)
* [Amdahl's Law](#amdahls-law) * [Amdahl's Law](#amdahls-law)
* [Brooks's Law](#brookss-law) * [Brooks' Law](#brooks-law)
* [Conway's Law](#conways-law) * [Conway's Law](#conways-law)
* [Dunbar's Number](#dunbars-number)
* [Hanlon's Razor](#hanlons-razor)
* [Hofstadter's Law](#hofstadters-law) * [Hofstadter's Law](#hofstadters-law)
* [The Hype Cycle & Amara's Law](#the-hype-cycle--amaras-law) * [The Hype Cycle & Amara's Law](#the-hype-cycle--amaras-law)
* [Hyrum's Law (The Law of Implicit Interfaces)](#hyrums-law-the-law-of-implicit-interfaces) * [Hyrum's Law (The Law of Implicit Interfaces)](#hyrums-law-the-law-of-implicit-interfaces)
@@ -22,6 +29,7 @@ Laws, Theories, Principles and Patterns that developers will find useful.
* [The Spotify Model](#the-spotify-model) * [The Spotify Model](#the-spotify-model)
* [Wadler's Law](#wadlers-law) * [Wadler's Law](#wadlers-law)
* [Principles](#principles) * [Principles](#principles)
* [The Pareto Principle (The 80/20 Rule)](#the-pareto-principle-the-8020-rule)
* [The Robustness Principle (Postel's Law)](#the-robustness-principle-postels-law) * [The Robustness Principle (Postel's Law)](#the-robustness-principle-postels-law)
* [SOLID](#solid) * [SOLID](#solid)
* [The Single Responsibility Principle](#the-single-responsibility-principle) * [The Single Responsibility Principle](#the-single-responsibility-principle)
@@ -29,6 +37,8 @@ Laws, Theories, Principles and Patterns that developers will find useful.
* [The Liskov Substitution Principle](#the-liskov-substitution-principle) * [The Liskov Substitution Principle](#the-liskov-substitution-principle)
* [The Interface Segregation Principle](#the-interface-segregation-principle) * [The Interface Segregation Principle](#the-interface-segregation-principle)
* [The Dependency Inversion Principle](#the-dependency-inversion-principle) * [The Dependency Inversion Principle](#the-dependency-inversion-principle)
* [The DRY Principle](#the-dry-principle)
* [Reading List](#reading-list)
* [TODO](#todo) * [TODO](#todo)
<!-- vim-markdown-toc --> <!-- vim-markdown-toc -->
@@ -57,28 +67,31 @@ The diagram below shows some examples of potential improvements in speed:
*(Image Reference: By Daniels220 at English Wikipedia, Creative Commons Attribution-Share Alike 3.0 Unported, https://en.wikipedia.org/wiki/File:AmdahlsLaw.svg)* *(Image Reference: By Daniels220 at English Wikipedia, Creative Commons Attribution-Share Alike 3.0 Unported, https://en.wikipedia.org/wiki/File:AmdahlsLaw.svg)*
As can be seen, even a program which is 50% parallelisable will benefit very little beyond 10 processing units, where as a program which is 95% parallelisable can still achieve significant speed improvements with over a thousand processing units. As can be seen, even a program which is 50% parallelisable will benefit very little beyond 10 processing units, whereas a program which is 95% parallelisable can still achieve significant speed improvements with over a thousand processing units.
As [Moore's Law](#moores-law) slows, and the acceleration of individual processor speed slows, parallelisation is key to improving performance. Graphics programming is an excellent example - with modern Shader based computing, individual pixels or fragments can be rendered in parallel - this is why modern graphics cards often have many thousands of processing cores (GPUs or Shader Units). As [Moore's Law](#moores-law) slows, and the acceleration of individual processor speed slows, parallelisation is key to improving performance. Graphics programming is an excellent example - with modern Shader based computing, individual pixels or fragments can be rendered in parallel - this is why modern graphics cards often have many thousands of processing cores (GPUs or Shader Units).
See also: See also:
- [Brooks's Law](#brookss-law) - [Brooks' Law](#brookss-law)
- [Moore's Law](#moores-law) - [Moore's Law](#moores-law)
### Brooks's Law ### Brooks' Law
[Brooks's Law on Wikipedia](https://en.m.wikipedia.org/wiki/Brooks%27s_law) [Brooks' Law on Wikipedia](https://en.m.wikipedia.org/wiki/Brooks%27s_law)
> Adding human resources to a late software development project makes it later. > Adding human resources to a late software development project makes it later.
This law suggests that in many cases, attempting to accelerate the delivery of a project which is already late, by adding more people, will make the delivery even later. Brooks is clear that this is an over-simplification, however the general reasoning is that given the ramp up time of new resources and the communication overheads, in the immediate short-term velocity decreases. Also, many tasks may not be divisible, i.e. easily distributed between more resources, meaning the potential velocity increase is also lower. This law suggests that in many cases, attempting to accelerate the delivery of a project which is already late, by adding more people, will make the delivery even later. Brooks is clear that this is an over-simplification, however, the general reasoning is that given the ramp up time of new resources and the communication overheads, in the immediate short-term velocity decreases. Also, many tasks may not be divisible, i.e. easily distributed between more resources, meaning the potential velocity increase is also lower.
The common phrase in delivery "Nine women can't make a baby in one month" relates to Brooks's Law, in particular the fact that some kinds of work are not divisible or parallelisable. The common phrase in delivery "Nine women can't make a baby in one month" relates to Brooks' Law, in particular, the fact that some kinds of work are not divisible or parallelisable.
This is a central theme of the book '[The Mythical Man Month](#reading-list)'.
See also: See also:
- [Death March](#todo) - [Death March](#todo)
- [Reading List: The Mythical Man Month](#reading-list)
### Conway's Law ### Conway's Law
@@ -90,14 +103,44 @@ See also:
- [The Spotify Model](#the-spotify-model) - [The Spotify Model](#the-spotify-model)
### Dunbar's Number
[Dunbar's Number on Wikipedia](https://en.wikipedia.org/wiki/Dunbar%27s_number)
"Dunbar's number is a suggested cognitive limit to the number of people with whom one can maintain stable social relationships— relationships in which an individual knows who each person is and how each person relates to every other person." There is some disagreement to the exact number. "... [Dunbar] proposed that humans can comfortably maintain only 150 stable relationships." He put the number into a more social context, "the number of people you would not feel embarrassed about joining uninvited for a drink if you happened to bump into them in a bar." Estimates for the number generally lay between 100 and 250.
Like stable relationships between individuals, a developer's relationship with a codebase takes effort to maintain. When faced with large complicated projects, or ownership of many projects we lean on convention, policy, and modeled procedure to scale. Dunbar's number is not only important to keep in mind as an office grows, but also when setting the scope for team efforts or deciding when a system should invest in tooling to assist in modeling and automating logistical overhead. Putting the number into an engineering context, it is the number of projects (or normalized complexity of a single project) for which you would feel confident in joining an on-call rotation to support.
See also:
- [Conway's Law](#conways-law)
### Hanlon's Razor
[Hanlon's Razor on Wikipedia](https://en.wikipedia.org/wiki/Hanlon%27s_razor)
> Never attribute to malice that which is adequately explained by stupidity.
>
> Robert J. Hanlon
This principle suggests that actions resulting in a negative outcome were not a result of ill will. Instead the negative outcome is more likely attributed to those actions and/or the impact being not fully understood.
### Hofstadter's Law ### Hofstadter's Law
[Hofstadter's Law on Wikipedia](https://en.wikipedia.org/wiki/Hofstadter%27s_law) [Hofstadter's Law on Wikipedia](https://en.wikipedia.org/wiki/Hofstadter%27s_law)
> It always takes longer than you expect, even when you take into account Hofstadter's Law. > It always takes longer than you expect, even when you take into account Hofstadter's Law.
>
> Douglas Hofstadter
You might hear this law referred to when looking at estimates for how long something will take. It seems a truism in software development that we tend to not be very good at accurately estimating how long something will take to deliver. You might hear this law referred to when looking at estimates for how long something will take. It seems a truism in software development that we tend to not be very good at accurately estimating how long something will take to deliver.
This is from the book '[Gödel, Escher, Bach: An Eternal Golden Braid](#reading-list)'.
See also:
- [Reading List: Gödel, Escher, Bach: An Eternal Golden Braid](#reading-list)
### The Hype Cycle & Amara's Law ### The Hype Cycle & Amara's Law
[The Hype Cycle on Wikipedia](https://en.wikipedia.org/wiki/Hype_cycle) [The Hype Cycle on Wikipedia](https://en.wikipedia.org/wiki/Hype_cycle)
@@ -125,7 +168,7 @@ In short, this cycle suggests that there is typically a burst of excitement arou
> >
> (Hyrum Wright) > (Hyrum Wright)
Hyrum's Law states that when you have a _large enough number of consumers_ of an API, all behaviours of the API (even those not defined as part of a public contract) will eventually come to be depended on by someone. A trivial examples may be non-functional elements such as the response time of an API. A more subtle example might be consumers who are relying on applying a regex to an error message to determine the *type* of error of an API. Even if the public contract of the API states nothing about the contents of the message, indicating users should use an associated error code, _some_ users may use the message, and changing the message essentially breaks the API for those users. Hyrum's Law states that when you have a _large enough number of consumers_ of an API, all behaviours of the API (even those not defined as part of a public contract) will eventually come to be depended on by someone. A trivial example may be non-functional elements such as the response time of an API. A more subtle example might be consumers who are relying on applying a regex to an error message to determine the *type* of error of an API. Even if the public contract of the API states nothing about the contents of the message, indicating users should use an associated error code, _some_ users may use the message, and changing the message essentially breaks the API for those users.
See also: See also:
@@ -138,7 +181,7 @@ See also:
> The number of transistors in an integrated circuit doubles approximately every two years. > The number of transistors in an integrated circuit doubles approximately every two years.
Often used to illustrate the sheer speed at which semiconductor and chip technology has improved, Moore's prediction has proven to be highly accurate over from the 1970s to the late 2000s. In more recent years, the trend has changed slightly, partly due to [physical limitations on the degree to which components can be miniaturised](https://en.wikipedia.org/wiki/Quantum_tunnelling). However, advancements in parallelisation, and potentially revolutionary changes in semi-conductor technology and quantum computing may mean that Moore's Law could continue to hold true for decades to come. Often used to illustrate the sheer speed at which semiconductor and chip technology has improved, Moore's prediction has proven to be highly accurate over from the 1970s to the late 2000s. In more recent years, the trend has changed slightly, partly due to [physical limitations on the degree to which components can be miniaturised](https://en.wikipedia.org/wiki/Quantum_tunnelling). However, advancements in parallelisation, and potentially revolutionary changes in semiconductor technology and quantum computing may mean that Moore's Law could continue to hold true for decades to come.
### Parkinson's Law ### Parkinson's Law
@@ -196,7 +239,7 @@ This law states that abstractions, which are generally used in computing to simp
An example might be loading a file and reading its contents. The file system APIs are an _abstraction_ of the lower level kernel systems, which are themselves an abstraction over the physical processes relating to changing data on a magnetic platter (or flash memory for an SSD). In most cases, the abstraction of treating a file like a stream of binary data will work. However, for a magnetic drive, reading data sequentially will be *significantly* faster than random access (due to increased overhead of page faults), but for an SSD drive, this overhead will not be present. Underlying details will need to be understood to deal with this case (for example, database index files are structured to reduce the overhead of random access), the abstraction 'leaks' implementation details the developer may need to be aware of. An example might be loading a file and reading its contents. The file system APIs are an _abstraction_ of the lower level kernel systems, which are themselves an abstraction over the physical processes relating to changing data on a magnetic platter (or flash memory for an SSD). In most cases, the abstraction of treating a file like a stream of binary data will work. However, for a magnetic drive, reading data sequentially will be *significantly* faster than random access (due to increased overhead of page faults), but for an SSD drive, this overhead will not be present. Underlying details will need to be understood to deal with this case (for example, database index files are structured to reduce the overhead of random access), the abstraction 'leaks' implementation details the developer may need to be aware of.
The example above can become more complex when _more_ abstractions are introduced. The Linux operating system allows files to be accessed over a network, but represented locally as 'normal' files. This abstraction will 'leak' if there are network failures. If a developer treats these files as 'normal' files, without considering the fact that they may be subject to network latency and failures, the solutions will be buggy. The example above can become more complex when _more_ abstractions are introduced. The Linux operating system allows files to be accessed over a network but represented locally as 'normal' files. This abstraction will 'leak' if there are network failures. If a developer treats these files as 'normal' files, without considering the fact that they may be subject to network latency and failures, the solutions will be buggy.
The article describing the law suggests that an over-reliance on abstractions, combined with a poor understanding of the underlying processes, actually makes dealing with the problem at hand _more_ complex in some cases. The article describing the law suggests that an over-reliance on abstractions, combined with a poor understanding of the underlying processes, actually makes dealing with the problem at hand _more_ complex in some cases.
@@ -222,9 +265,9 @@ The fictional example above led to the usage of the term 'Bike Shedding' as an e
[The Unix Philosophy on Wikipedia](https://en.wikipedia.org/wiki/Unix_philosophy) [The Unix Philosophy on Wikipedia](https://en.wikipedia.org/wiki/Unix_philosophy)
The Unix Philosophy is that software components should be small, and focused on doing one specific thing well. This can make it easier to build systems by composing together small, simple, well defined units, rather than using large, complex, multi-purpose programs. The Unix Philosophy is that software components should be small, and focused on doing one specific thing well. This can make it easier to build systems by composing together small, simple, well-defined units, rather than using large, complex, multi-purpose programs.
Modern practices like 'Microservice Architecture' can be thought of as an application of this law, where services are small, focused and do one specific thing, allowing complex behaviour to be composed from simple building blocks. Modern practices like 'Microservice Architecture' can be thought of as an application of this law, where services are small, focused and do one specific thing, allowing complex behaviour to be composed of simple building blocks.
### The Spotify Model ### The Spotify Model
@@ -257,6 +300,28 @@ See also:
Principles are generally more likely to be guidelines relating to design. Principles are generally more likely to be guidelines relating to design.
### The Pareto Principle (The 80/20 Rule)
[The Pareto Principle on Wikipedia](https://en.wikipedia.org/wiki/Pareto_principle)
> Most things in life are not distributed evenly.
The Pareto Principle suggests that in some cases, the majority of results come from a minority of inputs:
- 80% of a certain piece of software can be written in 20% of the total allocated time (conversely, the hardest 20% of the code takes 80% of the time)
- 20% of the effort produces 80% of the result
- 20% of the work creates 80% of the revenue
- 20% of the bugs cause 80% of the crashes
- 20% of the features cause 80% of the usage
In the 1940s American-Romanian engineer Dr. Joseph Juran, who is widely credited with being the father of quality control, [began to apply the Pareto principle to quality issues](https://en.wikipedia.org/wiki/Joseph_M._Juran).
This principle is also known as: The 80/20 Rule, The Law of the Vital Few and The Principle of Factor Sparsity.
Real-world examples:
- In 2002 Microsoft reported that by fixing the top 20% of the most-reported bugs, 80% of the related errors and crashes in windows and office would become eliminated ([Reference](https://www.crn.com/news/security/18821726/microsofts-ceo-80-20-rule-applies-to-bugs-not-just-features.htm)).
### The Robustness Principle (Postel's Law) ### The Robustness Principle (Postel's Law)
[The Robustness Principle on Wikipedia](https://en.wikipedia.org/wiki/Robustness_principle) [The Robustness Principle on Wikipedia](https://en.wikipedia.org/wiki/Robustness_principle)
@@ -287,11 +352,11 @@ These are key principles in [Object-Oriented Programming](#todo). Design princip
The first of the '[SOLID](#solid)' principles. This principle suggests that modules or classes should do one thing and one thing only. In more practical terms, this means that a single, small change to a feature of a program should require a change in one component only. For example, changing how a password is validated for complexity should require a change in only one part of the program. The first of the '[SOLID](#solid)' principles. This principle suggests that modules or classes should do one thing and one thing only. In more practical terms, this means that a single, small change to a feature of a program should require a change in one component only. For example, changing how a password is validated for complexity should require a change in only one part of the program.
Theoretically this should make code more robust, and easier to change. Knowing that a component which is being changed has a single responsibility only means that _testing_ that change should be easier. Using the earlier example, changing the password complexity component should only be able to affect the features which relate to password complexity. It can be much more difficult to reason about the impact of a change to a component which has many responsibilities. Theoretically, this should make the code more robust, and easier to change. Knowing that a component which is being changed has a single responsibility only means that _testing_ that change should be easier. Using the earlier example, changing the password complexity component should only be able to affect the features which relate to password complexity. It can be much more difficult to reason about the impact of a change to a component which has many responsibilities.
See also: See also:
- [Object-Orientated Programming](#todo) - [Object-Oriented Programming](#todo)
- [SOLID](#solid) - [SOLID](#solid)
### The Open/Closed Principle ### The Open/Closed Principle
@@ -308,7 +373,7 @@ This principle has particular relevance for object-oriented programming, where w
See also: See also:
- [Object-Orientated Programming](#todo) - [Object-Oriented Programming](#todo)
- [SOLID](#solid) - [SOLID](#solid)
### The Liskov Substitution Principle ### The Liskov Substitution Principle
@@ -319,13 +384,13 @@ See also:
The third of the '[SOLID](#solid)' principles. This principle states that if a component relies on a type, then it should be able to use subtypes of that type, without the system failing or having to know the details of what that subtype is. The third of the '[SOLID](#solid)' principles. This principle states that if a component relies on a type, then it should be able to use subtypes of that type, without the system failing or having to know the details of what that subtype is.
As an example, imagine we have a method which reads an XML document from a structure which represents a file. If the method uses a base type 'file', then anything which derives from 'file' should be able to be used in the function. If 'file' supports seeking in reverse, and the xml parser uses that function, but the derived type 'network file' fails when reverse seeking is attempted, then the 'network file' would be violating the principle. As an example, imagine we have a method which reads an XML document from a structure which represents a file. If the method uses a base type 'file', then anything which derives from 'file' should be able to be used in the function. If 'file' supports seeking in reverse, and the XML parser uses that function, but the derived type 'network file' fails when reverse seeking is attempted, then the 'network file' would be violating the principle.
This principle has particular relevance for object-orientated programming, where type hierarchies must be modelled carefully to avoid confusing users of a system. This principle has particular relevance for object-oriented programming, where type hierarchies must be modeled carefully to avoid confusing users of a system.
See also: See also:
- [Object-Orientated Programming](#todo) - [Object-Oriented Programming](#todo)
- [SOLID](#solid) - [SOLID](#solid)
### The Interface Segregation Principle ### The Interface Segregation Principle
@@ -336,13 +401,13 @@ See also:
The fourth of the '[SOLID](#solid)' principles. This principle states that consumers of a component should not depend on functions of that component which it doesn't actually use. The fourth of the '[SOLID](#solid)' principles. This principle states that consumers of a component should not depend on functions of that component which it doesn't actually use.
As an example, imagine we have a method which reads an XML document from structure which represents a file. It only needs to read bytes, move forwards or move backwards in the file. If this method needs to be updated because an unrelated feature of the file structure changes (such as an update to the permissions model used to represent file security), then the principle has been invalidated. It would be better for the file to implement a 'seekable-stream' interface, and for the XML reader to use that. As an example, imagine we have a method which reads an XML document from a structure which represents a file. It only needs to read bytes, move forwards or move backwards in the file. If this method needs to be updated because an unrelated feature of the file structure changes (such as an update to the permissions model used to represent file security), then the principle has been invalidated. It would be better for the file to implement a 'seekable-stream' interface, and for the XML reader to use that.
This principle has particular relevance for object-orientated programming, where interfaces, hierarchies and abstract types are used to [minimise the coupling](#todo) between different components. [Duck typing](#todo) is a methodology which enforces this principle by eliminating explicit interfaces. This principle has particular relevance for object-oriented programming, where interfaces, hierarchies and abstract types are used to [minimise the coupling](#todo) between different components. [Duck typing](#todo) is a methodology which enforces this principle by eliminating explicit interfaces.
See also: See also:
- [Object-Orientated Programming](#todo) - [Object-Oriented Programming](#todo)
- [SOLID](#solid) - [SOLID](#solid)
- [Duck Typing](#todo) - [Duck Typing](#todo)
- [Decoupling](#todo) - [Decoupling](#todo)
@@ -351,7 +416,7 @@ See also:
[The Dependency Inversion Principle](https://en.wikipedia.org/wiki/Dependency_inversion_principle) [The Dependency Inversion Principle](https://en.wikipedia.org/wiki/Dependency_inversion_principle)
> High level modules should not be dependent on low-level implementations. > High-level modules should not be dependent on low-level implementations.
The fifth of the '[SOLID](#solid)' principles. This principle states that higher level orchestrating components should not have to know the details of their dependencies. The fifth of the '[SOLID](#solid)' principles. This principle states that higher level orchestrating components should not have to know the details of their dependencies.
@@ -361,13 +426,36 @@ This principle is complex, as it can seem to 'invert' the expected dependencies
See also: See also:
- [Object-Orientated Programming](#todo) - [Object-Oriented Programming](#todo)
- [SOLID](#solid) - [SOLID](#solid)
- [Inversion of Control](#todo) - [Inversion of Control](#todo)
- [Dependency Injection](#todo) - [Dependency Injection](#todo)
### The DRY Principle
[The DRY Principle on Wikipedia](https://en.wikipedia.org/wiki/Don%27t_repeat_yourself)
> Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
DRY is an acronym for _Don't Repeat Yourself_. This principle aims to help developers reducing the repetition of code and keep the information in a single place and was cited in 1999 by Andrew Hunt and Dave Thomas in the book [The Pragmatic Developer](https://en.wikipedia.org/wiki/The_Pragmatic_Programmer)
> The opposite of DRY would be _WET_ (Write Everything Twice or We Enjoy Typing).
In practice, if you have the same piece of information in two (or more) different places, you can use DRY to merge them into a single one and reuse it wherever you want/need.
See also:
- [The Pragmatic Developer](https://en.wikipedia.org/wiki/The_Pragmatic_Programmer)
## Reading List
If you have found these concepts interesting, you may enjoy the following books.
- [The Mythical Man Month - Frederick P. Brooks Jr.](https://www.goodreads.com/book/show/13629.The_Mythical_Man_Month) - A classic volume on software engineering. [Brooks's Law](#brookss-law) is a central theme of the book.
- [Gödel, Escher, Bach: An Eternal Golden Braid - Douglas R. Hofstadter.](https://www.goodreads.com/book/show/24113.G_del_Escher_Bach) - This book is difficult to classify. [Hofstadter's Law](#hofstadters-law) is from the book.
## TODO ## TODO
Hi! If you land here, you've clicked on a link to a topic I've not written up yet, sorry about this - this is work in progress! Hi! If you land here, you've clicked on a link to a topic I've not written up yet, sorry about this - this is work in progress!
Feel free to [Raise an Issue](https://github.com/dwmkerr/hacker-laws/issues) requesting more details, or [Open a Pull Request](https://github.com/dwmkerr/hacker-laws/pulls) to submit your proposed definition of the topic. Feel free to [Raise an Issue](https://github.com/dwmkerr/hacker-laws/issues) requesting more details, or [Open a Pull Request](https://github.com/dwmkerr/hacker-laws/pulls) to submit your proposed definition of the topic.