SlideShare a Scribd company logo
Every Programmer Should Know
Code Reviews
Roger Xia
July 2012
$ whoami
• Programmer
Programming & Code review
• Programming is
– Taking an algorithm
– Choosing a language
– Using that language to implement algorithm and
solve problems
• Code review is
– ?
Why?
• Increase Quality & Reduce Defects
• Improve readability
• Share knowledge in team
• Know your workmate better!
• Two Wrongs Can Make a Right
• NOT personal attack!
• NOT architect reviews everything
methodology
• Team review (Planned 1-2 hour/week, Clear roles)
• Pair programming (Share knowledge, 1 task)
• Walkthrough (Author leads, reviewers take notes,
higher level)
• Peer review (Asynchronous)
• Gerrit
• Reaction & Ask questions
Preparation
• Code Conventions
• Findbugs
• Tested
• Test case
Take care of
• naming convention
spelling mistakes
• business logic
• refactoring
• performance
• security (attack, thread safe)
Refactoring
• Refactoring modifies software to improve its readability,
maintainability, and extensibility without changing what it actually
does.
• Martin Fowler uses “code smells” to identify when to refactor.
• Boss: "Refactoring is an overhead activity - I'm paid to write new,
revenue generating features."
Code smells
• Bad names
• Duplicate code
• Long method
• Large class
• Long parameter list
• Temporary field
• Speculative Generality
• Data Class
• Don’t flood log
Use Meaningful Names
Meaningful Names
• Class names
– Should be nouns or noun phrases.
– Examples: Car, Account, DataRetrievalService, AddressParser
• Method names
– Should be verb or verbPhrases
– Examples: parseData, deletePage, save
– Methods that return boolean values should sound like question.
– Examples: isAuthenticated, hasNoErrors, isEmpty
• Interface and Implementation
– ICache  LRUCache
– IExport  ExportService
• Constants
– MAX_VALUE
– SEP_COMMA, SEP_SEMICOLON
The Art of Readable code
• The book!
• I want to point out:
– Use blank to separate logic block.
Comments for complex process,
algorithm, reasons
Aiming for simplicity
• Do one thing in a function (simple responsibility)
• Have no side effects.
• Prefer exceptions to return codes.
• Format your code.
DRY -- Don’t repeat yourself
• Duplicated code should be avoided.
• Object Orientation, Abstract!
• Design pattern!
OO Principles
• Simple responsibility principle: Class should have one and
only one reason to change.
• Encapsulation: Modules should not know internal details of
objects it manipulates.
• Polymorphism -- Liskov’s substitution principle: A subclass
can be used as an argument where a base class is expected.
• Open-closed principle: Class should be open for extention,
but closed for modification.
Design Patterns
Pay Attention to Performance
• JAVA: JVM usage
– Don’t create object in loop
– Use ArrayList, HashMap etc as opposed to Vector, Hashtable etc
(synchronized) where possible. Even better is to use just arrays
where possible.
– Set initial capacity of a collection (e.g. ArrayList, HashMap) and
StringBuffer/StringBuilder appropriately.
– Concurrent Collection, Lock
– Lazy load or multi-threading where applicable.
– Cache (LRUCache, Distributed Cache)
Pay Attention to Performance
Pay Attention to Security
• Sandbox (security manager, access manager, Classloaders, policies)
• Scope: Access modifier to help protect your classes, methods, fields.
– public, protected, private, package
– Exceptions: object serialization, reflection,
• Immutable class
– final
– String
– Insecure direct object reference of mutable object
• Type safe
– Casting
• Thread safe
• OOM (static), file description handler, release resources (File, DBConnection)
• SQL injection
• Single point of failure
• secure code
Have Fun and win
http://rosettacode.org/wiki/Rosetta_Code

More Related Content

What's hot

Functional programming for the Advanced Beginner
Functional programming for the Advanced BeginnerFunctional programming for the Advanced Beginner
Functional programming for the Advanced Beginner
Luis Atencio
 
Java Building Blocks
Java Building BlocksJava Building Blocks
Java Building Blocks
Cate Huston
 
GeekAustin PHP Class - Session 6
GeekAustin PHP Class - Session 6GeekAustin PHP Class - Session 6
GeekAustin PHP Class - Session 6jimbojsb
 
Object oriented javascript
Object oriented javascriptObject oriented javascript
Object oriented javascriptGarrison Locke
 
