Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-4041-

Counter.java

Name: Anonymous 2014-09-04 11:02

why the fuck do retards have to invent a goddamned class just to use a goddamned integer? have people no shame?

Counter.java

/**
* A simple counter class that can be initialized to
* a specific value, incremented, and cleared.
* @author Owen Astrachan
*/

public class Counter
{
int myCount;

/**
* Construct a counter whose value is zero.
*/
public Counter()
{
myCount = 0;
}

/**
* Construct a counter with given initial value.
* @param init is the initial value of the counter
*/

public Counter(int init)
{
myCount = init;
}

/**
* Returns the value of the counter.
* @return the value of the counter
*/
public int getValue()
{
return myCount;
}

/**
* Zeros the counter so getValue() == 0.
*/
public void clear()
{
myCount = 0;
}

/**
* Increase the value of the counter by one.
*/
public void increment()
{
myCount++;
}

/**
* Return a string representing the value of this counter.
* @return a string representation of the value
*/

public String toString()
{
return ""+myCount;
}
}

Name: Anonymous 2014-09-04 11:13

why the fuck do retards have to post code without code tags? have people no shame?

Name: Anonymous 2014-09-04 16:26

Now, compare it to other languages:

C:
count++;

asm:
inc

FIOC:
count += 1

so clearly assembly is the best

Name: Anonymous 2014-09-04 18:13

(1+ count)

Name: Anonymous 2014-09-04 18:55

>>1

Using classes for trivial things considered best practice in Java.

Name: Anonymous 2014-09-04 18:59

>>1

@author Owen Astrachan
He is actually a Ph.D and holds university position.
http://en.wikipedia.org/wiki/Owen_Astrachan

Education is surely overpriced.

Name: Anonymous 2014-09-04 19:05

http://en.wikipedia.org/wiki/Owen_Astrachan
Astrachan is well known as the creator of "The All-Green Dance". Beginning as a small-scale, local phenomenon, "The All-Green Dance" has blossomed into a world-renowned craze. Astrachan teaches his dance to his students at Duke University every year, see [5].

Explains it all.

Name: Anonymous 2014-09-04 20:54

java has counted the anum

Name: Anonymous 2014-09-05 4:56

I think this may just be an example of a class for people learning java.

Name: Cudder !MhMRSATORI 2014-09-05 11:40

>>9
It's a horrible example, which upon further Googling appears to come from this disgusting ENTERPRISE ABSTRACT BULLSHITE-filled treatise: http://introcs.cs.princeton.edu/java/33design/ . OP should definitely submit it to The Daily WTF.

>>6,7
These ivory-tower architecture-astronaut abstraction-worshipping academics are entirely what's wrong with computer science. I can't stand reading through all of that link above but here's the part that's relevant to OP's WTF-inducing class:

Program Counter.java implements a counter, e.g., for an electronic voting machine. It encapsulates a single integer to ensure that it can only get incremented by one at at time and to ensure that it never goes negative. The goal of data abstraction is to restrict which operations you can perform. Can ensure that data type value always remains in a consistent state. Can add logging capability to hit(), e.g., to print timestamp of each vote. In the 2000 presidential election, Al Gore received negative 16,022 votes on an electronic voting machine in Volusia County, Florida. The counter variable was not properly encapsulated in the voting machine software!

THIS IS ABSOLUTE BULLSHIT. The bug is not because of "encapsulation", "information hiding", "abstraction", or any other politically-correct buzzword that's trendy these days. It is, plainly and simply, because whoever wrote that code was an idiot!

Theme = limit what you, the programmer, can do.

What the goddamn motherfucking bloody cuntshit!? If programmers are causing bugs, then it is absolutely the wrong thing to do to try to make it impossible for them to create bugs, because then they'll just never learn and their brains will decay instead. This naturally causes a feedback loop where the academics then try to come up with even more restrictive languages, and the programmers get even stupider in response, etc. It's the perfect solution to control-freak management in corporations whose goals are (implicitly) to take over the world - make everyone else stupid, so they can rule. Why else do you think we're seeing computers and OSs become more "secure", "encapsulated", and "user-friendly"? Knowledge is power and the corporations who want to control their users don't want them to know so much about how things really work, because an intelligent user/programmer is one who will be far less easy to manipulate. They can espouse all the benefits of "information hiding" with candy-coated words but it doesn't change the fact that it's a clever way of discouraging people from "knowing too much"!

