SlideShare a Scribd company logo
1 of 43
Download to read offline
Can PL/SQL
Be Clean?
AOUG, Oct. 2013
Peter Kofler, ‘Code Cop’
@codecopkofler
www.code-cop.org

Copyright Peter Kofler, licensed under CC-BY.
PETER KOFLER, CODE-COP.ORG

FANATIC ABOUT CODE QUALITY

Peter Kofler
• Ph.D. (Appl. Math.)
• Software Developer
for 14 years
• “fanatic about code quality”
• Pair Programming #CodeCopTour
PETER KOFLER, CODE-COP.ORG

FANATIC ABOUT CODE QUALITY

Agenda
Define Clean Code
● Define PL/SQL
● Apply Clean Code to PL/SQL
● Examples
● Discussion
●
What is Clean Code?
“Craftsmanship
Over Crap“
(Robert C. Martin)
“Clean code looks
like it was written
by someone who
cares.”
(Michael Feathers)
Rule 1)
Written by
someone who
cares.
What is Clean Code?
Clean Code
PETER KOFLER, CODE-COP.ORG

FANATIC ABOUT CODE QUALITY

Clean Code is Not New
Clean Coder, 2011
● Clean Code, 2008
● Implementation Patten, 2007
● Agile Software Development, 2002
● The Pragmatic Programmer, 1999
● Refactoring, 1999
● Code Complete 1st Ed, 1993 (!)
●
Quick And Dirty
Code Complete
“Write Programs for
People First,
Computers Second.”
(Steve McConnell)
Rule 2)
Written for
People First.
So how would
You
like the code to be?
(besides working correctly)
Code which does
not make me want
to kill the author.
http://programmers.stackexchange.com/a/13594/15057
PETER KOFLER, CODE-COP.ORG

FANATIC ABOUT CODE QUALITY

Easy and Simple!
Easy to read.
● Easy to follow.
● Easy to understand.
● Easy to modify.
● Easy to test.
● Easy ...
●

http://stackoverflow.com/a/954582/104143
Procedural Language/
Structured Query Language
Should you write
PL/SQL with care?
Should you write
PL/SQL for people?
Tadaaa!
Clean PL/SQL
looks like it was
written by someone who cares.
Write PL/SQL for
People First,
Databases Second.
But...
PETER KOFLER, CODE-COP.ORG

FANATIC ABOUT CODE QUALITY

PL/SQL is not Java
• Clean Code targets “modern” languages
– Java, C#
– Ruby, Python
– maybe C++
• Clean Code is about
– Object Orientation
– Test Driven Development
Do these guidelines
apply to PL/SQL?
PETER KOFLER, CODE-COP.ORG

FANATIC ABOUT CODE QUALITY

PL/SQL is...
• compiled
• imperative/procedural with modules
– function/procedure/package
• structured
– if/loop/continue/exit
– with exceptions
• static typed with strong type safety
• kind of object-orientated (version 8)
http://en.wikipedia.org/wiki/PL/SQL
Sounds much like
Java to me ;-)
Examples from
PETER KOFLER, CODE-COP.ORG

FANATIC ABOUT CODE QUALITY

Meaningful Names


Names should reveal intent.



Use pronounceable names.



Use Problem Domain Names.

e.g. http://www.zero1design.com/2011/10/31/cleaner-code-in-t-sql-part-1-%E2%80%93-naming-stored-procs-views/
http://theprofoundprogrammer.com/post/26561881517/text-single-letter-variables-who-the-fuck-do
PETER KOFLER, CODE-COP.ORG

FANATIC ABOUT CODE QUALITY

Other Chapters
●

Formatting 

●

Comments 

●

Functions 

●

Unit Testing 
/3 of “Clean Code”
applies directly

1
PETER KOFLER, CODE-COP.ORG

FANATIC ABOUT CODE QUALITY

Single Responsibility Principle
„SRP“
● Do one thing.
● One reason for a function to change.
● One level of abstraction per function.
● Maybe applies to packages as well.
●
PETER KOFLER, CODE-COP.ORG

FANATIC ABOUT CODE QUALITY

Other Object Oriented Stuff?
●

Encapsulation 

●

Coupling (between packages) 

●

Cohesion 

●

Cyclomatic Complexity 
½ of “Clean Code”
applies (in some way)
Conclusion
1)
Clean code always
looks like it was
written by someone who cares.
2)
Clean Code Applies
to PL/SQL
(at least to a certain extend)
3) Read It!
PETER KOFLER, CODE-COP.ORG

FANATIC ABOUT CODE QUALITY

Peter Kofler
@codecopkofler
www.code-cop.org
PETER KOFLER, CODE-COP.ORG

FANATIC ABOUT CODE QUALITY

CC Images
●