TypeScript - Silver Bullet for the Full-stack Developers
TypeScript - Silver Bullet for the Full-stack DevelopersTypeScript - Silver Bullet for the Full-stack Developers
TypeScript - Silver Bullet for the Full-stack Developers
Rutenis Turcinas
 
Java and the JVM
Java and the JVMJava and the JVM
Java and the JVM
Manish Pandit
 
TypeScript 101
TypeScript 101TypeScript 101
TypeScript 101
rachelterman
 
Functional Programming in Java
Functional Programming in JavaFunctional Programming in Java
Functional Programming in Java
Premanand Chandrasekaran
 
TypeScript Best Practices
TypeScript Best PracticesTypeScript Best Practices
TypeScript Best Practices
felixbillon
 
Concurrency & Parallel Programming
Concurrency & Parallel ProgrammingConcurrency & Parallel Programming
Concurrency & Parallel Programming
Ramazan AYYILDIZ
 
Functional programming with Xtend
Functional programming with XtendFunctional programming with Xtend
Functional programming with Xtend
Sven Efftinge
 
cpp-2013 #9 STL Algorithms Part 1
cpp-2013 #9 STL Algorithms Part 1cpp-2013 #9 STL Algorithms Part 1
cpp-2013 #9 STL Algorithms Part 1Amazon Web Services
 
2CPP04 - Objects and Classes
2CPP04 - Objects and Classes2CPP04 - Objects and Classes
2CPP04 - Objects and Classes
Michael Heron
 
Typescript for the programmers who like javascript
Typescript for the programmers who like javascriptTypescript for the programmers who like javascript
Typescript for the programmers who like javascript
Andrei Sebastian Cîmpean
 
TypeScript - An Introduction
TypeScript - An IntroductionTypeScript - An Introduction
TypeScript - An Introduction
NexThoughts Technologies
 
Metaprogramming with javascript
Metaprogramming with javascriptMetaprogramming with javascript
Metaprogramming with javascript
Ahmad Rizqi Meydiarso
 
Typescript Fundamentals
Typescript FundamentalsTypescript Fundamentals
Typescript Fundamentals
Sunny Sharma
 
Effective Scala: Programming Patterns
Effective Scala: Programming PatternsEffective Scala: Programming Patterns
Effective Scala: Programming PatternsVasil Remeniuk
 
Scala - the good, the bad and the very ugly
Scala - the good, the bad and the very uglyScala - the good, the bad and the very ugly
Scala - the good, the bad and the very ugly
Bozhidar Bozhanov
 
Introduction to programming with python
Introduction to programming with pythonIntroduction to programming with python
Introduction to programming with python
Porimol Chandro
 

What's hot (20)

Functional programming for the Advanced Beginner
Functional programming for the Advanced BeginnerFunctional programming for the Advanced Beginner
Functional programming for the Advanced Beginner
 
Java Building Blocks
Java Building BlocksJava Building Blocks
Java Building Blocks
 
GeekAustin PHP Class - Session 6
GeekAustin PHP Class - Session 6GeekAustin PHP Class - Session 6
GeekAustin PHP Class - Session 6
 
Object oriented javascript
Object oriented javascriptObject oriented javascript
Object oriented javascript
 
TypeScript - Silver Bullet for the Full-stack Developers
TypeScript - Silver Bullet for the Full-stack DevelopersTypeScript - Silver Bullet for the Full-stack Developers
TypeScript - Silver Bullet for the Full-stack Developers
 
Java and the JVM
Java and the JVMJava and the JVM
Java and the JVM
 
TypeScript 101
TypeScript 101TypeScript 101
TypeScript 101
 
Functional Programming in Java
Functional Programming in JavaFunctional Programming in Java
Functional Programming in Java
 
TypeScript Best Practices
TypeScript Best PracticesTypeScript Best Practices
TypeScript Best Practices
 
Concurrency & Parallel Programming
Concurrency & Parallel ProgrammingConcurrency & Parallel Programming
Concurrency & Parallel Programming
 
Functional programming with Xtend
Functional programming with XtendFunctional programming with Xtend
Functional programming with Xtend
 
cpp-2013 #9 STL Algorithms Part 1
cpp-2013 #9 STL Algorithms Part 1cpp-2013 #9 STL Algorithms Part 1
cpp-2013 #9 STL Algorithms Part 1
 