Seeing this shit spewing from the mouth of someone who is in the education system, in a position of power, is overwhelmingly rage-inducing. They're deliberately turning people who potentially are very intelligent and creative into mindless drones/slaves, and if you don't think this is bad, you've likely been brainwashed already... The right way forward is to improve programmer education (i.e. not feed them this tripe), by letting them make mistakes so they'll learn from them.

"Freedom is not worth having if it does not include the freedom to make mistakes."
"Those who give up freedom for security deserve neither."

/rant

Name: Anonymous 2014-09-05 13:18

>>7

Is Astrachan a jewish name?

Name: Anonymous 2014-09-05 14:04

>>9
This is usually done not by the ivory-tower abstraction-worshipping ``academics'', because that kind of people roam in the CORPORATE world. It's just a few of them that are frustrated because they wanted to apply BEST BUSINESS PRACTICES in a REAL WORLD ENVIRONMENT but they were too dumb and were hired by a second-rate university instead. This has nothing to do with being obsessed with abstraction, it's about doing what other Indian monkeys tell you to do in order to deserve that stupid looking business and the smug look, because otherwise you're just a neurotypical nigger spewing enterprise-y bullshit from an office desk.

Academia has nothing to do with this. If anything, it's the Lisp/Haskal weebs who can be called ivory-tower academics.

Name: Anonymous 2014-09-05 14:31

Please leave some messages for our friend Astra-chan. I'll be emailing him a link to this thread.

Name: Anonymous 2014-09-05 14:46

also, this faggot is another feminista:
http://www.youtube.com/watch?v=wGcXtqzTJHQ

Name: Anonymous 2014-09-05 14:51

Astra-chan, which Touhou Project character would you engage in sexual intercourse with?

Name: Anonymous 2014-09-05 15:15

>>11

Yes. It is Eastern European name and he could be Jewish. Astrachans's hidden agenda is dumbing down American education. He advocates implementing "no child left behind" (no nigger, no woman, etc...) policy on university level. Astrachans is either a useful idiot or outright paid by Russia or China.

Name: Anonymous 2014-09-05 15:57

>>10
Wow, your rant actually touched me. But keep in mind that restrictive languages allow for automatic verification which is something qualitatively different from testing and human code reviewing. No matter how good a programmer is, there is always a critical mass of LOC above which he won't be able to keep it all in his mind, and the only way to ensure the absence of at least a subset of errors is through automatic program verification.

Name: Anonymous 2014-09-05 15:59

yo cudder do you like have a day job?

are you a freelancer?

Name: Anonymous 2014-09-05 16:38

>>10

Actually, abstraction is useful, when you can assemble system from large parts, each having a well defined interface. For example, Lisp System can be assembled from reader, codewalker, compiler and package manager The problem is that such approach is justified mostly when parts are sufficiently large and managed by different developers. There is also so called test driven development, where you write code the way assisting unit testing and run units test after each modification. But TDD imposes even large maintenance costs than static typing - don't use it for anything but spacecraft navigation controllers.

Name: Anonymous 2014-09-05 16:39

Name: Anonymous 2014-09-05 16:48

>>20

https://www.youtube.com/watch?v=EjkKiC6qKoU&list=UUsWhiiIgYVtMPRULpV1Ww7Q
AMAL KOTBI
i cant stop keep noticing that all of them just soo ugly LOL
it is funny how Arabian girl comments that Jews are ugly, because middle easterns are all ugly.

Name: Anonymous 2014-09-05 17:24

>>21
Jews are the ugliest though

Name: Anonymous 2014-09-05 18:29

>>21,22
None of them are as ugly as the slit-eyed Asian zerg, though.

Name: Anonymous 2014-09-05 18:54

>>23
Kekekeke urinara manse

Name: Anonymous 2014-09-05 18:58

>>23

Fuck you. Japanese are cuties.

Name: Anonymous 2014-09-05 19:01

>>25
Japanese are not zerg, thats the koreans

Name: Anonymous 2014-09-05 19:03

>>24
Koreans are hot, kinda prudish though.

Name: Anonymous 2014-09-05 19:14

