[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
CS graduate code thread? Always worth a few laughs.
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 202
Thread images: 34
File: 1454906413139.png (638 KB, 4760x4986) Image search: [Google]
1454906413139.png
638 KB, 4760x4986
CS graduate code thread?

Always worth a few laughs.
>>
File: 1425860477255.jpg (70 KB, 694x801) Image search: [Google]
1425860477255.jpg
70 KB, 694x801
>>
Did somebody type that out?
>>
>>52888025
It's really quick and easy to do with vim
>>
>>52888000
wut
>>
>>52888000
I think this guy went on to write the api we use at work...
>>
>>52888047
Do you think a nigger of this caliber knows how to use Vim?

That was a very dedicated CS for-the-money memester and a couple of sleepless nights.
>>
>>52890083
I can't say I haven't done something similar. Spent ~3 sleepless nights programming that dumb ascii christmas tree in http://www.dangermouse.net/esoteric/bit.html a couple years ago. I took advantage of macros and regex where possible but there was still a ton of manual stuff to type.
>>
>>52887982
>>52888000
kill me
>>
>>52888095
he made a decimal number by converting an integer to a string, adding ".0" to the end, then parsing the string as a double. lol'd

>>52887982
that guy cracked RSA for a school project??
>>
>>52888025

You can write a program to do that for you..
>>
File: apple_goto_bug.png (76 KB, 694x801) Image search: [Google]
apple_goto_bug.png
76 KB, 694x801
>>
File: AfCriIU.png (66 KB, 1152x648) Image search: [Google]
AfCriIU.png
66 KB, 1152x648
>>52890708
it's funny because it's true
>>
>>52890708
kek
>>
File: GUvW23N.png (77 KB, 694x801) Image search: [Google]
GUvW23N.png
77 KB, 694x801
My favorite
>>
>>52887982
This is beautiful.

I'm assuming somebody scripted the generation of this code.

Hoping even.
>>
File: 1448574752467.gif (455 KB, 215x300) Image search: [Google]
1448574752467.gif
455 KB, 215x300
>>52890927
>>
Got some OC here

        <script language="JavaScript">
var r=0;
var g=0;
var b=0;
var rInc=1;
var gInc=1;
var bInc=1;
var count=0;
var hex=new Array("0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f");
function toHex(num) {
var ones=num%16;
var sixteens=(num-ones)/16;
return hex[ones]+hex[sixteens];
}
function changeFG() {
count++;
if (count>255) {
count=0;
rInc=count++;
gInc=count++;
bInc=count++;
}
r+=rInc;
g+=gInc;
b+=bInc;
if (r>255) {
r=0;
}
if (r<0) {
r=255
}
if (g>255) {
g=0;
}
if (g<0) {
g=255
}
if (b>255) {
b=0;
}
if (b<0) {
b=255
}
window.document.fgColor=toHex(r)+toHex(g)+toHex(b);
}
setInterval("changeFG()",65);
</script>
>>
>>52887982
> What is generated code ???
>>
https://opensource.apple.com

/thread
>>
>>52890927
i dont get why is this funny... i mean... this is absolutely on purpose nobody ever would do that, so it takes the realism of the funny ones and makes it stupid...
>>
File: uwot.jpg (108 KB, 799x774) Image search: [Google]
uwot.jpg
108 KB, 799x774
these dip memes
>>
>>52891122
Never underestimate human stupidity.
>>
>>52891227
?
>>
>>52891206
>https://opensource.apple.com
no.
>>
>>52888025
>2016
>not writing code that writes your code for you
>>
>>52890927
kek, never gets old
>>
File: oc0.png (71 KB, 694x657) Image search: [Google]
oc0.png
71 KB, 694x657
fucking group projects at uni
>>
>>52888025
no someone must of loop that code in another code
>>
File: csgrad.png (288 KB, 1530x1478) Image search: [Google]
csgrad.png
288 KB, 1530x1478
>>
>>52890865
gets me everytime
>>
>>52890927
But if it's tomorrow, it's no longer tomorrow's date.
>>
File: 1454445220299.png (25 KB, 907x500) Image search: [Google]
1454445220299.png
25 KB, 907x500
>>
>>52893888
umm all 3 are wrong

if(true) method();


is the right way
>>
File: 23mn90xcn4.jpg (84 KB, 729x717) Image search: [Google]
23mn90xcn4.jpg
84 KB, 729x717
>>52887982
Is that real? There's no fucking way that's real.
>>
>>52890473
you might as well have pasted the ascii art on a print statement you fucking idiot
>>
>>52890655
>>52888000
What's wrong with making a integer into a decimal this way? Seems fine to me

6 would become 6.0
42 would become 42.0
>>
>>52894371
it is "fine", but it's completely unnecessary. he went out of his way to do something that was built into java.
>>
>>52894399
Sometimes teachers make you write functions that are already built-in as an exercise. Everyone has probably written a sorting program or multiplication method
>>
File: 2og02nx0v.gif (919 KB, 500x281) Image search: [Google]
2og02nx0v.gif
919 KB, 500x281
>>52894371
i--it doesn't scale, oni cha
>>
>>52894399
>what is casting
>>
>>52887982
>//good luck
>>
http://thedailywtf.com/
>>
>>52887982
...at that point why don't you just use a table
>>
>>52892924
it's yesterday's version of tomorrow's date. let's be real, computers can't look into the future
>>
>>52894775
loop unrooling
>>
>>52890473

Can I ask.....


... why?
>>
>>52894939
For fun. THere were those holiday threads where you were supposed to write programs that print a ascii christmas tree of arbitrary height and I wanted to do it in as many esoteric langs as I could. http://pastebin.com/raw/3jX3XrJj
>>
>>52890708
Brilliant
>>
>>52890708
WHAT WAS THE SECOND GOTO SUPPOSED TO ACCOMPLISH????????????????????????????????

AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAH
>>
>>52890708
but in that code it always goes to fail. am i missing something?
>>
>>52895011
exactly this reaction
looks like it did its job d;^))
>>
>>52895028
REEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
>>
>>52891096
dont get it
>>
someone please post the one that has the "new averaging system" comment.
>>
>>52895044
>le ree
>>
>>52895028
>using the smiley with a carat nose
>>
>>52895047
retarded counter logic
>>
>>52895011
>>52895027
This was actually in an apple product, IIRC. They didn't notice the second goto and because of it their encryption was totally useless until it was fixed.
>>
>>52895097
it looks like there was another conditional there are one point that someone forgot to get rid of entirely, but still. that's retarded
>>
>>52895097
shouldnt static analyzers have caught that?

