/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

PDF
The Ring programming language version 1.4.1 book - Part 15 of 31
PDF
The Ring programming language version 1.10 book - Part 71 of 212
PDF
The Ring programming language version 1.8 book - Part 57 of 202
PDF
The Ring programming language version 1.6 book - Part 54 of 189
PDF
The Ring programming language version 1.5.4 book - Part 51 of 185
PDF
The Ring programming language version 1.5 book - Part 9 of 31
PDF
The Ring programming language version 1.5.1 book - Part 49 of 180
PDF
The Ring programming language version 1.9 book - Part 62 of 210
The Ring programming language version 1.4.1 book - Part 15 of 31
The Ring programming language version 1.10 book - Part 71 of 212
The Ring programming language version 1.8 book - Part 57 of 202
The Ring programming language version 1.6 book - Part 54 of 189
The Ring programming language version 1.5.4 book - Part 51 of 185
The Ring programming language version 1.5 book - Part 9 of 31
The Ring programming language version 1.5.1 book - Part 49 of 180
The Ring programming language version 1.9 book - Part 62 of 210

What's hot (20)

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

Similar to Utility Classes Are Killing Us (20)

PDF
public interface Game Note interface in place of class { .pdf
PDF
The Art of Clean Code
PDF
MineSweeper.java public class MS { public static void main(Strin.pdf
PDF
The main class of the tictoe game looks like.public class Main {.pdf
PDF
201707 CSE110 Lecture 13
PDF
Simple 27 Java Program on basic java syntax
DOCX
DOC
Find the output of the following code (Java for ICSE)
PDF
In Java using Eclipse, Im suppose to write a class that encapsulat.pdf
PDF
Driver.java import java.util.Scanner; import java.text.Decimal.pdf
DOCX
Java file
DOCX
Java file
PPT
DOCX
QA Auotmation Java programs,theory
PDF
DOCX
Example of JAVA Program
PDF
ObjectiveCreate a graphical game of minesweeper IN JAVA. The boar.pdf
PDF
import java.util.Scanner;public class Main {private static i.pdf
PDF
import java.util.Scanner;public class Main {    public static in.pdf
PDF
Yet another building metaphor
public interface Game Note interface in place of class { .pdf
The Art of Clean Code
MineSweeper.java public class MS { public static void main(Strin.pdf
The main class of the tictoe game looks like.public class Main {.pdf
201707 CSE110 Lecture 13
Simple 27 Java Program on basic java syntax
Find the output of the following code (Java for ICSE)
In Java using Eclipse, Im suppose to write a class that encapsulat.pdf
Driver.java import java.util.Scanner; import java.text.Decimal.pdf
Java file
Java file
QA Auotmation Java programs,theory
Example of JAVA Program
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 {    public static in.pdf
Yet another building metaphor
Ad

More from Yegor Bugayenko (20)

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

Recently uploaded (20)

PDF
EIS-Webinar-Regulated-Industries-2025-08.pdf
PDF
A hybrid framework for wild animal classification using fine-tuned DenseNet12...
PDF
Co-training pseudo-labeling for text classification with support vector machi...
PDF
Aug23rd - Mulesoft Community Workshop - Hyd, India.pdf
PDF
The-2025-Engineering-Revolution-AI-Quality-and-DevOps-Convergence.pdf
PDF
Electrocardiogram sequences data analytics and classification using unsupervi...
PPTX
AI-driven Assurance Across Your End-to-end Network With ThousandEyes
PDF
Introduction to MCP and A2A Protocols: Enabling Agent Communication
PDF
Human Computer Interaction Miterm Lesson
PDF
Auditboard EB SOX Playbook 2023 edition.
PPTX
Build automations faster and more reliably with UiPath ScreenPlay
PDF
The-Future-of-Automotive-Quality-is-Here-AI-Driven-Engineering.pdf
PDF
LMS bot: enhanced learning management systems for improved student learning e...
PPTX
Microsoft User Copilot Training Slide Deck
PDF
AI.gov: A Trojan Horse in the Age of Artificial Intelligence
PPTX
Internet of Everything -Basic concepts details
PDF
Build Real-Time ML Apps with Python, Feast & NoSQL
PDF
INTERSPEECH 2025 「Recent Advances and Future Directions in Voice Conversion」
PDF
NewMind AI Weekly Chronicles – August ’25 Week IV
PDF
Transform-Your-Supply-Chain-with-AI-Driven-Quality-Engineering.pdf
EIS-Webinar-Regulated-Industries-2025-08.pdf
A hybrid framework for wild animal classification using fine-tuned DenseNet12...
Co-training pseudo-labeling for text classification with support vector machi...
Aug23rd - Mulesoft Community Workshop - Hyd, India.pdf
The-2025-Engineering-Revolution-AI-Quality-and-DevOps-Convergence.pdf
Electrocardiogram sequences data analytics and classification using unsupervi...
AI-driven Assurance Across Your End-to-end Network With ThousandEyes
Introduction to MCP and A2A Protocols: Enabling Agent Communication
Human Computer Interaction Miterm Lesson
Auditboard EB SOX Playbook 2023 edition.
Build automations faster and more reliably with UiPath ScreenPlay
The-Future-of-Automotive-Quality-is-Here-AI-Driven-Engineering.pdf
LMS bot: enhanced learning management systems for improved student learning e...
Microsoft User Copilot Training Slide Deck
AI.gov: A Trojan Horse in the Age of Artificial Intelligence
Internet of Everything -Basic concepts details
Build Real-Time ML Apps with Python, Feast & NoSQL
INTERSPEECH 2025 「Recent Advances and Future Directions in Voice Conversion」
NewMind AI Weekly Chronicles – August ’25 Week IV
Transform-Your-Supply-Chain-with-AI-Driven-Quality-Engineering.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();