TL;DR
We added some style to application text along with our first photo. To not repeat the same code, we add a function that adds a photo. This post is part of the functional language series, and it is based on a remarkable book Programming Elm Build Safe and Maintainable Front-End Applications by Jeremy Fairbank.
View Photo Function
In programming, there is a concept of do not repeat yourself (DRY is an acronym that describes this concept). Let’s first add a new photo by copy/past existing detailed photo element (screenshot above). We change src
and caption
text.
After recompile:
Let’s DRY main
by writing viewPhoto
method.
Remember
- DRY concept and when to use it
Comments are closed.