@include Welcome(); to mixins.

Colonel Duck
Quacking tips
Published in
2 min readJun 20, 2018

Don’t Repeat Yourself (DRY) is a common software development principle.

If 10 places have the same functionality. Writing the same code 10 times would break this DRY principle. Non-DRY code is humorously considered WET. “Write Everything Twice”, “We Enjoy Typing” and “Waste Everyone’s Time”.

The reasoning behind this, is that any change would lead to editing all 10 different places. Editing multiple places can be horribly tedious and error prone.

A much better solution would be to write the code only once and reference it from other places.

Much like Harvard Referencing, or when giving credit to someone’s written work, Mixins allow you to point at some other information and paste it in place of your reference.

Another benefit to this, is that the information you’re pointing to might be quite large, a shorthand can be useful.

Mixins have other uses as well, and in some languages are used for creating an object from multiple concepts. The Michael Gregory object is a composite of Computer Programmer, Musician and Mullet Enthusiast.

The specific syntax you are seeing here is from SCSS or SASS. When creating webpages, we specify the colours and style of the website using CSS. SCSS/SASS allows us to re-use code along with many other useful features.

More information on SASS’ mixins can be found at https://sass-lang.com/guide#topic-6 .

If you’re into something a little spicier, these pages on Java Recursive Generics and the Curiously Recurring Generic Patter might be of interest.
https://vyazelenko.com/2012/03/02/recursive-generics-to-the-rescue/ http://www.unquietcode.com/blog/2011/programming/using-generics-to-build-fluent-apis-in-java/

--

--

Colonel Duck
Quacking tips

Award winning software and creative agency — creating value differently.