meaning that function _always_ goes to fail. shouldnt it have raised red flags before it got released?
>>
>>52895097
or even unit tests for that matter
>>
File: 7PuxBDEl.jpg (43 KB, 607x640) Image search: [Google]
7PuxBDEl.jpg
43 KB, 607x640
>>52895061
http://www.daniweb.com/software-development/cpp/threads/440954/cant-fix-error-in-my-program
>>
File: qjNhkn4l.jpg (21 KB, 640x411) Image search: [Google]
qjNhkn4l.jpg
21 KB, 640x411
>>
File: 1446623635719.jpg (15 KB, 250x352) Image search: [Google]
1446623635719.jpg
15 KB, 250x352
>>52895259
>>
>>52895201
>>52895216
Too much objective C rotted their brains beyond the point of being able to use such things, let alone read their code after writing it
>>
>>52895259
hehehehehe

it's funny but oh so true
>>
File: z0AuxwAl.jpg (28 KB, 555x640) Image search: [Google]
z0AuxwAl.jpg
28 KB, 555x640
>>
>>52895336
the cringiest thing there is the comments
>>
File: Ici1lvNl.jpg (34 KB, 640x618) Image search: [Google]
Ici1lvNl.jpg
34 KB, 640x618
>>
>>52895336
who even writes monkey code like this? i forgot people like this existed
>>
File: pxmKXHX.jpg (16 KB, 400x421) Image search: [Google]
pxmKXHX.jpg
16 KB, 400x421
>>
File: 51tjIQtl.jpg (27 KB, 640x555) Image search: [Google]
51tjIQtl.jpg
27 KB, 640x555
>>
>>52895432
fuckin jej
>>
File: 1446614542770.gif (989 KB, 425x240) Image search: [Google]
1446614542770.gif
989 KB, 425x240
>>52895432
>>
>>52895240
>>52895336

Holy shit
>>
>>52887982
what language is that
>>
>>52893974
Of course not,

