Is this a scam?

Asked

Viewed 218 times

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?

  • 4

    Gambiarra == inadequate solution (difficult to maintain or expensive) that solves the problem in the short term.

  • 3

    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.

  • 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.

  • 1

    Hmm, so it would be a solution not as efficient or extensible as it should be but that is quick to write..

  • Reference in gambiarras: Gambi Design Patterns.

Show 1 more comment

1 answer

1


Gambiarra may have several interpretations, but it is never the ultimate best solution. It may be something provisional, but not permanent.

When it comes to Python, I think his philosophy is a great starting point for understanding what maybe a gambit is and how to make great code:

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nestled.
Sparse is better than dense.
Readability counts.
Special cases are not special enough to violate the rules.
Although practicality wins purity.
Mistakes must not pass silently.
Unless they are explicitly silenced.
In case of ambiguity, resist the temptation to guess.
There must be one - and only one - obvious way to do.
Although such a way is not so obvious at first sight unless you are Dutch.
Now it’s better than ever.
Although it’s never often better than right now.
If the implementation is difficult to explain, the idea is bad.
If the implementation is easy to explain, maybe the idea is good.
Namespaces are a great idea - let’s do more of them!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.