SlideShare une entreprise Scribd logo
1  sur  14
Télécharger pour lire hors ligne
/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

Contenu connexe

Tendances

PyCon2009_AI_Alt
PyCon2009_AI_AltPyCon2009_AI_Alt
PyCon2009_AI_Alt
Hiroshi Ono
 

Tendances (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
 

Similaire à 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 { .pdf
kavithaarp
 
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
aniyathikitchen
 
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
asif1401
 
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
anjandavid
 
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
anandhomeneeds
 
Example of JAVA Program
Example of JAVA ProgramExample of JAVA Program
Example of JAVA Program
Trenton 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.pdf
rajkumarm401
 
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
stopgolook
 
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
anwarsadath111
 
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
anithareadymade
 

Similaire à 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
 

Plus de Yegor Bugayenko

Plus de 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
 

Dernier

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 

Dernier (20)

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 

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();