2CPP04 - Objects and Classes
2CPP04 - Objects and Classes2CPP04 - Objects and Classes
2CPP04 - Objects and Classes
 
Typescript for the programmers who like javascript
Typescript for the programmers who like javascriptTypescript for the programmers who like javascript
Typescript for the programmers who like javascript
 
TypeScript - An Introduction
TypeScript - An IntroductionTypeScript - An Introduction
TypeScript - An Introduction
 
Metaprogramming with javascript
Metaprogramming with javascriptMetaprogramming with javascript
Metaprogramming with javascript
 
Typescript Fundamentals
Typescript FundamentalsTypescript Fundamentals
Typescript Fundamentals
 
Effective Scala: Programming Patterns
Effective Scala: Programming PatternsEffective Scala: Programming Patterns
Effective Scala: Programming Patterns
 
Scala - the good, the bad and the very ugly
Scala - the good, the bad and the very uglyScala - the good, the bad and the very ugly
Scala - the good, the bad and the very ugly
 
Introduction to programming with python
Introduction to programming with pythonIntroduction to programming with python
Introduction to programming with python
 

Viewers also liked

Que es el correo electronico
Que es el correo electronicoQue es el correo electronico
Que es el correo electronico
LicDiegoM
 
Infographic
Infographic Infographic
Infographic
Content Kwekers
 
EU: Polystyrene, In Primary Forms - Market Report. Analysis And Forecast To 2020
EU: Polystyrene, In Primary Forms - Market Report. Analysis And Forecast To 2020EU: Polystyrene, In Primary Forms - Market Report. Analysis And Forecast To 2020
EU: Polystyrene, In Primary Forms - Market Report. Analysis And Forecast To 2020
IndexBox Marketing
 
Nazismo
NazismoNazismo
Proyecto de la feria de la ciencia
Proyecto de la feria de la cienciaProyecto de la feria de la ciencia
Proyecto de la feria de la ciencia
Facebook
 
A'NUE LIGNE
A'NUE LIGNE A'NUE LIGNE
A'NUE LIGNE
Mariam Elias
 
The Next Generation Datacenter
The Next Generation DatacenterThe Next Generation Datacenter
The Next Generation Datacenter
Red Hat Events
 
John Deere 6000 6010 series tractor
John Deere 6000 6010 series tractorJohn Deere 6000 6010 series tractor
John Deere 6000 6010 series tractor
Rimsky Cheng
 
Project report on polystyrene (ps)
Project report on polystyrene (ps)Project report on polystyrene (ps)
Project report on polystyrene (ps)
Lanka Anil raj
 
Why you should integrate peer code reviews in your software company
Why you should integrate peer code reviews in your software companyWhy you should integrate peer code reviews in your software company
Why you should integrate peer code reviews in your software company
Matts Devriendt
 
POLYSTYRENE
POLYSTYRENEPOLYSTYRENE
POLYSTYRENE
lukkumanul
 
Things You MUST Know Before Deploying OpenStack: Bruno Lago, Catalyst IT
Things You MUST Know Before Deploying OpenStack: Bruno Lago, Catalyst ITThings You MUST Know Before Deploying OpenStack: Bruno Lago, Catalyst IT
Things You MUST Know Before Deploying OpenStack: Bruno Lago, Catalyst IT
OpenStack
 
Te ushqehemi dhe jo te hame!
Te ushqehemi dhe jo te hame!Te ushqehemi dhe jo te hame!
Te ushqehemi dhe jo te hame!
Egla Mërzheku
 
History Of Graphic Design
History Of Graphic DesignHistory Of Graphic Design
History Of Graphic Design
Mariam Elias
 

Viewers also liked (14)

Que es el correo electronico
Que es el correo electronicoQue es el correo electronico
Que es el correo electronico
 
Infographic
Infographic Infographic
Infographic
 
EU: Polystyrene, In Primary Forms - Market Report. Analysis And Forecast To 2020
EU: Polystyrene, In Primary Forms - Market Report. Analysis And Forecast To 2020EU: Polystyrene, In Primary Forms - Market Report. Analysis And Forecast To 2020
EU: Polystyrene, In Primary Forms - Market Report. Analysis And Forecast To 2020
 
Nazismo
NazismoNazismo
Nazismo
 
Proyecto de la feria de la ciencia
Proyecto de la feria de la cienciaProyecto de la feria de la ciencia
Proyecto de la feria de la ciencia
 