ftfy:
(if true (method))
>>
File: hCCxSCE.png (78 KB, 461x549) Image search: [Google]
hCCxSCE.png
78 KB, 461x549
>>
>>52895432
so assign to all tweeters the value of gamergater and then tell them "block"
>>
File: JA1y4DRh.jpg (45 KB, 1024x882) Image search: [Google]
JA1y4DRh.jpg
45 KB, 1024x882
>>
>>52895240
>>52895336
>>52895391
>>52895418
Never not funny....

>>52887982
The fucking new champion - this may derail the fucking New Averaging system

>>52892470
I never did a lot of x86 asm - why is this garbage?

>>52894371
works != fine

it's much easier to convert the actual integer to a double... and to display it like that he can just do %.1f in printf (this doesn't look like C\C++ so thats not applicable, but similar shit)


- also i pray that this thread is up tomorrow morning, now that i've got a coding job and coder friends, i'm going to share the fuck outta this
>>
>>52895514
https://github.com/indrora/steam_latest/blob/21cc14158c171f5912b04b83abf41205eb804b31/scripts/steam.sh#L359

    # Scary!
rm -rf "$STEAMROOT/"*


scary indeed if -z "$STEAMROOT"
>>
>>52895240
>it's real
jesus
>>
>>52895432
First error results in a compiler error, i stopped reading where the compiler did

>doing assigns, not boolean comparations
>not moving this in to one if statement and one cout block by using the boolean or
>using endl instead of /n (not a real issue, but fuck off i find /n to be better.)
>>
>>52895622
>using \n
enjoy your non flushed buffer
>>
>>52895622
>find /n to be better
>/n
>/
>////////////////////////////////////////////////


Also
>>52895657
>>
>>52895657
 cout << "Block" << endl; 
>>
File: faggot.png (94 KB, 714x668) Image search: [Google]
faggot.png
94 KB, 714x668
>>52887982
>>
>>52895537
>be microsoft
>skip windows 9 because of the sheer volume of production code that uses this trick

wew lads
>>
>>52887982

Was in a Junior level programming class and the professor was making an object. He titled it some obscure thing like ColorOfLampShade. This kid raised his hand and asked the professor how we're supposed to know whether or not these classes exist and how do we find them.

I just don't understand how he made it that far but didn't know what we were doing?
>>
>>52887982
What the fuck? i had a program for calculating primes in my first year of programming, it was easy as fuck
>>
Make a program: asks the user to input 5 integers and then displays them in ascending order.

C++ limitation.
>>
>>52897602

One guy who graduated in my class literally did not understand variable assignment. Like:

int a = 5;
a = 3;
// Why doesn't a equal five anymore?
>>
>>52895117
It was probably a source control fail. Someone changed the tab stops on the goto to spaces or something pointless and committed it, meanwhile someone else removed the entire condition. git tries to combine the two edits and comes up with that and because it's not a conflict it silently fucks the code. Shit like that happens every once in a blue moon in every source control system I've used. Since it's so rare you tend to trust it even though you really need to look over the diff every time.
>>
>>52887982
>not knowing what wheel factorization is
note that i in the biggest loop is incremented by 30030 = 2*3*5*7*11*13.
it's essentially a more advanced version of "all primes are 1 mod 2" or "all primes are 1 or 5 mod 2*3".
the more primes you use the better complexity you get, although it's probably negligible for reasonable values of n.
and it's obviously generated code so why does it matter
>>
>>52897692
How are you able to graduate any programming class without understanding this, it's literally day 1 stuff
>>
File: stupid-best.jpg (43 KB, 413x427) Image search: [Google]
stupid-best.jpg
43 KB, 413x427
>>52895336
Well, hate to be that guy, but..

If I got the job to maintain some old software and had to add some logic in the case x==y, I would be happy if the segment for that case was already there
>>
>>52897662
#include <iostream>
#include <algorithm>
#include <iterator>
#include <array>

int main() {
std::array<int, 5> a;
std::copy_n(std::istream_iterator<int>(std::cin), a.size(), a.begin());
std::sort(a.begin(), a.end());
std::copy(a.begin(), a.end(), std::ostream_iterator<int>(std::cout));
return 0;
}
>>
>>52893888
It depends on the language

top left is correct in Java and C, bottom left is correct in C#, right is pants on head retarded

>>52893974
Is good javascript
>>
int x = ((((((((((((((((((((((((((((((((0))))))))))))))))))))))))))))))))
>>
>>52897692
Maybe Haskell was his 1st language
>>

