Software development is “the act of breaking a complex problem down into smaller problems, and composing simple solutions to form a complete solution to the complex problem.”
The above quote is taken from Eric Elliots fantastic series on Software Composition and encapsulates the core idea that you should strive to understand in order to become a good software developer.
Writing your code with this intention in mind, streamlines the development process and results in an organised, reasonable, legible codebase. Overall, the process will be more enjoyable for yourself and any other future developer who may need to maintain and build upon it in future. You can understand this principle by looking at the simple functions below.
Imagine you wanted to create a shout function that took a string and converted it to uppercase and added a number of exclamation marks at the end of it. If you were to write it in the lazy way you might write the following.
The above is fine in most cases but what happens if you don’t want to shout quite so forcefully… (Maybe you’ve trod on a grape rather than a plug socket?)
In that instance, we could refactor the above the above code to the following which gives us more flexibility and thus would be better software composition.
The above may look confusing but hopefully serve as an indication of a broader concept of the best way to be composing your software.
Other terms for the above is called functional programming, or declarative programming which are ideas that incorporate the above but for more information on these I will be posting more about them in future.
I would also recommend Eric Elliots series on software composition or ‘Professor Frisbys Mostly Adequate Guide to Functional Programming’ which both provide an in depth look into the broader world of software composition.