A'NUE LIGNE
A'NUE LIGNE A'NUE LIGNE
A'NUE LIGNE
 
The Next Generation Datacenter
The Next Generation DatacenterThe Next Generation Datacenter
The Next Generation Datacenter
 
John Deere 6000 6010 series tractor
John Deere 6000 6010 series tractorJohn Deere 6000 6010 series tractor
John Deere 6000 6010 series tractor
 
Project report on polystyrene (ps)
Project report on polystyrene (ps)Project report on polystyrene (ps)
Project report on polystyrene (ps)
 
Why you should integrate peer code reviews in your software company
Why you should integrate peer code reviews in your software companyWhy you should integrate peer code reviews in your software company
Why you should integrate peer code reviews in your software company
 
POLYSTYRENE
POLYSTYRENEPOLYSTYRENE
POLYSTYRENE
 
Things You MUST Know Before Deploying OpenStack: Bruno Lago, Catalyst IT
Things You MUST Know Before Deploying OpenStack: Bruno Lago, Catalyst ITThings You MUST Know Before Deploying OpenStack: Bruno Lago, Catalyst IT
Things You MUST Know Before Deploying OpenStack: Bruno Lago, Catalyst IT
 
Te ushqehemi dhe jo te hame!
Te ushqehemi dhe jo te hame!Te ushqehemi dhe jo te hame!
Te ushqehemi dhe jo te hame!
 
History Of Graphic Design
History Of Graphic DesignHistory Of Graphic Design
History Of Graphic Design
 

Similar to Code reviews

Code reviews
Code reviewsCode reviews
Code reviewsRoger Xia
 
Design p atterns
Design p atternsDesign p atterns
Design p atterns
Amr Abd El Latief
 
Eurosport's Kodakademi #2
Eurosport's Kodakademi #2Eurosport's Kodakademi #2
Eurosport's Kodakademi #2
Benjamin Baumann
 
Orthogonality: A Strategy for Reusable Code
Orthogonality: A Strategy for Reusable CodeOrthogonality: A Strategy for Reusable Code
Orthogonality: A Strategy for Reusable Codersebbe
 
Clean code
Clean codeClean code
Clean code
Simon Sönnby
 
Clean code, Feb 2012
Clean code, Feb 2012Clean code, Feb 2012
Clean code, Feb 2012cobyst
 
Principled And Clean Coding
Principled And Clean CodingPrincipled And Clean Coding
Principled And Clean Coding
Metin Ogurlu
 
Clean code presentation
Clean code presentationClean code presentation
Clean code presentation
Bhavin Gandhi
 
TDD and the Legacy Code Black Hole
TDD and the Legacy Code Black HoleTDD and the Legacy Code Black Hole
TDD and the Legacy Code Black Hole
Noam Kfir
 
Segue to design patterns
Segue to design patternsSegue to design patterns
Segue to design patterns
Rahul Singh
 
Unit Testing Full@
Unit Testing Full@Unit Testing Full@
Unit Testing Full@Alex Borsuk
 
Software development fundamentals
Software development fundamentalsSoftware development fundamentals
Software development fundamentals
Alfred Jett Grandeza
 
Reading Notes : the practice of programming
Reading Notes : the practice of programmingReading Notes : the practice of programming
Reading Notes : the practice of programming
Juggernaut Liu
 
Javascript best practices
Javascript best practicesJavascript best practices
Javascript best practices
Jayanga V. Liyanage
 
Generalization in Auto-Testing. How we put what we had into new Technological...
Generalization in Auto-Testing. How we put what we had into new Technological...Generalization in Auto-Testing. How we put what we had into new Technological...
Generalization in Auto-Testing. How we put what we had into new Technological...
SQALab
 
The View - Lotusscript coding best practices
The View - Lotusscript coding best practicesThe View - Lotusscript coding best practices
The View - Lotusscript coding best practicesBill Buchan
 
Software Design Patterns. Part I :: Structural Patterns
Software Design Patterns. Part I :: Structural PatternsSoftware Design Patterns. Part I :: Structural Patterns
Software Design Patterns. Part I :: Structural Patterns
Sergey Aganezov
 
Ansible Best Practices - July 30
Ansible Best Practices - July 30Ansible Best Practices - July 30
Ansible Best Practices - July 30
tylerturk
 
