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@
 

Último (20)

presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
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
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
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
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
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
 
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
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
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...
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
+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...
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
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
 

Symmetry, Scala & Software -- Refresh Dublin October 2013