SlideShare a Scribd company logo
1 of 14
Download to read offline
/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: "
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!"
/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");
}
/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!");
}
}
/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();
/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();
}
}
/13@yegor256 8
No stateу них нет состояния
/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
/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();
}
}
/13@yegor256 11
new Farewell(
new Attempts(
new VerboseDiff(
new Diff(
new Secret() as secret,
new Guess()
)
), 5
),
secret
).say();
/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@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();
/13@yegor256 14

More Related Content

What's hot

The Ring programming language version 1.5.4 book - Part 52 of 185
The Ring programming language version 1.5.4 book - Part 52 of 185The Ring programming language version 1.5.4 book - Part 52 of 185
The Ring programming language version 1.5.4 book - Part 52 of 185Mahmoud Samir Fayed
 
The Ring programming language version 1.5.2 book - Part 51 of 181
The Ring programming language version 1.5.2 book - Part 51 of 181The Ring programming language version 1.5.2 book - Part 51 of 181
The Ring programming language version 1.5.2 book - Part 51 of 181Mahmoud Samir Fayed
 
The Ring programming language version 1.8 book - Part 59 of 202
The Ring programming language version 1.8 book - Part 59 of 202The Ring programming language version 1.8 book - Part 59 of 202
The Ring programming language version 1.8 book - Part 59 of 202Mahmoud Samir Fayed
 
The Ring programming language version 1.7 book - Part 55 of 196
The Ring programming language version 1.7 book - Part 55 of 196The Ring programming language version 1.7 book - Part 55 of 196
The Ring programming language version 1.7 book - Part 55 of 196Mahmoud Samir Fayed
 
The Ring programming language version 1.9 book - Part 60 of 210
The Ring programming language version 1.9 book - Part 60 of 210The Ring programming language version 1.9 book - Part 60 of 210
The Ring programming language version 1.9 book - Part 60 of 210Mahmoud Samir Fayed
 
The Ring programming language version 1.7 book - Part 57 of 196
The Ring programming language version 1.7 book - Part 57 of 196The Ring programming language version 1.7 book - Part 57 of 196
The Ring programming language version 1.7 book - Part 57 of 196Mahmoud Samir Fayed
 
PyCon2009_AI_Alt
PyCon2009_AI_AltPyCon2009_AI_Alt
PyCon2009_AI_AltHiroshi Ono
 
関数プログラミングことはじめ revival
関数プログラミングことはじめ revival関数プログラミングことはじめ revival
関数プログラミングことはじめ revivalNaoki Kitora
 
The Ring programming language version 1.3 book - Part 42 of 88
The Ring programming language version 1.3 book - Part 42 of 88The Ring programming language version 1.3 book - Part 42 of 88
The Ring programming language version 1.3 book - Part 42 of 88Mahmoud Samir Fayed
 
The Ring programming language version 1.9 book - Part 61 of 210
The Ring programming language version 1.9 book - Part 61 of 210The Ring programming language version 1.9 book - Part 61 of 210
The Ring programming language version 1.9 book - Part 61 of 210Mahmoud Samir Fayed
 
The Ring programming language version 1.2 book - Part 38 of 84
The Ring programming language version 1.2 book - Part 38 of 84The Ring programming language version 1.2 book - Part 38 of 84
The Ring programming language version 1.2 book - Part 38 of 84Mahmoud Samir Fayed
 
The Ring programming language version 1.6 book - Part 53 of 189
The Ring programming language version 1.6 book - Part 53 of 189The Ring programming language version 1.6 book - Part 53 of 189
The Ring programming language version 1.6 book - Part 53 of 189Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 70 of 212
The Ring programming language version 1.10 book - Part 70 of 212The Ring programming language version 1.10 book - Part 70 of 212
The Ring programming language version 1.10 book - Part 70 of 212Mahmoud Samir Fayed
 
Homemade GoTo mount for Telescopes using Nylon wheels, GT2 belts and 100:1 ge...
Homemade GoTo mount for Telescopes using Nylon wheels, GT2 belts and 100:1 ge...Homemade GoTo mount for Telescopes using Nylon wheels, GT2 belts and 100:1 ge...
Homemade GoTo mount for Telescopes using Nylon wheels, GT2 belts and 100:1 ge...Janis Alnis
 
The Ring programming language version 1.5.2 book - Part 50 of 181
The Ring programming language version 1.5.2 book - Part 50 of 181The Ring programming language version 1.5.2 book - Part 50 of 181
The Ring programming language version 1.5.2 book - Part 50 of 181Mahmoud Samir Fayed
 