Refactoring workshop
Refactoring workshop Refactoring workshop
Refactoring workshop
Itzik Saban
 
Improving Software Quality Using Object Oriented Design Principles
Improving Software Quality Using Object Oriented Design PrinciplesImproving Software Quality Using Object Oriented Design Principles
Improving Software Quality Using Object Oriented Design Principles
Dr. Syed Hassan Amin
 

Similar to Code reviews (20)

Code reviews
Code reviewsCode reviews
Code reviews
 
Design p atterns
Design p atternsDesign p atterns
Design p atterns
 
Eurosport's Kodakademi #2
Eurosport's Kodakademi #2Eurosport's Kodakademi #2
Eurosport's Kodakademi #2
 
Orthogonality: A Strategy for Reusable Code
Orthogonality: A Strategy for Reusable CodeOrthogonality: A Strategy for Reusable Code
Orthogonality: A Strategy for Reusable Code
 
Clean code
Clean codeClean code
Clean code
 
Clean code, Feb 2012
Clean code, Feb 2012Clean code, Feb 2012
Clean code, Feb 2012
 
Principled And Clean Coding
Principled And Clean CodingPrincipled And Clean Coding
Principled And Clean Coding
 
Clean code presentation
Clean code presentationClean code presentation
Clean code presentation
 
TDD and the Legacy Code Black Hole
TDD and the Legacy Code Black HoleTDD and the Legacy Code Black Hole
TDD and the Legacy Code Black Hole
 
Segue to design patterns
Segue to design patternsSegue to design patterns
Segue to design patterns
 
Unit Testing Full@
Unit Testing Full@Unit Testing Full@
Unit Testing Full@
 
Software development fundamentals
Software development fundamentalsSoftware development fundamentals
Software development fundamentals
 
Reading Notes : the practice of programming
Reading Notes : the practice of programmingReading Notes : the practice of programming
Reading Notes : the practice of programming
 
Javascript best practices
Javascript best practicesJavascript best practices
Javascript best practices
 
Generalization in Auto-Testing. How we put what we had into new Technological...
Generalization in Auto-Testing. How we put what we had into new Technological...Generalization in Auto-Testing. How we put what we had into new Technological...
Generalization in Auto-Testing. How we put what we had into new Technological...
 
The View - Lotusscript coding best practices
The View - Lotusscript coding best practicesThe View - Lotusscript coding best practices
The View - Lotusscript coding best practices
 
Software Design Patterns. Part I :: Structural Patterns
Software Design Patterns. Part I :: Structural PatternsSoftware Design Patterns. Part I :: Structural Patterns
Software Design Patterns. Part I :: Structural Patterns
 
Ansible Best Practices - July 30
Ansible Best Practices - July 30Ansible Best Practices - July 30
Ansible Best Practices - July 30
 
Refactoring workshop
Refactoring workshop Refactoring workshop
Refactoring workshop
 
Improving Software Quality Using Object Oriented Design Principles
Improving Software Quality Using Object Oriented Design PrinciplesImproving Software Quality Using Object Oriented Design Principles
Improving Software Quality Using Object Oriented Design Principles
 

More from Roger Xia

机器学习推动金融数据智能
机器学习推动金融数据智能机器学习推动金融数据智能
机器学习推动金融数据智能Roger Xia
 
Learning notes ruby
Learning notes rubyLearning notes ruby
Learning notes rubyRoger Xia
 
Converged open platform for enterprise
Converged open platform for enterpriseConverged open platform for enterprise
Converged open platform for enterpriseRoger Xia
 
E commerce search strategies
E commerce search strategiesE commerce search strategies
E commerce search strategiesRoger Xia
 
Indefero source code_managment
Indefero source code_managmentIndefero source code_managment
Indefero source code_managmentRoger Xia
 
Web Services Atomic Transactio
 Web Services Atomic Transactio Web Services Atomic Transactio
Web Services Atomic Transactio
Roger Xia
 
Web service through cxf
Web service through cxfWeb service through cxf
Web service through cxfRoger Xia
 
Q con london2011-matthewwall-whyichosemongodbforguardiancouk
Q con london2011-matthewwall-whyichosemongodbforguardiancoukQ con london2011-matthewwall-whyichosemongodbforguardiancouk
Q con london2011-matthewwall-whyichosemongodbforguardiancouk
Roger Xia
 