>>
>>52898468
Get it? Because it's empty.
>>
File: RSA signing.png (137 KB, 1120x800) Image search: [Google]
RSA signing.png
137 KB, 1120x800
>>52887982

I wonder if anyone is going to get this reference
>>
>>52890865
Sudo in PHP, couldn't possibly go wrong...
>>
>>52891227
No error handling, does not account for beer <=-1
>>
>>52893974
jsfaggot
learn a real language
>>
>>52898518
dick bleed!!
>>
>>52898009
C++ has become so beutiful
>>
>>52898425
>lisp programmer learns C++
>>
>>52898358
it does not depend on the language you moron.
>>
rare real code form real cs grad
free(children); // and fight the power
>>
File: coerce.jpg (84 KB, 890x717) Image search: [Google]
coerce.jpg
84 KB, 890x717
>>52888000
Would be normal in PHP.
>>
>>52895011
I don't get how this was exploitable.

You would think if some signature generation function called "goto fail" every fucking time it was called, giving SSL sites the all clear would be the opposite of what it did.
>>
>>52890708
That's a good reason to always use brackets with these kind of statements.
>>
File: switch.png (78 KB, 694x801) Image search: [Google]
switch.png
78 KB, 694x801
>>
>>52893974
I like wrapping it in brackets, even when there's only one line after the conditional, but this way is fine, as long as it's consistent.
>>
>>52891074
Stop tripfagging /wg/
>>
>>52895432
Shit
>>
>>52895554
>>52892470
this is literally a sleep sort in x86
help me /g/
>>
>Still an amateur at programming
>A lot of these already manage to make me cringe
I can't imagine what this must feel like to experienced people.

Particularly, this one got me: >>52895240
>>
>>52895240
kek someone actually formatted all that mess
>>
>>52900389
I have literally never heard of this before. And I'm someone who's snuck bogosort into production.

http://rosettacode.org/wiki/Sorting_algorithms/Sleep_sort
>>
>>52895815
>be Microsoft
>can't name the OS a roman number instead
>>
>>52897662
It's not that bad...
#include <iostream>
#include <algorithm>
using namespace std;

int main() {
int tab[5];
for(int &i : tab)
cin >> i;

sort(begin(tab), end(tab));

for(int i : tab)
cout << i;
}
>>
>>52893888
>>52893974
All 4 are different degrees of space-saving

t. artist
>>
>>52900606
>I'm someone who's snuck bogosort into production.
How the hell does anyone get away with that?
>>
>>52898009
>std::
>>
The funny thing is though that these CS grads that got degrees from accredited universities have jobs and you NEETs don't.
>>
>>52895240
They can use a do-while loop in huge blocks, but not a for loop and a list or array to make all these things easier. I didn't study it carefully out anything, but I didn't even see any user-defined functions either. This...makes me a little angry actually.
>>
>>52902658
He works at Apple
>>
File: dis nigga aint making sense.png (12 KB, 138x178) Image search: [Google]
dis nigga aint making sense.png
12 KB, 138x178
>>52895259
This is actually a pretty standard Java accessor.
>>
>>52905777
what's the point of wrapping that access in a method call? if the field is meant to be public then just make the damn thing public.
>>
>>52905777
It returns it's only argument...
>>
>>52905942
oh shit I I missed that
>>
>>52905916
Well the idea is that the "sentPackets" variable would have been previously declared private and as such out, of the scope of any other class that might want access. The accessor allows that class to have a reference to the "sentPackets" variable without giving full access.
>>
>>52905992
I'll say again, it returns its only argument. It ain't accessing shit.
>>
>>52905916
> Never worked with access protection.

