19 Pieces of junk code that individuals actually write

One of them may have been written by you .

bernard - Bardo  - 5 Minute reading

Photo :Damir Spanic on Unsplash

At some point , It happened to all of us . You've produced code that you're not proud of . These codes make you doubt ," How could I write such a thing ?"
There's nothing to be ashamed of . We are just human beings . occasionally , We just didn't do our best .

It happened to me , It happened to you , But it also happens to other developers . It took me some time , Collected the worst code snippets I could find . today , I'll introduce them to you .

however , I only do this under one condition . You must promise me that you will not treat them in a bad way . remember , At some point , You may have written something similar . since it is so , Let's put on open-minded glasses , Play . Here comes the first one !

There was a mistake in rebuilding the wheel

Conventional boolean type comparisons do not return what you are looking for . What should you do ? The answer is simple , You create one yourself .


  Magic number

Look at this picture , I can't help asking . What happens if we change one of the numbers ? There may be nothing good .


At least it is divided into several lines

From the pure look of this code , I guess it's a school project . Needless to say , I express my condolences to the teacher .


The devil is also a function

today , We'll see isEven Various implementations of functions . This is our first candidate . What I want to say is , We have made a good start . How did you like it? ?


I want a function to get the size of the string

The idea flashed through the minds of our developer partners . He didn't hesitate for a second . And implemented it immediately .


Awaken the inner child

Although it sounds crazy , But you can use emoticons as variable names . But should you use them this way ? Look at the code below , Decide for yourself .


Who the hell is reading t information

If you have a colleague who repeatedly uses the same submission . She may have done so .


If any of these changes

The future is unpredictable . It can change overnight . To prevent this from happening , You'd better be more careful .


Reasons for buying ultra widescreen displays

There is nothing wrong with verbose variable names . As long as they help improve the readability of the code . But sometimes , We have to ask ourselves  " How long is long ?”


Act of genius

There is nothing to add here . I think this note is self-evident .


Typesetting is the best

The feeling of type safety is very good . So how can you better ensure that you don't make any kind of mistakes ? These guys , They came up with this idea .


If it works , It just works

What are you really talking about . Just make sure that the sum of the parameters is always 7. And this function will not fail .


Make sure it's real Bool

How much pessimism is excessive pessimism ? I want to say this man is really close .


The best way of Test Driven Development

We must praise the use of unit tests . But I can't help asking . If the test is generating random numbers , What happens ?


Do you dare to expand ?

We have all written complex switch statements at some time . however , A thousand lines seems a little too much . But after all, there are many mouse states that need to be overwritten .


on trial Switch sentence

Do you think the future plan is to expand this Switch Do you ? There's nothing left , Just believe it .


Mathematics is difficult

Sometimes , It's not shameful to use external help . What actually exists is -- Even bags . Can you guess how many times it is downloaded every week ? It exceeds 15 Ten thousand times .


When brilliant ideas flow

Sometimes , You just think you're a rebel . You must do things your own way . But I think we can agree , This type of code should not enter code review .


When you are a code farmer, but your passion is calligraphy

I tried different types of fonts . But I have to say , It has never come this far . If it makes you doubt " Is that how pirated software is written ?" You're not alone .


Last thought

I hope you have a good mood when looking at these examples . Of course I am . Welcome to let me know which one you like best . Or if you have some shameful photos to share , Don't be afraid to share it in comments .

I enjoyed browsing through these code snippets . It reminds me of my early days . In my career , I wrote some code snippets that I'm not proud of . But fortunately , No one took a screenshot of them . Or at least I hope so .