The Ring programming language version 1.3 book - Part 40 of 88
The Ring programming language version 1.3 book - Part 40 of 88The Ring programming language version 1.3 book - Part 40 of 88
The Ring programming language version 1.3 book - Part 40 of 88Mahmoud Samir Fayed
 
The Ring programming language version 1.8 book - Part 66 of 202
The Ring programming language version 1.8 book - Part 66 of 202The Ring programming language version 1.8 book - Part 66 of 202
The Ring programming language version 1.8 book - Part 66 of 202Mahmoud Samir Fayed
 
The Ring programming language version 1.5.4 book - Part 46 of 185
The Ring programming language version 1.5.4 book - Part 46 of 185The Ring programming language version 1.5.4 book - Part 46 of 185
The Ring programming language version 1.5.4 book - Part 46 of 185Mahmoud Samir Fayed
 

What's hot (20)

The Ring programming language version 1.5.4 book - Part 52 of 185
The Ring programming language version 1.5.4 book - Part 52 of 185The Ring programming language version 1.5.4 book - Part 52 of 185
The Ring programming language version 1.5.4 book - Part 52 of 185
 
The Ring programming language version 1.5.2 book - Part 51 of 181
The Ring programming language version 1.5.2 book - Part 51 of 181The Ring programming language version 1.5.2 book - Part 51 of 181
The Ring programming language version 1.5.2 book - Part 51 of 181
 
The Ring programming language version 1.8 book - Part 59 of 202
The Ring programming language version 1.8 book - Part 59 of 202The Ring programming language version 1.8 book - Part 59 of 202
The Ring programming language version 1.8 book - Part 59 of 202
 
The Ring programming language version 1.7 book - Part 55 of 196
The Ring programming language version 1.7 book - Part 55 of 196The Ring programming language version 1.7 book - Part 55 of 196
The Ring programming language version 1.7 book - Part 55 of 196
 
The Ring programming language version 1.9 book - Part 60 of 210
The Ring programming language version 1.9 book - Part 60 of 210The Ring programming language version 1.9 book - Part 60 of 210
The Ring programming language version 1.9 book - Part 60 of 210
 
The Ring programming language version 1.7 book - Part 57 of 196
The Ring programming language version 1.7 book - Part 57 of 196The Ring programming language version 1.7 book - Part 57 of 196
The Ring programming language version 1.7 book - Part 57 of 196
 
PyCon2009_AI_Alt
PyCon2009_AI_AltPyCon2009_AI_Alt
PyCon2009_AI_Alt
 
関数プログラミングことはじめ revival
関数プログラミングことはじめ revival関数プログラミングことはじめ revival
関数プログラミングことはじめ revival
 
The Ring programming language version 1.3 book - Part 42 of 88
The Ring programming language version 1.3 book - Part 42 of 88The Ring programming language version 1.3 book - Part 42 of 88
The Ring programming language version 1.3 book - Part 42 of 88
 
The Ring programming language version 1.9 book - Part 61 of 210
The Ring programming language version 1.9 book - Part 61 of 210The Ring programming language version 1.9 book - Part 61 of 210
The Ring programming language version 1.9 book - Part 61 of 210
 
The Ring programming language version 1.2 book - Part 38 of 84
The Ring programming language version 1.2 book - Part 38 of 84The Ring programming language version 1.2 book - Part 38 of 84
The Ring programming language version 1.2 book - Part 38 of 84
 
pptuni1
pptuni1pptuni1
pptuni1
 
New
NewNew
New
 
The Ring programming language version 1.6 book - Part 53 of 189
The Ring programming language version 1.6 book - Part 53 of 189The Ring programming language version 1.6 book - Part 53 of 189
The Ring programming language version 1.6 book - Part 53 of 189
 
The Ring programming language version 1.10 book - Part 70 of 212
The Ring programming language version 1.10 book - Part 70 of 212The Ring programming language version 1.10 book - Part 70 of 212
The Ring programming language version 1.10 book - Part 70 of 212
 
Homemade GoTo mount for Telescopes using Nylon wheels, GT2 belts and 100:1 ge...
Homemade GoTo mount for Telescopes using Nylon wheels, GT2 belts and 100:1 ge...Homemade GoTo mount for Telescopes using Nylon wheels, GT2 belts and 100:1 ge...
Homemade GoTo mount for Telescopes using Nylon wheels, GT2 belts and 100:1 ge...
 
