Below you will find pages that utilize the taxonomy term “Refactoring”
Posts
Improving Design - Separating responsibilities
Let’s take a look at the following piece of code:
fun search(query: String): List<String> { val allItems: List<String> = ExternalSystem.fetchAllItems() val filtered = allItems.filter { it.contains(query) } val reordered = filtered.sortedWith(object : Comparator<String> { override fun compare(lhs: String, rhs: String): Int { if (lhs == query) { return -1 } else if (rhs == query) { return 0 } return lhs.compareTo(rhs) } }) return reordered } From a behavioral point of view, this code has no problems.
Posts
Refactoring Legacy Code
Intro Quite often in software development, we come to a point where we have to alter some code, whether to make it easier to read and understand or to add a new feature.
Recently a friend of mine posted a piece of code in a public Slack channel, and he asked for resources that would help him improve not only that particular code but any legacy code in general.