vendredi 30 janvier 2015

YAGNI principle put to practice


I recently came across to this principle and so far it is clear the fact that doing things that you don't need at the moment is not feasible as they might not be used or might be changed.


That being said, consider the following scenario: You're working on an application that needs to display text in labels, in several places/parts. The targeted language is English, and there is no requirement to implement multi-language. At this point, if you needed multi-language feature, you'd define every string in a resource file (let's say it's an XML file) and create/use a class to read them and assign them to the corresponding labels (according to the language). Thing is, since multi-language is not a requirement, YAGNI.


So, do you still define strings into a resource file and implement the reader, or you hard-code them and reafactor when you actually need it?





Aucun commentaire:

Enregistrer un commentaire