The Ring programming language version 1.5.2 book - Part 50 of 181
The Ring programming language version 1.5.2 book - Part 50 of 181The Ring programming language version 1.5.2 book - Part 50 of 181
The Ring programming language version 1.5.2 book - Part 50 of 181
 
The Ring programming language version 1.3 book - Part 40 of 88
The Ring programming language version 1.3 book - Part 40 of 88The Ring programming language version 1.3 book - Part 40 of 88
The Ring programming language version 1.3 book - Part 40 of 88
 
The Ring programming language version 1.8 book - Part 66 of 202
The Ring programming language version 1.8 book - Part 66 of 202The Ring programming language version 1.8 book - Part 66 of 202
The Ring programming language version 1.8 book - Part 66 of 202
 
The Ring programming language version 1.5.4 book - Part 46 of 185
The Ring programming language version 1.5.4 book - Part 46 of 185The Ring programming language version 1.5.4 book - Part 46 of 185
The Ring programming language version 1.5.4 book - Part 46 of 185
 

Similar to Utility Classes Are Killing Us

public interface Game Note interface in place of class { .pdf
public interface Game  Note interface in place of class { .pdfpublic interface Game  Note interface in place of class { .pdf
public interface Game Note interface in place of class { .pdfkavithaarp
 
MineSweeper.java public class MS { public static void main(Strin.pdf
MineSweeper.java public class MS { public static void main(Strin.pdfMineSweeper.java public class MS { public static void main(Strin.pdf
MineSweeper.java public class MS { public static void main(Strin.pdfaniyathikitchen
 
The main class of the tictoe game looks like.public class Main {.pdf
The main class of the tictoe game looks like.public class Main {.pdfThe main class of the tictoe game looks like.public class Main {.pdf
The main class of the tictoe game looks like.public class Main {.pdfasif1401
 
Find the output of the following code (Java for ICSE)
Find the output of the following code (Java for ICSE)Find the output of the following code (Java for ICSE)
Find the output of the following code (Java for ICSE)Mokshya Priyadarshee
 
In Java using Eclipse, Im suppose to write a class that encapsulat.pdf
In Java using Eclipse, Im suppose to write a class that encapsulat.pdfIn Java using Eclipse, Im suppose to write a class that encapsulat.pdf
In Java using Eclipse, Im suppose to write a class that encapsulat.pdfanjandavid
 
Driver.java import java.util.Scanner; import java.text.Decimal.pdf
Driver.java import java.util.Scanner; import java.text.Decimal.pdfDriver.java import java.util.Scanner; import java.text.Decimal.pdf
Driver.java import java.util.Scanner; import java.text.Decimal.pdfanandhomeneeds
 
QA Auotmation Java programs,theory
QA Auotmation Java programs,theory QA Auotmation Java programs,theory
QA Auotmation Java programs,theory archana singh
 
Example of JAVA Program
Example of JAVA ProgramExample of JAVA Program
Example of JAVA ProgramTrenton Asbury
 
ObjectiveCreate a graphical game of minesweeper IN JAVA. The boar.pdf
ObjectiveCreate a graphical game of minesweeper IN JAVA. The boar.pdfObjectiveCreate a graphical game of minesweeper IN JAVA. The boar.pdf
ObjectiveCreate a graphical game of minesweeper IN JAVA. The boar.pdfrajkumarm401
 
import java.util.Scanner;public class Main {private static i.pdf
import java.util.Scanner;public class Main {private static i.pdfimport java.util.Scanner;public class Main {private static i.pdf
import java.util.Scanner;public class Main {private static i.pdfstopgolook
 
import java.util.Scanner;public class Main {    public static in.pdf
import java.util.Scanner;public class Main {    public static in.pdfimport java.util.Scanner;public class Main {    public static in.pdf
import java.util.Scanner;public class Main {    public static in.pdfanwarsadath111
 
Yet another building metaphor
Yet another building metaphorYet another building metaphor
Yet another building metaphorAslam Khan
 
Here is the code for youimport java.util.Scanner; import java.u.pdf
Here is the code for youimport java.util.Scanner; import java.u.pdfHere is the code for youimport java.util.Scanner; import java.u.pdf
Here is the code for youimport java.util.Scanner; import java.u.pdfanithareadymade
 

Similar to Utility Classes Are Killing Us (20)

public interface Game Note interface in place of class { .pdf
public interface Game  Note interface in place of class { .pdfpublic interface Game  Note interface in place of class { .pdf
public interface Game Note interface in place of class { .pdf
 
The Art of Clean Code
The Art of Clean CodeThe Art of Clean Code
The Art of Clean Code
 
MineSweeper.java public class MS { public static void main(Strin.pdf
MineSweeper.java public class MS { public static void main(Strin.pdfMineSweeper.java public class MS { public static void main(Strin.pdf
MineSweeper.java public class MS { public static void main(Strin.pdf
 
The main class of the tictoe game looks like.public class Main {.pdf
The main class of the tictoe game looks like.public class Main {.pdfThe main class of the tictoe game looks like.public class Main {.pdf
The main class of the tictoe game looks like.public class Main {.pdf
 
201707 CSE110 Lecture 13
201707 CSE110 Lecture 13   201707 CSE110 Lecture 13
201707 CSE110 Lecture 13
 
Ann
AnnAnn
Ann
 
Find the output of the following code (Java for ICSE)
Find the output of the following code (Java for ICSE)Find the output of the following code (Java for ICSE)
Find the output of the following code (Java for ICSE)
 
In Java using Eclipse, Im suppose to write a class that encapsulat.pdf
In Java using Eclipse, Im suppose to write a class that encapsulat.pdfIn Java using Eclipse, Im suppose to write a class that encapsulat.pdf
In Java using Eclipse, Im suppose to write a class that encapsulat.pdf
 
Driver.java import java.util.Scanner; import java.text.Decimal.pdf
Driver.java import java.util.Scanner; import java.text.Decimal.pdfDriver.java import java.util.Scanner; import java.text.Decimal.pdf
Driver.java import java.util.Scanner; import java.text.Decimal.pdf
 
Java file
Java fileJava file
Java file
 
Java file
Java fileJava file
Java file
 
Cpp c++ 1
Cpp c++ 1Cpp c++ 1
Cpp c++ 1
 
QA Auotmation Java programs,theory
QA Auotmation Java programs,theory QA Auotmation Java programs,theory
QA Auotmation Java programs,theory
 
Studyx4
Studyx4Studyx4
Studyx4
 
Example of JAVA Program
Example of JAVA ProgramExample of JAVA Program
Example of JAVA Program
 
ObjectiveCreate a graphical game of minesweeper IN JAVA. The boar.pdf
ObjectiveCreate a graphical game of minesweeper IN JAVA. The boar.pdfObjectiveCreate a graphical game of minesweeper IN JAVA. The boar.pdf
ObjectiveCreate a graphical game of minesweeper IN JAVA. The boar.pdf
 
import java.util.Scanner;public class Main {private static i.pdf
import java.util.Scanner;public class Main {private static i.pdfimport java.util.Scanner;public class Main {private static i.pdf
import java.util.Scanner;public class Main {private static i.pdf
 
import java.util.Scanner;public class Main {    public static in.pdf
import java.util.Scanner;public class Main {    public static in.pdfimport java.util.Scanner;public class Main {    public static in.pdf
import java.util.Scanner;public class Main {    public static in.pdf
 
Yet another building metaphor
Yet another building metaphorYet another building metaphor
Yet another building metaphor
 
Here is the code for youimport java.util.Scanner; import java.u.pdf
Here is the code for youimport java.util.Scanner; import java.u.pdfHere is the code for youimport java.util.Scanner; import java.u.pdf
Here is the code for youimport java.util.Scanner; import java.u.pdf
 

More from Yegor Bugayenko

Can Distributed Teams Deliver Quality?
Can Distributed Teams Deliver Quality?Can Distributed Teams Deliver Quality?
Can Distributed Teams Deliver Quality?Yegor Bugayenko
 
Are You Sure You Are Not a Micromanager?
Are You Sure You Are Not a Micromanager?Are You Sure You Are Not a Micromanager?
Are You Sure You Are Not a Micromanager?Yegor Bugayenko
 
On Requirements Management (Demotivate Them Right)
On Requirements Management (Demotivate Them Right)On Requirements Management (Demotivate Them Right)
On Requirements Management (Demotivate Them Right)Yegor Bugayenko
 
My Experience of 1000 Interviews
My Experience of 1000 InterviewsMy Experience of 1000 Interviews
My Experience of 1000 InterviewsYegor Bugayenko
 
Are you sure you are not a micromanager?
Are you sure you are not a micromanager?Are you sure you are not a micromanager?
Are you sure you are not a micromanager?Yegor Bugayenko
 
Quality Assurance vs. Testing
Quality Assurance vs. TestingQuality Assurance vs. Testing
Quality Assurance vs. TestingYegor Bugayenko
 
Typical Pitfalls in Testing
Typical Pitfalls in TestingTypical Pitfalls in Testing
Typical Pitfalls in TestingYegor Bugayenko
 
Software Testing Pitfalls
Software Testing PitfallsSoftware Testing Pitfalls
Software Testing PitfallsYegor Bugayenko
 
Five Trends We Are Afraid Of
Five Trends We Are Afraid OfFive Trends We Are Afraid Of
Five Trends We Are Afraid OfYegor Bugayenko
 
Who Cares About Quality?
Who Cares About Quality?Who Cares About Quality?
Who Cares About Quality?Yegor Bugayenko
 
Zold: a cryptocurrency without Blockchain
Zold: a cryptocurrency without BlockchainZold: a cryptocurrency without Blockchain
Zold: a cryptocurrency without BlockchainYegor Bugayenko
 
How to Cut Corners and Stay Cool
How to Cut Corners and Stay CoolHow to Cut Corners and Stay Cool
How to Cut Corners and Stay CoolYegor Bugayenko
 
Java Annotations Are a Bad Idea
Java Annotations Are a Bad IdeaJava Annotations Are a Bad Idea
Java Annotations Are a Bad IdeaYegor Bugayenko
 

More from Yegor Bugayenko (20)

Can Distributed Teams Deliver Quality?
Can Distributed Teams Deliver Quality?Can Distributed Teams Deliver Quality?
Can Distributed Teams Deliver Quality?
 
Are You Sure You Are Not a Micromanager?
Are You Sure You Are Not a Micromanager?Are You Sure You Are Not a Micromanager?
Are You Sure You Are Not a Micromanager?
 
On Requirements Management (Demotivate Them Right)
On Requirements Management (Demotivate Them Right)On Requirements Management (Demotivate Them Right)
On Requirements Management (Demotivate Them Right)
 
My Experience of 1000 Interviews
My Experience of 1000 InterviewsMy Experience of 1000 Interviews
My Experience of 1000 Interviews
 
Are you sure you are not a micromanager?
Are you sure you are not a micromanager?Are you sure you are not a micromanager?
Are you sure you are not a micromanager?
 
Quality Assurance vs. Testing
Quality Assurance vs. TestingQuality Assurance vs. Testing
Quality Assurance vs. Testing
 
Is Java Getting Better?
Is Java Getting Better?Is Java Getting Better?
Is Java Getting Better?
 
Typical Pitfalls in Testing
Typical Pitfalls in TestingTypical Pitfalls in Testing
Typical Pitfalls in Testing
 
Software Testing Pitfalls
Software Testing PitfallsSoftware Testing Pitfalls
Software Testing Pitfalls
 
Five Trends We Are Afraid Of
Five Trends We Are Afraid OfFive Trends We Are Afraid Of
Five Trends We Are Afraid Of
 
Experts vs Expertise
Experts vs ExpertiseExperts vs Expertise
Experts vs Expertise
 
Who Cares About Quality?
Who Cares About Quality?Who Cares About Quality?
Who Cares About Quality?
 
Quantity vs. Quality
Quantity vs. QualityQuantity vs. Quality
Quantity vs. Quality
 
Experts vs Expertise
Experts vs ExpertiseExperts vs Expertise
Experts vs Expertise
 
Zold: a cryptocurrency without Blockchain
Zold: a cryptocurrency without BlockchainZold: a cryptocurrency without Blockchain
Zold: a cryptocurrency without Blockchain
 
Life Without Blockchain
Life Without BlockchainLife Without Blockchain
Life Without Blockchain
 
How to Cut Corners and Stay Cool
How to Cut Corners and Stay CoolHow to Cut Corners and Stay Cool
How to Cut Corners and Stay Cool
 
Math or Love?
Math or Love?Math or Love?
Math or Love?
 
How much do you cost?
How much do you cost?How much do you cost?
How much do you cost?
 
Java Annotations Are a Bad Idea
Java Annotations Are a Bad IdeaJava Annotations Are a Bad Idea
Java Annotations Are a Bad Idea
 

Recently uploaded

Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integrationmarketing932765
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024TopCSSGallery
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...itnewsafrica
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...itnewsafrica
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesManik S Magar
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Nikki Chapple
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 

Recently uploaded (20)

Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 

Utility Classes Are Killing Us

  • 1. /13@yegor256 1 Utility классы нас убивают Yegor Bugayenko Utility Classes Are Killing Us
  • 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. /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. /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. /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. /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. /13@yegor256 8 No stateу них нет состояния
  • 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. /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. /13@yegor256 11 new Farewell( new Attempts( new VerboseDiff( new Diff( new Secret() as secret, new Guess() ) ), 5 ), secret ).say();
  • 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@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();