Bad Programming Practics

1) Select a language
2) Post bad practices so we can remind ourselves to stop doing them

Other urls found in this thread:

en.wikipedia.org/wiki/C11_(C_standard_revision)
twitter.com/SFWRedditGifs

int a;

not int a = 0;

In c always fucking init your frigging variables.

This so much

Don't know why for-loop got cut from the standard either, comfy as fuck for looping

Why would int a; always be a bad idea?

For loops still exist.
en.wikipedia.org/wiki/C11_(C_standard_revision)

Sometimes you read input into your variables, so it doesn't matter.

Here's a basic one, is x larger than y.

1) Any language
2)
if (x >= y)
return true;
else
return false;

Creating objects or new variables inside a loop over and over instead of defining them outside the loop once.

it's initialized to garbage, whatever value happens to be on the stack at the time. it's a best practice to always set a deterministic value.

if you have good code analysis tools it's not necessary as they will warn you if you attempt to read before setting it.

I don't get it. Why couldn't it just be :

return x >= y;

Using loops when you can use a matrix in Matlab

Setting the return value as a class property and returning null from the method. Specifically PHP but could be a lot.

because faggots can't into if. That faggo is probably a first year CS

writing code in python

writing a UI

>c++
>#include "class.h"
>#include "class.cpp"

>2) Post bad practices so we can remind ourselves to stop doing them
That's the point you idiots

why is that UI specific?
And why bad practice? I always do it (although I never code UIs)

Using c++ is the biggest mistake here.

1) Java
2) using it unironically

What's wrong with C++?

everything, but I'll start:
> cin/cout and related hacks
> OOP language without GC in (current year)
> dozens of different variants of each primitive data type (oh, you want an integer? that's actually called "uint16" in our code!)
> hilarious lack of infix operator defines/overloads
> bad for functional

what a meme post

It's not always a bad idea, but usually unnecessary. Unless you have a specific reason not to, give it a value on declaration.

Using static types.

this, it's 2016

in C++ you don't need to shoehorn in class inheritance where it isn't necessary... and it's almost never necessary

the compiler will actually just fix this for you lol

>compiler optimizing what you don't want it to optimize

Why the fuck does it do it then?

ok autist

If you're telling me your compiler compiles your code so that creating new objects within a loop has the same effect outside, considering every object's constructors may affect something static, then your compiler is shit

How is it autistic?

Python:
def list_square(li):
length = len(li)
for i in range(0, length):
li[i] = li[i] * li[i]
return li

>java
>actually using it

return x >= y; is less legible senpai.

The one thing I wish would be weeded out by a mass genocide is opening the wrapper on the same line as the if/loop statement.

The alternatives are either not OOP, are bloated as fuck, or you use C# and are stuck developing on and for Windows.

also C# is bloated as fuck

People with two-digit IQs don't like it.

This guy is retarded.

Class name{
int a;
name(){
a=1;
}
}

Look, I used int a; and it's completely normal and proper in this context.

>name() {

It's too hard for dumb people.

Remember, we want programming to be an "inclusive" skill!

Nigga it's 2016, use constructor initializations.

Python

Making something that should be a function a class whose constructor returns the object you want.

A class member isn't a variable. And that's not C. That's not even C++.

He said Class, not class.

Uh, you're an idiot. There is no "may"; the compiler knows if your object's constructors affect something static or not.

>not using switches

If (i == 4) return 5;
If (i == 6) return 7;
If (i == 8) return 9;
Etc
Etc

>ruby
Method Overload
module sex
def fuck
...
end
def pussy
...
end
def penis
...
end
end
a.pussy.penis.fuck


Just Don't