cleaning: http://www.flickr.com/photos/inf3ktion/4477642894/

●

dump: http://www.flickr.com/photos/sanmartin/2682745838/

●

thumb: http://www.flickr.com/photos/leehaywood/4481372869/

●

knife: http://www.flickr.com/photos/21232564@N06/2234726613/

●

finish: http://www.flickr.com/photos/jayneandd/4450623309/

More Related Content

What's hot

What's hot (20)

TDD as if You Meant It (2013)
TDD as if You Meant It (2013)TDD as if You Meant It (2013)
TDD as if You Meant It (2013)
 
GDCR15 in Las Palmas, Gran Canaria
GDCR15 in Las Palmas, Gran CanariaGDCR15 in Las Palmas, Gran Canaria
GDCR15 in Las Palmas, Gran Canaria
 
Coding Dojo Object Calisthenics (2016)
Coding Dojo Object Calisthenics (2016)Coding Dojo Object Calisthenics (2016)
Coding Dojo Object Calisthenics (2016)
 
Deliberate Practice (Agile Slovenia 2015)
Deliberate Practice (Agile Slovenia 2015)Deliberate Practice (Agile Slovenia 2015)
Deliberate Practice (Agile Slovenia 2015)
 
Deliberate Practice, New Learning Styles (2015)
Deliberate Practice, New Learning Styles (2015)Deliberate Practice, New Learning Styles (2015)
Deliberate Practice, New Learning Styles (2015)
 
Brutal Coding Constraints (ITAKE 2017)
Brutal Coding Constraints (ITAKE 2017)Brutal Coding Constraints (ITAKE 2017)
Brutal Coding Constraints (ITAKE 2017)
 
Designing Test Cases for the Gilded Rose Kata v2 (2015)
Designing Test Cases for the Gilded Rose Kata v2 (2015)Designing Test Cases for the Gilded Rose Kata v2 (2015)
Designing Test Cases for the Gilded Rose Kata v2 (2015)
 
Designing Test Cases for the Gilded Rose Kata v3 (2016)
Designing Test Cases for the Gilded Rose Kata v3 (2016)Designing Test Cases for the Gilded Rose Kata v3 (2016)
Designing Test Cases for the Gilded Rose Kata v3 (2016)
 
Architectural changes in Orion
Architectural changes in OrionArchitectural changes in Orion
Architectural changes in Orion
 
Refactoring the Tennis Kata v2 (2016)
Refactoring the Tennis Kata v2 (2016)Refactoring the Tennis Kata v2 (2016)
Refactoring the Tennis Kata v2 (2016)
 
JetBrains MPS
JetBrains MPSJetBrains MPS
JetBrains MPS
 
Python for Swift
Python for SwiftPython for Swift
Python for Swift
 
An introduction to go programming language
An introduction to go programming languageAn introduction to go programming language
An introduction to go programming language
 
Future of PERL in IT
Future of PERL in ITFuture of PERL in IT
Future of PERL in IT
 
Lets Go - An introduction to Google's Go Programming Language
Lets Go - An introduction to Google's Go Programming Language Lets Go - An introduction to Google's Go Programming Language
Lets Go - An introduction to Google's Go Programming Language
 
TDD with Rails
TDD with RailsTDD with Rails
TDD with Rails
 
A First Look at Google's Go Programming Language
A First Look at Google's Go Programming LanguageA First Look at Google's Go Programming Language
A First Look at Google's Go Programming Language
 
Code Reviews in Python - PyZh
Code Reviews in Python - PyZhCode Reviews in Python - PyZh
Code Reviews in Python - PyZh
 
UnDeveloper Studio
UnDeveloper StudioUnDeveloper Studio
UnDeveloper Studio
 
Using Aspects for Language Portability (SCAM 2010)
Using Aspects for Language Portability (SCAM 2010)Using Aspects for Language Portability (SCAM 2010)
Using Aspects for Language Portability (SCAM 2010)
 

Similar to Can PL/SQL be Clean? (2013)

Code Quality Assurance v4 (2013)
Code Quality Assurance v4 (2013)Code Quality Assurance v4 (2013)
Code Quality Assurance v4 (2013)
Peter Kofler
 
Coding Dojo: Roman Numerals (2014)
Coding Dojo: Roman Numerals (2014)Coding Dojo: Roman Numerals (2014)
Coding Dojo: Roman Numerals (2014)
Peter Kofler
 
Coding Dojo: Adding Tests to Legacy Code (2014)
Coding Dojo: Adding Tests to Legacy Code (2014)Coding Dojo: Adding Tests to Legacy Code (2014)
Coding Dojo: Adding Tests to Legacy Code (2014)
Peter Kofler
 