Spring one2gx2010 spring-nonrelational_data
Spring one2gx2010 spring-nonrelational_dataSpring one2gx2010 spring-nonrelational_data
Spring one2gx2010 spring-nonrelational_data
Roger Xia
 
Consistency-New-Generation-Databases
Consistency-New-Generation-DatabasesConsistency-New-Generation-Databases
Consistency-New-Generation-DatabasesRoger Xia
 
Java explore
Java exploreJava explore
Java explore
Roger Xia
 
Mongo db实战
Mongo db实战Mongo db实战
Mongo db实战
Roger Xia
 
Ca siteminder
Ca siteminderCa siteminder
Ca siteminder
Roger Xia
 
Fixing twitter
Fixing twitterFixing twitter
Fixing twitter
Roger Xia
 
Eclipse plug in mylyn & tasktop
Eclipse plug in mylyn & tasktopEclipse plug in mylyn & tasktop
Eclipse plug in mylyn & tasktop
Roger Xia
 
新浪微博架构猜想
新浪微博架构猜想新浪微博架构猜想
新浪微博架构猜想
Roger Xia
 
构建高效能的Web网站 精选版-by-infoq
构建高效能的Web网站 精选版-by-infoq构建高效能的Web网站 精选版-by-infoq
构建高效能的Web网站 精选版-by-infoq
Roger Xia
 
Jenkins
JenkinsJenkins
Jenkins
Roger Xia
 

More from Roger Xia (20)

机器学习推动金融数据智能
机器学习推动金融数据智能机器学习推动金融数据智能
机器学习推动金融数据智能
 
Learning notes ruby
Learning notes rubyLearning notes ruby
Learning notes ruby
 
Converged open platform for enterprise
Converged open platform for enterpriseConverged open platform for enterprise
Converged open platform for enterprise
 
E commerce search strategies
E commerce search strategiesE commerce search strategies
E commerce search strategies
 
Saml
SamlSaml
Saml
 
JavaEE6
JavaEE6JavaEE6
JavaEE6
 
Indefero source code_managment
Indefero source code_managmentIndefero source code_managment
Indefero source code_managment
 
Web Services Atomic Transactio
 Web Services Atomic Transactio Web Services Atomic Transactio
Web Services Atomic Transactio
 
Web service through cxf
Web service through cxfWeb service through cxf
Web service through cxf
 
Q con london2011-matthewwall-whyichosemongodbforguardiancouk
Q con london2011-matthewwall-whyichosemongodbforguardiancoukQ con london2011-matthewwall-whyichosemongodbforguardiancouk
Q con london2011-matthewwall-whyichosemongodbforguardiancouk
 
Spring one2gx2010 spring-nonrelational_data
Spring one2gx2010 spring-nonrelational_dataSpring one2gx2010 spring-nonrelational_data
Spring one2gx2010 spring-nonrelational_data
 
Consistency-New-Generation-Databases
Consistency-New-Generation-DatabasesConsistency-New-Generation-Databases
Consistency-New-Generation-Databases
 
Java explore
Java exploreJava explore
Java explore
 
Mongo db实战
Mongo db实战Mongo db实战
Mongo db实战
 
Ca siteminder
Ca siteminderCa siteminder
Ca siteminder
 
Fixing twitter
Fixing twitterFixing twitter
Fixing twitter
 
Eclipse plug in mylyn & tasktop
Eclipse plug in mylyn & tasktopEclipse plug in mylyn & tasktop
Eclipse plug in mylyn & tasktop
 
新浪微博架构猜想
新浪微博架构猜想新浪微博架构猜想
新浪微博架构猜想
 
构建高效能的Web网站 精选版-by-infoq
构建高效能的Web网站 精选版-by-infoq构建高效能的Web网站 精选版-by-infoq
构建高效能的Web网站 精选版-by-infoq
 
Jenkins
JenkinsJenkins
Jenkins
 

Recently uploaded

Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
Abida Shariff
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Jeffrey Haguewood
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
Product School
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Product School
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 

Recently uploaded (20)

Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 

