SlideShare uma empresa Scribd logo
1 de 39
Baixar para ler offline
Symmetry, Scala &
Software
Refresh Dublin
15 October 2013

Eric Bowman
@ebowman

ebowman@gilt.com
http://tech.gilt.com
“harmonious and
beautiful proportion
and balance”

http://en.wikipedia.org/wiki/Symmetry
“patterned
self-similarity”

http://en.wikipedia.org/wiki/Symmetry
Symmetry is changing
without changing.
Symmetry
in Scala
Scala
•Object-Oriented/Functional
Hybrid
•Statically Typed
public class HelloWorld {
public static void main(String[] args) {
System.out.println("hello, world");
}
}
public class HelloWorld {
public static void main(String[] args) {
System.out.println("hello, world");
}
}

object HelloWorld extends App {
println("hello, world")
}

!
public class HelloWorld {
public static void main(String[] args) {
System.out.println("hello, world");
}
}

object HelloWorld extends App {
println("hello, world")
}

!

println("hello, world")
for (int i = 1; i <= 10; i++) {
for (int j = 1; j <= 10; j++) {
System.out.println(i*j);
}
}

!
!
for (int i = 1; i <= 10; i++) {
for (int j = 1; j <= 10; j++) {
System.out.println(i*j);
}
}

!
!

for {
i <- 1 to 10
j <- 1 to 10
} println(i * j)

!
Future<Integer> f = callService1();
Future<Integer> f2 = callService2(f.get());
System.out.println(f2.get());
Future<Integer> f = callService1();
Future<Integer> f2 = callService2(f.get());
System.out.println(f2.get());

val f = for {
x <- callService1()
y <- callService2(x)
} yield y
println(Await.result(f, Duration.Inf))

!
String capitalize(String name) {
if (name == null) return null;
else return Character.toUpperCase(
name.charAt(0)) + name.substring(1);
}
String capitalize(String name) {
if (name == null) return null;
else return Character.toUpperCase(
name.charAt(0)) + name.substring(1);
}

def capitalize(n: Option[String]): Option[String] = {
for (name <- n) yield {
name(0).toUpper + name.substring(1)
}
}

!
!
for (int i = 1; i <= 10; i++) {
for (int j = 1; j <= 10; j++) {
System.out.println(i*j);
}
}

!
!

Future<Integer> f = callService1();
Future<Integer> f2 = callService2(f.get());
System.out.println(f2.get());

Ja
va

String capitalize(String name) {
if (name == null) return null;
else return Character.toUpperCase(
name.charAt(0)) + name.substring(1);
}

for {
i <- 1 to 10
j <- 1 to 10
} println(i * j)

!

val f = for {
x <- callService1()
y <- callService2(x)
} yield y
println(Await.result(f, Duration.Inf))

!
!

def capitalize(name: Option[String]): Option[String] =
for (n <- name) yield {
n(0).toUpper + n.substring(1)
}

!
!

Sc

al
a
Refactoring
“By continuously improving the design of code,
we make it easier and easier to work with. This
is in sharp contrast to what typically happens:
little refactoring and a great deal of attention
paid to expediently adding new features. If you
get into the hygienic habit of refactoring
continuously, you'll find that it is easier to
extend and maintain code.”

http://en.wikipedia.org/wiki/Code_refactoring
•Abstraction
•Composition/Decomposition
•Name & Location
1. Finite, unchanging list of possible
refactorings.
2. Every refactoring is reversible.
3. Every refactoring is deterministic.
4. Refactorings can be combined in any
order.
Group Theory
“‘Numbers measure size;
groups measure symmetry.”

Groups and Symmetry, Armstrong, Spring-Verlag, 1988, p.1
“The most substantial piece of writing in the whole
literature of mankind”

http://upload.wikimedia.org/wikipedia/commons/5/53/Evariste_galois.jpg
http://opinionator.blogs.nytimes.com/2010/05/02/group-think/
http://opinionator.blogs.nytimes.com/2010/05/02/group-think/
“the symmetry group of an object is the
group of all isometries under which the
object is invariant with composition as the
operation”

http://en.wikipedia.org/wiki/Symmetry_group
“the symmetry group of a program ... is the
group of all refactorings under which the
program behaves identically after applying
refactorings in any order”
for (int i = 1; i <= 10; i++) {
for (int j = 1; j <= 10; j++) {
System.out.println(i*j);
}
}

!
!

Future<Integer> f = callService1();
Future<Integer> f2 = callService2(f.get());
System.out.println(f2.get());

Ja
va

String capitalize(String name) {
if (name == null) return null;
else return Character.toUpperCase(
name.charAt(0)) + name.substring(1);
}

for {
i <- 1 to 10
j <- 1 to 10
} println(i * j)

!

val f = for {
x <- callService1()
y <- callService2(x)
} yield y
println(Await.result(f, Duration.Inf))

!
!

def capitalize(name: Option[String]): Option[String] =
for (n <- name) yield {
n(0).toUpper + n.substring(1)
}

!
!

Sc

al
a
Breaking
Symmetry
a[i].x += a[i - 1].x;
a[i].y += a[i - 1].y;

http://www.metalev.org/2011/04/source-code-symmetry-and-transcendent.html
a[i].x += a[i - 1].x;
a[i].y += a[i - 1].y;

a(i) += a(i-1)

