What is considered a "gambiarra" or a bad code?

Asked

Viewed 442 times

8

For example, I create a code, and it works, but I’m not sure it’s right for me to do it that way. Is that a trick? I have to make sure that the code is done in such a way for it to be considered a "good code"?

  • 3
  • 4
  • 1

    People voting to close: do you really think that what separates a gambiarra from something well done is an opinion? IT is no longer exact?

  • When I saw the question I saw no reason to close. After I saw the reason(mainly based on opinions) I got a flea behind the ear, but gambiarra is still a poorly made solution, poorly structured, or poorly elaborated, this is universal, I think kk

  • 3

    Related: https://answall.com/q/33702/101

  • 3

    That the question is not good I have no doubts, but I do not know with what to close. So bad is that the posted answer may be interesting but does not answer what was asked. And I do not know if it can answer here. This involves a lot, seems to me something as broad. It is not just saying what is gambiarra, has to show everything that is, involves years of experience being passed in a few lines, does not give.

  • The past links I think will clear up my doubt. Renan said this and voted to close too, I did not understand '-' "People who are voting to close: do you really think that what separates a gambiarra from something well done is an opinion? TI is no longer exact?" But, thank you, I think I can too, have my opinion, my opinion!

  • Ah. 2 Renan’s, rs; Sorry.

  • @bigown I agree with "too wide", but not with "based on opinions". p.s.: I’m not the Renan who voted to close.

  • I think this answer may help clarify a little: https://answall.com/a/152237/14262, mainly in the part Readability and maintenance

  • What will define if code is a gambiarra is the context where it was applied or is in that scenario the adopted solution was appropriate? Context means environment and functionality/system requirements.

Show 6 more comments

1 answer

8


Gambiarra is the term used for poor quality and poorly done code, and it doesn’t always work (but sometimes it does, only in a way that shouldn’t be used).

Often, it is a confusing code, tied up with a lot of stuff that has little or nothing to do with the purpose of the code, and brings problems and unwanted side effects. It can also be a fragile code that does not work in abnormal situations.

For example:

Gambiarra

To know what is or is not gambiarra is something very subjective. An example of a real-world gambiarra of programming would be to pass a value X as a parameter of function A to function B, save the X in a file in function A and read that file in function B. This is gambiarra because the file would be being used for the application to communicate with itself without saving data from one run to another nor saving memory, and generates side effects because it depends on the use of the disk, is slower, etc. And it is also an inappropriate way to do, because there is another solution much simpler and direct and files were not designed for this purpose.

  • 1

    But then, how will I come to that conclusion? "way that should not be used" That’s why they want to close the question?

  • @Lucascarvalho I edited the answer.

Browser other questions tagged

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