>>27

We should issue you one way ticket to North Korea.

Name: Anonymous 2014-09-05 19:21

the counter example is dumb. It shows how far behind we are with program verification. They've made an integer that can't decrease in value. That's great. But does that restrict the counter to increment with the number of voters that voted for the candidate? Of course not. The programmer still has to get that right and using an integer that can't decrease doesn't make it any easier. The restricted interface also imposes difficulty. What if the algorithm doesn't go through all the voters, one at a time? What if they are processed in groups and merged? If anything, votes are implemented with database transactions and the number of votes is retrieved with a query. I bet the database library doesn't use a counter class to count the number of matching rows.

Name: Anonymous 2014-09-05 19:36

What do you mean I can't vote because I'm dead?!?

Name: Anonymous 2014-09-05 19:38

>>29

If future elections would allow revoting votes, then you'll have to implement decrement, redesigning entire class and possible the places that use it.

Name: Anonymous 2014-09-05 19:40

>>28
North Koreans ain't got no seoul.

Name: Anonymous 2014-09-05 20:02

>>32
They'll take it back.

Name: Anonymous 2014-09-05 20:08

>>27

Koreans are not hot, they are colder than a dead nigga in the hoods of detroit.

Name: Anonymous 2014-09-05 21:01

>>17
Well that just means the programmer isn't intelligent.

has nothing to do about being a good programmer.

get on my level, total photographic memory of and total intuitive unconscious comprehension of multi-millions of lines.

Name: Anonymous 2014-09-06 4:44

>>26
Yes they are, they reproduce like parasites and fill all available territory completely, also the Japanese have an overmind and they are trying to infest the whole world. This is all more true in respect to the Chinese, but the Japanese are like that too - 120 million zerg on a patch of land smaller than California.

Name: Anonymous 2014-09-06 5:05

>>36

Whatever you say, nida.

Name: Anonymous 2014-09-06 7:07

>>37
Polish my shoes, n'wah.

Name: Anonymous 2014-09-06 9:18

>>35
Yeah well my penis is 40cm long.

Name: Cudder !MhMRSATORI 2014-09-06 11:43

>>18
Yes, no.

>>19
There's a difference between using abstraction because you understand what it abstracts and how it can be useful and what the limitations are, and using it because someone told you to.

It's like giving a kid a calculator and telling her ("maths is hard!") that it'll solve all her homework maths problems. Sure it works for the simple stuff, and she'll feel like she won't ever have to learn arithmetic, but what if the result overflows? Even worse, what if it produces subtly wrong answers? Someone who doesn't know how arithmetic works can be easily made to believe that 2+2=5, 1+4=7, or whatever the calculator says, in the same way that someone who doesn't understand software can be persuaded to believe anything about how computers work. A calculator is a (very leaky) abstraction, just like software.