http://www.metalev.org/2011/04/source-code-symmetry-and-transcendent.html
http://pages.cs.wisc.edu/~dyer/vsam/images/mona.gif
http://www.leonardodavinci.net/images/gallery/monalisa_detail1.jpg
http://www.saylor.org/site/wp-content/uploads/2012/04/6-mona-lisa.gif
http://upload.wikimedia.org/wikipedia/commons/thumb/d/db/MaryRose-carpentry_tools1.jpg/250px-MaryRose-carpentry_tools1.jpg
http://test.classconnection.s3.amazonaws.com/324/flashcards/95324/png/altarpiece.png
http://upload.wikimedia.org/wikipedia/commons/thumb/d/db/MaryRose-carpentry_tools1.jpg/250px-MaryRose-carpentry_tools1.jpg
http://test.classconnection.s3.amazonaws.com/324/flashcards/95324/png/altarpiece.png
http://www.biographyonline.net/artists/images/Much-The_Scream.jpg
http://upload.wikimedia.org/wikipedia/commons/6/63/Michelangelos_David.jpg
http://amolife.com/image/images/stories/Art&Abstract/most_popular_sculptures%20(7).jpg
http://www.pics24h.com/img/artwork/5-most-famous-paintings/5-most-famous-paintings03.jpg
Fin

niF

join us.
http://tech.gilt.com
@gilttech

@ebowman
ebowman@gilt.com

Mais conteúdo relacionado

Semelhante a Symmetry, Scala & Software -- Refresh Dublin October 2013

Optimizing Application Architecture (.NET/Java topics)
Optimizing Application Architecture (.NET/Java topics)Optimizing Application Architecture (.NET/Java topics)
Optimizing Application Architecture (.NET/Java topics)
Ravi Okade
 
Martin Odersky - Evolution of Scala
Martin Odersky - Evolution of ScalaMartin Odersky - Evolution of Scala
Martin Odersky - Evolution of Scala
Scala Italy
 
flatMap Oslo presentation slides
flatMap Oslo presentation slidesflatMap Oslo presentation slides
flatMap Oslo presentation slides
Martin Odersky
 

Semelhante a Symmetry, Scala & Software -- Refresh Dublin October 2013 (20)

Clean Code at Silicon Valley Code Camp 2011 (02/17/2012)
Clean Code at Silicon Valley Code Camp 2011 (02/17/2012)Clean Code at Silicon Valley Code Camp 2011 (02/17/2012)
Clean Code at Silicon Valley Code Camp 2011 (02/17/2012)
 
Scala Days San Francisco
Scala Days San FranciscoScala Days San Francisco
Scala Days San Francisco
 
The Ring programming language version 1.9 book - Part 54 of 210
The Ring programming language version 1.9 book - Part 54 of 210The Ring programming language version 1.9 book - Part 54 of 210
The Ring programming language version 1.9 book - Part 54 of 210
 
Code transformation With Spoon
Code transformation With SpoonCode transformation With Spoon
Code transformation With Spoon
 
Optimizing Application Architecture (.NET/Java topics)
Optimizing Application Architecture (.NET/Java topics)Optimizing Application Architecture (.NET/Java topics)
Optimizing Application Architecture (.NET/Java topics)
 
Scala final ppt vinay
Scala final ppt vinayScala final ppt vinay
Scala final ppt vinay
 
Principled io in_scala_2019_distribution
Principled io in_scala_2019_distributionPrincipled io in_scala_2019_distribution
Principled io in_scala_2019_distribution
 
PATTERNS04 - Structural Design Patterns
PATTERNS04 - Structural Design PatternsPATTERNS04 - Structural Design Patterns
PATTERNS04 - Structural Design Patterns
 
Design patterns through refactoring
Design patterns through refactoringDesign patterns through refactoring
Design patterns through refactoring
 
2CPP16 - STL
2CPP16 - STL2CPP16 - STL
2CPP16 - STL
 
Intro to JavaScript
Intro to JavaScriptIntro to JavaScript
Intro to JavaScript
 
Go Reactive: Event-Driven, Scalable, Resilient & Responsive Systems
Go Reactive: Event-Driven, Scalable, Resilient & Responsive SystemsGo Reactive: Event-Driven, Scalable, Resilient & Responsive Systems
Go Reactive: Event-Driven, Scalable, Resilient & Responsive Systems
 
The Why and How of Scala at Twitter
The Why and How of Scala at TwitterThe Why and How of Scala at Twitter
The Why and How of Scala at Twitter
 
Scalable JavaScript Design Patterns
Scalable JavaScript Design PatternsScalable JavaScript Design Patterns
Scalable JavaScript Design Patterns
 
Java mcq
Java mcqJava mcq
Java mcq
 
Google guava overview
Google guava overviewGoogle guava overview
Google guava overview
 
Martin Odersky - Evolution of Scala
Martin Odersky - Evolution of ScalaMartin Odersky - Evolution of Scala
Martin Odersky - Evolution of Scala
 
flatMap Oslo presentation slides
flatMap Oslo presentation slidesflatMap Oslo presentation slides
flatMap Oslo presentation slides
 
Flatmap
FlatmapFlatmap
Flatmap
 
Ruby On Rails
Ruby On RailsRuby On Rails
Ruby On Rails
 

Último

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Último (20)

From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
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
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 

Symmetry, Scala & Software -- Refresh Dublin October 2013