Clean Code III - Software Craftsmanship
Clean Code III - Software CraftsmanshipClean Code III - Software Craftsmanship
Clean Code III - Software Craftsmanship
Theo Jungeblut
 
Clean Code Part III - Craftsmanship at SoCal Code Camp
Clean Code Part III - Craftsmanship at SoCal Code CampClean Code Part III - Craftsmanship at SoCal Code Camp
Clean Code Part III - Craftsmanship at SoCal Code Camp
Theo Jungeblut
 
Practical (J)Unit Testing (2009)
Practical (J)Unit Testing (2009)Practical (J)Unit Testing (2009)
Practical (J)Unit Testing (2009)
Peter Kofler
 
Coding Dojo: Bank OCR (2014)
Coding Dojo: Bank OCR (2014)Coding Dojo: Bank OCR (2014)
Coding Dojo: Bank OCR (2014)
Peter Kofler
 
Deliberate Practice (2014)
Deliberate Practice (2014)Deliberate Practice (2014)
Deliberate Practice (2014)
Peter Kofler
 

Similar to Can PL/SQL be Clean? (2013) (20)

Code Quality Assurance v4 (2013)
Code Quality Assurance v4 (2013)Code Quality Assurance v4 (2013)
Code Quality Assurance v4 (2013)
 