Code reviews

  • 1. Every Programmer Should Know Code Reviews Roger Xia July 2012
  • 3. Programming & Code review • Programming is – Taking an algorithm – Choosing a language – Using that language to implement algorithm and solve problems • Code review is – ?
  • 4. Why? • Increase Quality & Reduce Defects • Improve readability • Share knowledge in team • Know your workmate better! • Two Wrongs Can Make a Right • NOT personal attack! • NOT architect reviews everything
  • 5. methodology • Team review (Planned 1-2 hour/week, Clear roles) • Pair programming (Share knowledge, 1 task) • Walkthrough (Author leads, reviewers take notes, higher level) • Peer review (Asynchronous) • Gerrit • Reaction & Ask questions
  • 6.
  • 7. Preparation • Code Conventions • Findbugs • Tested • Test case
  • 8. Take care of • naming convention spelling mistakes • business logic • refactoring • performance • security (attack, thread safe)
  • 9. Refactoring • Refactoring modifies software to improve its readability, maintainability, and extensibility without changing what it actually does. • Martin Fowler uses “code smells” to identify when to refactor. • Boss: "Refactoring is an overhead activity - I'm paid to write new, revenue generating features."
  • 10. Code smells • Bad names • Duplicate code • Long method • Large class • Long parameter list • Temporary field • Speculative Generality • Data Class • Don’t flood log
  • 12. Meaningful Names • Class names – Should be nouns or noun phrases. – Examples: Car, Account, DataRetrievalService, AddressParser • Method names – Should be verb or verbPhrases – Examples: parseData, deletePage, save – Methods that return boolean values should sound like question. – Examples: isAuthenticated, hasNoErrors, isEmpty • Interface and Implementation – ICache  LRUCache – IExport  ExportService • Constants – MAX_VALUE – SEP_COMMA, SEP_SEMICOLON
  • 13. The Art of Readable code • The book! • I want to point out: – Use blank to separate logic block.
  • 14. Comments for complex process, algorithm, reasons
  • 15. Aiming for simplicity • Do one thing in a function (simple responsibility) • Have no side effects. • Prefer exceptions to return codes. • Format your code.
  • 16. DRY -- Don’t repeat yourself • Duplicated code should be avoided. • Object Orientation, Abstract! • Design pattern!
  • 17. OO Principles • Simple responsibility principle: Class should have one and only one reason to change. • Encapsulation: Modules should not know internal details of objects it manipulates. • Polymorphism -- Liskov’s substitution principle: A subclass can be used as an argument where a base class is expected. • Open-closed principle: Class should be open for extention, but closed for modification.
  • 19. Pay Attention to Performance • JAVA: JVM usage – Don’t create object in loop – Use ArrayList, HashMap etc as opposed to Vector, Hashtable etc (synchronized) where possible. Even better is to use just arrays where possible. – Set initial capacity of a collection (e.g. ArrayList, HashMap) and StringBuffer/StringBuilder appropriately. – Concurrent Collection, Lock – Lazy load or multi-threading where applicable. – Cache (LRUCache, Distributed Cache)
  • 20. Pay Attention to Performance
  • 21. Pay Attention to Security • Sandbox (security manager, access manager, Classloaders, policies) • Scope: Access modifier to help protect your classes, methods, fields. – public, protected, private, package – Exceptions: object serialization, reflection, • Immutable class – final – String – Insecure direct object reference of mutable object • Type safe – Casting • Thread safe • OOM (static), file description handler, release resources (File, DBConnection) • SQL injection • Single point of failure
  • 23. Have Fun and win http://rosettacode.org/wiki/Rosetta_Code

Editor's Notes

  1. Loose couple:FacadeSpringMessaging
  2. Temporary fieldAn attribute of an object is only set in certain circumstances; but an object should need all of its attributes Speculative Generality“Oh I think we need the ability to do this kind of thing someday” Data ClassThese are classes that have fields, getting and setting methods for the fields, and nothing else; they are data holders, but objects should be about data AND behavior
  3. http://www.slideshare.net/srikanthps/practices-for-becoming-a-better-programmer-presentation
  4. Are we writing comments because our code is unclear?Will you keep the comments up-to-date whenever code is updated?
  5. If there is a bug in the code or code requires changes, then, one has to change it at multiple places.
  6. http://www.lifeyun.com/design-pattern-diagram.html
  7. http://www.artima.com/insidejvm/ed2/jvm2.html
  8. http://www.artima.com/insidejvm/ed2/jvm2.html
  9. Mitigation of serialization:- Don’t extend java.io.serializable- ImplementreadObject and writeObject as final methods that throw IOException- If serialize you must: use transient or use java.io.Externalizeable plus Encryption