That's sometimes easy, sometimes not so easy due to the boilerplate requirements of the language/framework/library one uses. Other times it introduces a trade-off between repetition and code complexity/readability, so it's not the silver bullet your comment suggests it to be.