Using Automated Code Reviews to Achieve Continuous Quality (ASQF Agile Night ...
Using Automated Code Reviews to Achieve Continuous Quality (ASQF Agile Night ...Using Automated Code Reviews to Achieve Continuous Quality (ASQF Agile Night ...
Using Automated Code Reviews to Achieve Continuous Quality (ASQF Agile Night ...
 
Outside-in Test Driven Development - the London School of TDD
Outside-in Test Driven Development - the London School of TDDOutside-in Test Driven Development - the London School of TDD
Outside-in Test Driven Development - the London School of TDD
 
Coding Dojo: Functional Calisthenics (2016)
Coding Dojo: Functional Calisthenics (2016)Coding Dojo: Functional Calisthenics (2016)
Coding Dojo: Functional Calisthenics (2016)
 
Pragmatic Introduction to Python Unit Testing (PyDays 2018)
Pragmatic Introduction to Python Unit Testing (PyDays 2018)Pragmatic Introduction to Python Unit Testing (PyDays 2018)
Pragmatic Introduction to Python Unit Testing (PyDays 2018)
 
Prime Factors Code Kata - Practicing TDD (2014)
Prime Factors Code Kata - Practicing TDD (2014)Prime Factors Code Kata - Practicing TDD (2014)
Prime Factors Code Kata - Practicing TDD (2014)
 
Coding Dojo: Naming with Dices (2021)
Coding Dojo: Naming with Dices (2021)Coding Dojo: Naming with Dices (2021)
Coding Dojo: Naming with Dices (2021)
 
Coding Dojo: Roman Numerals (2014)
Coding Dojo: Roman Numerals (2014)Coding Dojo: Roman Numerals (2014)
Coding Dojo: Roman Numerals (2014)
 
Pragmatic Introduction to PHP Unit Testing (2015)
Pragmatic Introduction to PHP Unit Testing (2015)Pragmatic Introduction to PHP Unit Testing (2015)
Pragmatic Introduction to PHP Unit Testing (2015)
 
Coding Dojo: Adding Tests to Legacy Code (2014)
Coding Dojo: Adding Tests to Legacy Code (2014)Coding Dojo: Adding Tests to Legacy Code (2014)
Coding Dojo: Adding Tests to Legacy Code (2014)
 
JUnit Boot Camp (GeeCON 2016)
JUnit Boot Camp (GeeCON 2016)JUnit Boot Camp (GeeCON 2016)
JUnit Boot Camp (GeeCON 2016)
 
Extract Method Refactoring Workshop (2016)
Extract Method Refactoring Workshop (2016)Extract Method Refactoring Workshop (2016)
Extract Method Refactoring Workshop (2016)
 
Clean Code III - Software Craftsmanship
Clean Code III - Software CraftsmanshipClean Code III - Software Craftsmanship
Clean Code III - Software Craftsmanship
 
Clean Code Part III - Craftsmanship at SoCal Code Camp
Clean Code Part III - Craftsmanship at SoCal Code CampClean Code Part III - Craftsmanship at SoCal Code Camp
Clean Code Part III - Craftsmanship at SoCal Code Camp
 
Pair Programming (2015)
Pair Programming (2015)Pair Programming (2015)
Pair Programming (2015)
 
Letter to a Junior Developer: The Engineering Side of Programming
Letter to a Junior Developer: The Engineering Side of ProgrammingLetter to a Junior Developer: The Engineering Side of Programming
Letter to a Junior Developer: The Engineering Side of Programming
 
Practical (J)Unit Testing (2009)
Practical (J)Unit Testing (2009)Practical (J)Unit Testing (2009)
Practical (J)Unit Testing (2009)
 
Copilot to Cover: Why AI can't replace developers with robots, but can make l...
Copilot to Cover: Why AI can't replace developers with robots, but can make l...Copilot to Cover: Why AI can't replace developers with robots, but can make l...
Copilot to Cover: Why AI can't replace developers with robots, but can make l...
 
Coding Dojo: Bank OCR (2014)
Coding Dojo: Bank OCR (2014)Coding Dojo: Bank OCR (2014)
Coding Dojo: Bank OCR (2014)
 
Deliberate Practice (2014)
Deliberate Practice (2014)Deliberate Practice (2014)
Deliberate Practice (2014)
 

More from Peter Kofler

Coding Dojo: Fun with Tic-Tac-Toe (2014)
Coding Dojo: Fun with Tic-Tac-Toe (2014)Coding Dojo: Fun with Tic-Tac-Toe (2014)
Coding Dojo: Fun with Tic-Tac-Toe (2014)
Peter Kofler
 
Coding Dojo for Testers/Testing Dojo: Designing Test Cases with FitNesse (2014)
Coding Dojo for Testers/Testing Dojo: Designing Test Cases with FitNesse (2014)Coding Dojo for Testers/Testing Dojo: Designing Test Cases with FitNesse (2014)
Coding Dojo for Testers/Testing Dojo: Designing Test Cases with FitNesse (2014)
Peter Kofler
 
Coding Dojo: Mars Rover (2014)
Coding Dojo: Mars Rover (2014)Coding Dojo: Mars Rover (2014)
Coding Dojo: Mars Rover (2014)
Peter Kofler
 
Code Refactoring - Live Coding Demo (JavaDay 2014)
Code Refactoring - Live Coding Demo (JavaDay 2014)Code Refactoring - Live Coding Demo (JavaDay 2014)
Code Refactoring - Live Coding Demo (JavaDay 2014)
Peter Kofler
 

More from Peter Kofler (11)

Coding Dojo: Baby Steps Push Challenge (2021)
Coding Dojo: Baby Steps Push Challenge (2021)Coding Dojo: Baby Steps Push Challenge (2021)
Coding Dojo: Baby Steps Push Challenge (2021)
 
Writing Tests with the Unity Test Framework
Writing Tests with the Unity Test FrameworkWriting Tests with the Unity Test Framework
Writing Tests with the Unity Test Framework
 
Coding Dojo: Asynchronous Clock-In (2016)
Coding Dojo: Asynchronous Clock-In (2016)Coding Dojo: Asynchronous Clock-In (2016)
Coding Dojo: Asynchronous Clock-In (2016)
 
Mob Programming (2016)
Mob Programming (2016)Mob Programming (2016)
Mob Programming (2016)
 
Code Retreat Venice (2016)
Code Retreat Venice (2016)Code Retreat Venice (2016)
Code Retreat Venice (2016)
 
Coding Dojo: Data Munging (2016)
Coding Dojo: Data Munging (2016)Coding Dojo: Data Munging (2016)
Coding Dojo: Data Munging (2016)
 
Coding Dojo: Bank OCR Outside-In (2015)
Coding Dojo: Bank OCR Outside-In (2015)Coding Dojo: Bank OCR Outside-In (2015)
Coding Dojo: Bank OCR Outside-In (2015)
 
Coding Dojo: Fun with Tic-Tac-Toe (2014)
Coding Dojo: Fun with Tic-Tac-Toe (2014)Coding Dojo: Fun with Tic-Tac-Toe (2014)
Coding Dojo: Fun with Tic-Tac-Toe (2014)
 
Coding Dojo for Testers/Testing Dojo: Designing Test Cases with FitNesse (2014)
Coding Dojo for Testers/Testing Dojo: Designing Test Cases with FitNesse (2014)Coding Dojo for Testers/Testing Dojo: Designing Test Cases with FitNesse (2014)
Coding Dojo for Testers/Testing Dojo: Designing Test Cases with FitNesse (2014)
 
Coding Dojo: Mars Rover (2014)
Coding Dojo: Mars Rover (2014)Coding Dojo: Mars Rover (2014)
Coding Dojo: Mars Rover (2014)
 
Code Refactoring - Live Coding Demo (JavaDay 2014)
Code Refactoring - Live Coding Demo (JavaDay 2014)Code Refactoring - Live Coding Demo (JavaDay 2014)
Code Refactoring - Live Coding Demo (JavaDay 2014)
 

Recently uploaded

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 

Recently uploaded (20)

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...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
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
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
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
 
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
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 

Can PL/SQL be Clean? (2013)