1
I’m starting in programming, I have some difficulty reading codes even my own after a while.
I was a researcher on legibility and came across the term "gambiarra". this raised a question for me.
what exactly defines a gambiarra and how to avoid creating a?
codes like the one I was writing and ended up getting lost in can be considered gambiarras?
class Skeleton:
def __init__(self, names_list, delimiters=",. /*"):
self.deimiters = [char for char in delimiters]
self.__items = {}
for name in names_list:
replaced_name = name
for delimiter_char in self.deimiters:
replaced_name = replaced_name.replace(delimiter_char, " ")
tokens = replaced_name.split()
for i in range(len(tokens)):
key = " ".join(tokens[:i + 1])
if key in self.__items:
item = self.__items[key]
if name not in item["shapes"]:
item["shapes"].append(name)
else:
self.__items[key] = {}
item = self.__items[key]
item["shapes"] = []
item["shapes"].append(name)
Something specific?
– Maniero
Gambiarra == inadequate solution (difficult to maintain or expensive) that solves the problem in the short term.
– rray
In my opinion the concept of gambiarra is very relative, gambiarra has not to do legibility, you can make a highly legible gambiarra, eheheh! Gambiarra is where you choose a path, even if doubtful or risky, only because it will give you a faster result and will solve the problem in the immediate term. For example. vc makes a "webscraping" on a website, even having an API available, only pq considers that working with the API will require more time and work.
– Sidon
But sometimes you are almost obliged to do the gambiarra, consider that you are not finding the API that meets what you need. I can the case in our colleague Gabriel.
– Sidon
Hmm, so it would be a solution not as efficient or extensible as it should be but that is quick to write..
– StackOverflowToxicityVictim
Reference in gambiarras: Gambi Design Patterns.
– Victor Stafusa