You can have private setters or instance variables that you don't want to be modified or set manually. You know, like the setup for a Singleton? Oh wait, you don't. Nevermind.
>>
>>52905942
You're right, he didn't need to pass an argument.
>>
>>52905992
>too retarded to see it's an id function
>>
>>52906056
Sounds like overengineered shite desu
>>
File: laughing schoolers.png (121 KB, 508x304) Image search: [Google]
laughing schoolers.png
121 KB, 508x304
>>52906088
>not using encapsulation to secure your code against ID10t errors
>>
>>52901715
Apple would sue them.
>>
>>52895514
NO
NO
NO
>>
>>52895570
That script is gold. Just at the start:
STEAMROOT="$(cd "${0%/*}" && echo $PWD)"
>>
>>52895336
Oh god why
I really wish I could see this guy's thought process at the time
>>
>>52895570
>>52906538
I don't know shit about shell. What's happening?
>>
>>52906684
First one deletes everything on your box, if ran as root and the variable STEAMROOT is undefined/empty.
The second one goes into a directory and returns current directory name instead of fucking just using the name.
>>
>>52895097

>nsa
>>
>>52895336
upon a glance it looked alright.. am i dumb to not immediately see it?
>>
>>52893888
if(true) { //is best because you can put unnecessary comments here
return false;
}
>>
>>52895432
STOP OBJECTIFYING FEMALE PROGRAMMURZ
>>
>>52894630
>not wishing your programs good luck as they journey through your code
>>
>>52907026
if (x >= y) return true;
else return false;

all that other shit is unnecessary
>>
File: 75031.jpg (75 KB, 331x506) Image search: [Google]
75031.jpg
75 KB, 331x506
>>52887982
>//good luck
>>
>>52907106
return x >= y;
>>
>>52895259
>>52905777
A get method doesn't need an argument. A set does.

>>52895514
Rip in peace
>>
>>52907182
Yeah I would not recommend doing that.
There's that fine border between short and readable and very short but not readable.
You look smart, I'll give you that, but it's chaos in debugging or passing it to someone else.
>>
>>52907220
>2016
>using getters and setters
>>
>>52907228
But... Microsoft told me to....
>>
>>52907223
Anyone who can't understand that is a literal retard
>>
>>52907316
I'm afraid there are lots of people out there.
But there must be a reason why nearly all professors tell you that is bad practice, no?
>>
>>52907325
The other way isn't more readable at all. It's the same thing with extra shit for no reason.
>>
>>52894428
I just finished implementing a linked list for the second time in 3 years this morning
>>
>>52907316
this desu
>>
>>52907245
Microsoft is evil
>>
>>52907228

My professors always told me to use getters and setters
I literally don't understand why, I can literally see the code if I'm not passing pointers how the fuck can I even modify it, or what the fuck is going on.
Getters and setters are such a fucking waste of time holy shit
>>
>>52907944
such is life when you are dealing with shit like java where you are fukt if if you start with a public variable and then need to add access control but can not since others might have used the public access in their usage of your code

python is great you can override attribute access in classes if you need to later and people using the class notice no difference.
>>
int clock
while(true)
{
clock +1
wait(1);
}
>>
>>52895622
there are no compile errors on that code, assuming everything is defined
>>
I want to laugh, but I don't understand any of this.
>>
>>52907316
Correct.
>>
https://onedrive.live.com/view.aspx?resid=EBE7DEDA70D06DA0!107&app=PowerPoint&authkey=!AD-O3oq3Ung7pzk
>>
>>52909195
Just started learning to program, completely lost. I like to think everyone is just pretending to laugh and understand
>>
>>52907032
if (true) // why couldn't you put comments here?
{
return false;
}
>>
>>52910152
>I can't understand something so everyone else must not be able to either
>Autism
>>
>>52887982
how would the code be to determinate if a number is prime or not?

i'm assuming this is what this tries to do.

not a codemonkey, btw
>>
>>52895467
Kek. This is funny because when french built the Airbus they thought it was a good idea to make the aircraft scream "RETARD... RETARD..." when the pilot is supposed to pull back the power to idle
>>
>>52910481
There are simple algorithms for it:

https://en.wikipedia.org/wiki/Primality_test

"The simplest primality test is trial division: Given an input number n, check whether any prime integer m from 2 to Sqrt(n) evenly divides n (the division leaves no remainder). If n is divisible by any m then n is composite, otherwise it is prime"

All you need is a loop that checks the modulo from n/2 to n/Sqrt(n), and a condition to get out of the loop once it finds the first instance of a division with no remainder, so the code doesn't stay in the loop unnecessarily.
>>
>>52909195
Don't worry, they aren't any funnier when you do. Just snippets of bad code, none of them bad in any particularly funny way.
>>
>>52910481

The way you should code it is more like this:

unsigned long long int root2(unsigned long long int n) {
if(n==0)
return 0;
if(n==1)
return 1;
unsigned long long int i=0,f=(static_cast<unsigned long long>(1)<<32);
unsigned long long int j=(static_cast<unsigned long long>(1)<<31);
while(1)
{
if((n/j==j)||(n/j==(j+1))||(i==f)){
return j;
}
if((n/j==(j-1)))
return j-1;
else if(n/j>j)
i=j;
else
f=j;
j=(i+f)/2;
}
return j;
}

void coprimes_init(unsigned long long int * coprimearray, unsigned long long int mod, unsigned long long int order){
bool * coprimeTest = new bool[order];
for(unsigned long long int i=0;i<mod;i++){
coprimeTest[i]=true;
}
for(unsigned long long int i=0;i<primeNum;i++){
unsigned long long int index=primearray[i]*primearray[i];
coprimeTest[primearray[i]]=false;
while(index<mod){
coprimeTest[index]=false;
index+=primearray[i];
}
}
for(unsigned long long int i=1,j=0;i<mod;i++){
if(coprimeTest[i]){
coprimearray[j++]=i;
}
}
delete coprimeTest;
return;
}

bool primeChecker(unsigned long long int n){//Abandon hope all ye who enter here

const size_t primeNum=6;
const unsigned long long int primearray[primeNum]={2,3,5,7,11,13};
unsigned long long int mod=1, order=1;
if((n==0)||n==1)
return false;
for(unsigned long long int i = 0; i<primeNum; i++){
order*=(primearray[i]-1);
mod*=primearray[i];
if( n==primearray[i] )
return true;
else if(n%primearray[i]==0)
return false;
}
static bool init=false;
static unsigned long long int * coprimearray=new unsigned long long int[order];
if(!init){
coprimes_init(coprimearray, mod, order);
init=true;
}
unsigned long int root=static_cast<unsigned long int>(root2(n));
if((n%root)==0)
return false;
unsigned long long int test=coprimearray[1], i=1;
do{
if(n%test==0)
return false;
i++;
if(i==order){
i=0;
test++;
}
test+=coprimearray[i];
}while(test<root);
return true;
}
>>
>>52893974
If(whatever){
method;
}
>>
>>52912757
if(2==1==0){
(*method)();
}
>>
>>52913250
Oh my god this takes the cake holy shit
>>
>>52910166
>>
>>52894593
Grow up
>>
>>52913944
fucking disgusting
half the point of allman style is the horizontal blank spaces separating scopes

might as well go
if (true)
/* I MAGE GOMMENDZ :DDD */{
return false;
} //:-DDDDDDDDDDDD
>>
>>52913962
I prefer the natural flow from the if statement, to an explanation of what is to come.

I prefer at a glance readability.
>>
>>52907944
>what is OOP?
>>
>>52913994

>OOP requires getters/setters

Ok mate.
>>
>>52915476
this.pussy.set(me.penis.get(HARD))
>>
>>52915476
If you want to have absolute control over there internal state and values of your objects, it's usually a good idea to have setters and getters. However, if your idea of oop is glorified structs, then no. They're not necessary.
>>
>>52915535
>However, if your idea of oop is glorified structs, then no

But they are, they just have inhertience and shit
>>
>>52915476
>what is encapsulation
>>
File: mathsinjava.jpg (57 KB, 674x490) Image search: [Google]
mathsinjava.jpg
57 KB, 674x490
>>52905777
>>
>>52915901

What's wrong with this?
>>
>>52907944
>>52915476
>>52915535
if you create getters and setters to the attributes of your class, why not making them public ?
For me using getters and setters is stupid. We make them private so a retard won't change it as he wants and will use the methods do to something specific.
>>
>>52917064
you use getters and setters if you need to check the values (if you want to enforce the .age attribute of a Person isn't set to something like -3 or 189.2)
>>
>>52917064
Sometimes you need to add some behaviour in set/get, if you use public attributes in the API you will be really fucked
>>
>>52913992
depends on what the comment describes, you put in the appropriate space

if it describes the condition, you put it on the same line or above
if it describes what happens inside the block, you put it there

it's not hard
>>
I see this pattern at work all the time. Trigger Warning: We use JavaScript.

 doThing(poo, function (err) {
...
});


Cool, let's see what doThing is up to...

 function doThing (poop, callback) {
try {
someGlobalArray.push(poop);
} catch (err) {
console.log(err);
}

callback();
return false;
}


One dude wrote all the code I'm paraphrasing there. Like he has multiple personality disorder and they're both fucking clinically retarded.
Thread replies: 202
Thread images: 34

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.