Thankfully there are sane people teaching maths (http://www.bbc.com/news/education-20259382 ), but unfortunately this hasn't been true for computer science.

>>13
You might do better to copy the useful posts only, and leave out the /pol/ idiots.

Name: Anonymous 2014-09-06 12:01

>>10
>>41
protip: computer science is not a course in programming. If you want a course in programming, you do a programming course. Computer science is about the theory of information and computation.

Name: Anonymous 2014-09-06 13:01

It doesn't even check for an overflow condition. Also, for a voting machine it should have some sort of access control on the count reset.

Name: Anonymous 2014-09-06 13:12

>>41-nigger was exploded before he could optimise his quotes

Name: Anonymous 2014-09-06 18:13

>>40
Shalom!

Name: Anonymous 2014-09-07 0:23

>>42
Zeroed your counter, nida!

Name: Anonymous 2014-09-07 2:09

def makeInc(x):
def inc(y):
# x is "closed" in the definition of inc
return y + x
return inc


/THREAD

Name: Anonymous 2014-09-07 4:49

>>46
top kek, you are even dumber than astra-chan.

Name: Cudder !MhMRSATORI 2014-09-07 13:42

>>29,31
votes[candidate]++;

OOP and the rest of that ENTERPRISE BULLSHITE is in some way really clever; it makes it far easier for many people to get paid doing what looks like really productive work. It's a great method of expanding work to keep people employed at all costs. A single person with a few days would probably be enough to write the whole software for a voting machine, at very little cost, but when the job is given to some huge company it ends up turning into a bloated monstrosity "requiring" tens or even hundreds of people over months or years and going overbudget, and the product still contains bugs!

You don't even need a database to count votes; assuming there are less than 257 candidates in any single vote, the largest country in the world still requires less than 2GB if every single person in it (and that's including people who can't vote) got a byte to put their choice in.

The costs of running a database - which probably means licensing fees, server costs (disk, OS, power, etc.), and a team of overpaid DBAs and "developers", can be replaced by a single memory device costing less than $10.

Of course they'll probably complain and give all sorts of reasons why a database is "needed", but that's just because they're desperate to keep their jobs... no, I think a DB is absolutely NOT needed for this application. Vote data is vote data. It's created to be counted. It doesn't need anywhere near the processing flexibility that a database gives.

Name: Anonymous 2014-09-07 14:07

>>48
I love you, Cudder-dono.

Name: Anonymous 2014-09-07 14:28

>>49
* donna Cudder

Name: Anonymous 2014-09-07 15:42

>>48
To help protect against voter fraud, there should be some redundancy in the data collected. For worst anonymity, the voter's id is attached to their vote with timestamp and the table is made public. Each voter can confirm their vote. Everyone can perform a recount and that published voters are alive. If someone suspects a voter didn't actually go to the polls, they can contact them and use an alibi to prove voter fraud occurred.

Name: Anonymous 2014-09-07 18:14

>>50
The -dono honorific is gender-neutral.

Name: Anonymous 2014-09-07 18:38

>>48
Shalom!

Name: Anonymous 2014-09-07 21:17

Name: Anonymous 2014-09-07 21:44

>>54
Computer Science with C++
bad reviews
not surprising

Name: L. A. Calculus !jYCj6s4P.g 2014-09-07 22:30

>>1
WAT KINDA PLASTIC FISHER'S PRICE RETOID WUD WRITE DAT SHIT? YAINT RED DA FUCKIN STANDARD
#include <stdio.h>

#define MAXDIGITS 3

struct count {
char base[MAXDIGITS + 1];
char *s, *endp;
};

void clear(struct count *countp)
{
countp->s = countp->base + MAXDIGITS - 1;
*countp->s = '0';
countp->endp = countp->base + MAXDIGITS;
*countp->endp = '\0';
}

int increment(struct count *countp)
{
char *p;

for (p = countp->endp; p > countp->s; *p = '0')
if (*--p != '9') {
++*p;
return 0;
}
if (countp->s == countp->base)
return 1;
*--countp->s = '1';
return 0;
}

int main(void)
{
struct count count;

clear(&count);
while (increment(&count) == 0)
puts(count.s);
return 0;
}

Name: Anonymous 2014-09-08 9:13

BeanCounter.java

Name: Anonymous 2014-09-08 14:57

Who are you quoting, >>55-kun?

Name: /jewtube/ 2014-09-08 15:58

>>58
Some Canadian Amazon reviewer obviously.

Name: Anonymous 2016-11-10 17:55

>>55
even my intructor said this book is not book

Name: Anonymous 2016-11-10 23:33

Name: Anonymous 2016-11-10 23:35

(define (make-counter)
(let ((value 0))
(lambda ()
(set! value (+ value 1))
value)))

Name: Cudder !cXCudderUE 2016-11-11 2:59

http://www.cs.duke.edu/csed/poop/huff/

Found more bullshit (I am not sure if the URL is meant to be satirical) from the same guy.

Huffman Coding, sounds like a good thing to have students play with. That I agree with. What's wrong? Everything else. Explicitly storing Huffman trees, actually using a tree for the algorithm, turning dozen-liners into multiclass ENTERPRISE monstrosities, and ignoring the simplicity and elegance of Canonical Huffman are things that no one actually does in the real world.

Name: Anonymous 2016-11-11 4:13

>>63
poop

Name: Anonymous 2016-11-11 6:01

Check em

Name: Anonymous 2016-11-11 6:07

>>65
You want me to check those? You better get ready to check my dubs.

Name: Anonymous 2016-11-11 15:24

>>63
/poop/huff
that was jenkem quality!

Don't change these.
Name: Email:
Entire Thread Thread List