Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
/13@yegor256 1
Utility классы нас убивают
Yegor Bugayenko
Utility Classes Are
Killing Us
/13@yegor256 2
/13@yegor256 3
10 N = INT(RND(1) * 100)
20 T = T + 1
30 IF T > 5 THEN GOTO 120
40 PRINT "Guess a number in 0..100 range: "...
/13@yegor256 4
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(int argc, char** argv) {
srand(time(NULL)...
/13@yegor256 5
import java.util.Scanner;
public class Main {
public static void main(String... args) {
int n = (int) (Math...
/13@yegor256 6
import java.util.Scanner;
public class Main {
public static void main(String... args) {
int n = (int) (Math...
/13@yegor256 7
import java.util.Scanner;
public class Main {
public static void main(String... args) {
int n = (int) (Math...
/13@yegor256 8
No stateу них нет состояния
/13@yegor256 9
class InputUtils {
public static int read() {
System.out.print(
"Guess a number in 0..100 range: “
);
retur...
/13@yegor256 10
import java.util.Scanner;
public class Main {
public static void main(String... args) {
int n = (int) (Mat...
/13@yegor256 11
new Farewell(
new Attempts(
new VerboseDiff(
new Diff(
new Secret() as secret,
new Guess()
)
), 5
),
secret
...
/13@yegor256 12
n
t
x System.out.print(
"Guess a number in 0..100 range: “
);
new Scanner(System.in).nextInt();
if (x < n)...
/13@yegor256 13
import java.util.Scanner;
public class Main {
public static void main(String... args) {
int n = (int) (Mat...
/13@yegor256 14
You’ve finished this document.
Download and read it offline.
Upcoming SlideShare
What to Upload to SlideShare
Next
Upcoming SlideShare
What to Upload to SlideShare
Next
Download to read offline and view in fullscreen.

0

Share

Utility Classes Are Killing Us

Download to read offline

JBreak 2017; Novosibirsk, Russia; 4 April 2017; video is here: https://www.youtube.com/watch?v=85B3FV_sB60

Related Books

Free with a 30 day trial from Scribd

See all

Related Audiobooks

Free with a 30 day trial from Scribd

See all
  • Be the first to like this

Utility Classes Are Killing Us

  1. 1. /13@yegor256 1 Utility классы нас убивают Yegor Bugayenko Utility Classes Are Killing Us
  2. 2. /13@yegor256 2
  3. 3. /13@yegor256 3 10 N = INT(RND(1) * 100) 20 T = T + 1 30 IF T > 5 THEN GOTO 120 40 PRINT "Guess a number in 0..100 range: " 50 INPUT X 60 IF X < N THEN PRINT "Too small." 70 IF X > N THEN PRINT "Too big." 80 IF X = N THEN GOTO 100 90 GOTO 20 100 PRINT "Bingo!" 110 GOTO 130 120 PRINT "You lost, sorry. It was: ", N 130 PRINT "Thanks for playing with me!"
  4. 4. /13@yegor256 4 #include <stdio.h> #include <stdlib.h> #include <time.h> int main(int argc, char** argv) { srand(time(NULL)); int x, t=0, n=rand() % 100; while (++t <= 5) { printf("Guess a number in 0..100 range: "); scanf("%d", &x); if (x > n) { printf("Too big.n"); } else if (x < n) { printf("Too small.n"); } else { break; } } if (t < 5) { printf("Bingo!n"); } else { printf("You lost, sorry. It was: %dn", n); } printf("Thanks for playing with me!n"); }
  5. 5. /13@yegor256 5 import java.util.Scanner; public class Main { public static void main(String... args) { int n = (int) (Math.random() * 100.0d); int t = 0; while (true) { if (++t > 5) { System.out.println("You lost, sorry. It was: " + n); break; } System.out.print("Guess a number in 0..100 range: "); int x = new Scanner(System.in).nextInt(); if (x < n) { System.out.println("Too small."); } else if (x > n) { System.out.println("Too big."); } else { System.out.println("Bingo!"); break; } } System.out.println("Thanks for playing with me!"); } }
  6. 6. /13@yegor256 6 import java.util.Scanner; public class Main { public static void main(String... args) { int n = (int) (Math.random() * 100.0d); int t = 0; while (true) { if (++t > 5) { System.out.println("You lost, sorry. It was: " + n); break; } System.out.print("Guess a number in 0..100 range: "); int x = new Scanner(System.in).nextInt(); if (x < n) { System.out.println("Too small."); } else if (x > n) { System.out.println("Too big."); } else { System.out.println("Bingo!"); break; } } System.out.println("Thanks for playing with me!"); } } System.out.print("Guess a number in 0..100 range: "); int x = new Scanner(System.in).nextInt();
  7. 7. /13@yegor256 7 import java.util.Scanner; public class Main { public static void main(String... args) { int n = (int) (Math.random() * 100.0d); int t = 0; while (true) { if (++t > 5) { System.out.println("You lost, sorry. It was: " + n); break; } int x = InputUtils.read(); if (x < n) { System.out.println("Too small."); } else if (x > n) { System.out.println("Too big."); } else { System.out.println("Bingo!"); break; } } System.out.println("Thanks for playing with me!"); } } class InputUtils { public static int read() { System.out.print( "Guess a number in 0..100 range: “ ); return new Scanner(System.in).nextInt(); } }
  8. 8. /13@yegor256 8 No stateу них нет состояния
  9. 9. /13@yegor256 9 class InputUtils { public static int read() { System.out.print( "Guess a number in 0..100 range: “ ); return new Scanner(System.in).nextInt(); } } class NumberUtils { public static int compare(int x, int n) { if (x < n) { System.out.println("Too small."); } else if (x > n) { System.out.println("Too big."); } else { System.out.println("Bingo!"); } } } class RandomUtils { public static int make() { return (int) (Math.random() * 100.0d); } } class WhateverUtils { public static int build() { return ?; } } n t x
  10. 10. /13@yegor256 10 import java.util.Scanner; public class Main { public static void main(String... args) { int n = (int) (Math.random() * 100.0d); int t = 0; while (true) { if (++t > 5) { System.out.println("You lost, sorry. It was: " + n); break; } new Guess(); if (x < n) { System.out.println("Too small."); } else if (x > n) { System.out.println("Too big."); } else { System.out.println("Bingo!"); break; } } System.out.println("Thanks for playing with me!"); } } class Guess implements Integer { @Override public int value() { System.out.print( "Guess a number in 0..100 range: “ ); return new Scanner(System.in).nextInt(); } }
  11. 11. /13@yegor256 11 new Farewell( new Attempts( new VerboseDiff( new Diff( new Secret() as secret, new Guess() ) ), 5 ), secret ).say();
  12. 12. /13@yegor256 12 n t x System.out.print( "Guess a number in 0..100 range: “ ); new Scanner(System.in).nextInt(); if (x < n) { System.out.println("Too small."); } else if (x > n) { System.out.println("Too big."); } else { System.out.println("Bingo!"); }(int) (Math.random() * 100.0d);
  13. 13. /13@yegor256 13 import java.util.Scanner; public class Main { public static void main(String... args) { int n = (int) (Math.random() * 100.0d); int t = 0; while (true) { if (++t > 5) { System.out.println("You lost, sorry. It was: " + n); break; } System.out.print("Guess a number in 0..100 range: "); int x = new Scanner(System.in).nextInt(); if (x < n) { System.out.println("Too small."); } else if (x > n) { System.out.println("Too big."); } else { System.out.println("Bingo!"); break; } } System.out.println("Thanks for playing with me!"); } } new Farewell( new Attempts( new VerboseDiff( new Diff( new Secret() as secret, new Guess() ) ), 5 ), secret ).say();
  14. 14. /13@yegor256 14

JBreak 2017; Novosibirsk, Russia; 4 April 2017; video is here: https://www.youtube.com/watch?v=85B3FV_sB60

Views

Total views

568

On Slideshare

0

From embeds

0

Number of embeds

3

Actions

Downloads

5

Shares

0

Comments

0

Likes

0

×