SlideShare a Scribd company logo
1 of 13
Good coding style
A drama in 12 parts with an epilogue
Konstantin Osipov
Staff Engineer
Sun/MySQL
kostja@sun.com
These slides released under the Creative Commons 
Attribution­Noncommercial­Share Alike License
Agenda
●
It's all Monty's fault! Or maybe not?
● Define the problem
● What can be done
● Call to arms
●
Thank you & References
What's a good coding style?
●
C++ FAQ Lite:
Thank you for reading this answer rather than just trying to set your own
coding standards.
But beware that some people on comp.lang.c++ are very sensitive on this issue.
Nearly every software engineer has, at some point, been exploited by someone
who used coding standards as a "power play." Furthermore some attempts to set
C++ coding standards have been made by those who didn't know what they were
talking about, so the standards end up being based on what was the
state-of-the-art when the standards setters were writing code. Such
impositions generate an attitude of mistrust for coding standards.
Why is it a problem: the style is obsolete
kostja@bodhi:~/work/mysql-6.0-runtime/sql$ grep '<true>' *.{h,cc}
| grep -v sql_yacc.cc | wc -l
356356
kostja@bodhi:~/work/mysql-6.0-runtime/sql$ grep '<false>' *.
{h,cc} | grep -v sql_yacc.cc | wc -l
212
Why is it a problem: the style is ignored
struct st_bstream_snapshot_info
class QUICK_RANGE
class DsMrr_impl
class MDL_context and class DDL_blocker_class
typedef struct st_table_ref TABLE_REF
class NdbScanOperation and class TableEvent
class sp_head and sp_instr_jump
Why is it a problem: maintenance
Foo::Foo(int a_arg, int b_arg, int c_arg)
: a(a_arg), b(b_arg), c(c_arg)
-> rename or add a member
int descriptive_identifier_name1= 1;
char not_so_descriptive= 2;
-> now add a declaration of very_long_and_descriptive_identifier3
My_long_class_name::My_long_class_name(int param1, Type1 param 2,
Type2 param3);
-> rename the class or the method
Why is It a problem: practice
●
sheer neglect to copy constructors and
assignment operators
● all members are public, in new code as well
●
-> C++ practice guide is missing
Define a good coding style, attempt #2
●
helps readability
● prevents coding mistakes
● simplifies maintenance
● easy to learn
●
unambiguous
●
comes with a best practices guide
A change is called for!
Possible immediate steps:
● prefer new/delete to malloc()/free() wherever
possible
●
TRUE -> true, FALSE -> false switch
● m_ prefixes for private class members
● remove typedef st_name {} NAME constructs
● your pet peeve can be here, if it's also
everybody's
The criticism
●
what we have is good enough, and everybody is
used to it
● there are more important problems (AKA re-
engineering is our savior)
●
a change means the code is always half-way
through it. Doxygen comments adoption.
●
changes in the style is a revision history noise
What can be done?
●
let's talk about it, but not too much
● accept and follow the current status quo
● improve what we have, with care
Thank you!
References
●
MySQL coding guidelines :
http://forge.mysql.com/wiki/MySQL_Internals_Coding_Guidelines
●
C++ FAQ lite: http://www.parashift.com/c++-faq-lite/
●
Bjarne Stroustrup's FAQ: http://www.research.att.com/~bs/bs_faq.html
●
C++ Style Guide from Geosoft.no: http://geosoft.no/development/cppstyle.html
●
Collection of other styles: http://www.chris-lott.org/resources/cstyle/

More Related Content

What's hot

Basics of writing clean code
Basics of writing clean codeBasics of writing clean code
Basics of writing clean codeKnoldus Inc.
 
Exceptions: Why, When, How and Where!
Exceptions: Why, When, How and Where!Exceptions: Why, When, How and Where!
Exceptions: Why, When, How and Where!Hernan Wilkinson
 
Elixir Brasil 2019 - Quality: A Panacéia para seu código Elixir
Elixir Brasil 2019 - Quality:  A Panacéia para seu código ElixirElixir Brasil 2019 - Quality:  A Panacéia para seu código Elixir
Elixir Brasil 2019 - Quality: A Panacéia para seu código ElixirWeverton Timoteo
 
TDD python ne-april-2014
TDD python ne-april-2014TDD python ne-april-2014
TDD python ne-april-2014Alex Kavanagh
 
Clean Code - Part 2
Clean Code - Part 2Clean Code - Part 2
Clean Code - Part 2Knoldus Inc.
 
Javascript: The good parts for humans (part 1)
Javascript: The good parts for humans (part 1)Javascript: The good parts for humans (part 1)
Javascript: The good parts for humans (part 1)Anji Beeravalli
 
TDD for the masses
TDD for the massesTDD for the masses
TDD for the massesJorge Ortiz
 
Go/Ruby/Java: What's next?
Go/Ruby/Java: What's next?Go/Ruby/Java: What's next?
Go/Ruby/Java: What's next?Hernan Wilkinson
 
(6) cpp abstractions inheritance_part_i_exercises
(6) cpp abstractions inheritance_part_i_exercises(6) cpp abstractions inheritance_part_i_exercises
(6) cpp abstractions inheritance_part_i_exercisesNico Ludwig
 
Test Driven Development in Python
Test Driven Development in PythonTest Driven Development in Python
Test Driven Development in PythonAnoop Thomas Mathew
 
Practical pointers for better code review
Practical pointers for better code reviewPractical pointers for better code review
Practical pointers for better code reviewkhink
 
SubTests are the Best
SubTests are the BestSubTests are the Best
SubTests are the BestCaktus Group
 
Lập trình hướng kiểm thử - Test Driven development
Lập trình hướng kiểm thử - Test Driven developmentLập trình hướng kiểm thử - Test Driven development
Lập trình hướng kiểm thử - Test Driven developmentAnh Lê
 
TDD er død. Lenge leve TDD!
TDD er død. Lenge leve TDD!TDD er død. Lenge leve TDD!
TDD er død. Lenge leve TDD!Kjetil Klaussen
 
SOLID refactoring - racing car katas
SOLID refactoring - racing car katasSOLID refactoring - racing car katas
SOLID refactoring - racing car katasGeorg Berky
 
Test driven development_and_puppet-cfgmgmtcamp_eu-20140402
Test driven development_and_puppet-cfgmgmtcamp_eu-20140402Test driven development_and_puppet-cfgmgmtcamp_eu-20140402
Test driven development_and_puppet-cfgmgmtcamp_eu-20140402Johan De Wit
 
I'm a TDD cheat and I'm not afraid to admit it
I'm a TDD cheat and I'm not afraid to admit itI'm a TDD cheat and I'm not afraid to admit it
I'm a TDD cheat and I'm not afraid to admit itDaniel Irvine
 

What's hot (20)

Basics of writing clean code
Basics of writing clean codeBasics of writing clean code
Basics of writing clean code
 
Exceptions: Why, When, How and Where!
Exceptions: Why, When, How and Where!Exceptions: Why, When, How and Where!
Exceptions: Why, When, How and Where!
 
Elixir Brasil 2019 - Quality: A Panacéia para seu código Elixir
Elixir Brasil 2019 - Quality:  A Panacéia para seu código ElixirElixir Brasil 2019 - Quality:  A Panacéia para seu código Elixir
Elixir Brasil 2019 - Quality: A Panacéia para seu código Elixir
 
TDD python ne-april-2014
TDD python ne-april-2014TDD python ne-april-2014
TDD python ne-april-2014
 
Clean Code - Part 2
Clean Code - Part 2Clean Code - Part 2
Clean Code - Part 2
 
Javascript: The good parts for humans (part 1)
Javascript: The good parts for humans (part 1)Javascript: The good parts for humans (part 1)
Javascript: The good parts for humans (part 1)
 
TDD for the masses
TDD for the massesTDD for the masses
TDD for the masses
 
TDD & Refactoring
TDD & RefactoringTDD & Refactoring
TDD & Refactoring
 
Go/Ruby/Java: What's next?
Go/Ruby/Java: What's next?Go/Ruby/Java: What's next?
Go/Ruby/Java: What's next?
 
(6) cpp abstractions inheritance_part_i_exercises
(6) cpp abstractions inheritance_part_i_exercises(6) cpp abstractions inheritance_part_i_exercises
(6) cpp abstractions inheritance_part_i_exercises
 
Test Driven Development in Python
Test Driven Development in PythonTest Driven Development in Python
Test Driven Development in Python
 
Practical pointers for better code review
Practical pointers for better code reviewPractical pointers for better code review
Practical pointers for better code review
 
클린 테스트
클린 테스트클린 테스트
클린 테스트
 
SubTests are the Best
SubTests are the BestSubTests are the Best
SubTests are the Best
 
Lập trình hướng kiểm thử - Test Driven development
Lập trình hướng kiểm thử - Test Driven developmentLập trình hướng kiểm thử - Test Driven development
Lập trình hướng kiểm thử - Test Driven development
 
Clean Code, Resumen Capítulo 1.
Clean Code, Resumen Capítulo 1. Clean Code, Resumen Capítulo 1.
Clean Code, Resumen Capítulo 1.
 
TDD er død. Lenge leve TDD!
TDD er død. Lenge leve TDD!TDD er død. Lenge leve TDD!
TDD er død. Lenge leve TDD!
 
SOLID refactoring - racing car katas
SOLID refactoring - racing car katasSOLID refactoring - racing car katas
SOLID refactoring - racing car katas
 
Test driven development_and_puppet-cfgmgmtcamp_eu-20140402
Test driven development_and_puppet-cfgmgmtcamp_eu-20140402Test driven development_and_puppet-cfgmgmtcamp_eu-20140402
Test driven development_and_puppet-cfgmgmtcamp_eu-20140402
 
I'm a TDD cheat and I'm not afraid to admit it
I'm a TDD cheat and I'm not afraid to admit itI'm a TDD cheat and I'm not afraid to admit it
I'm a TDD cheat and I'm not afraid to admit it
 

Viewers also liked

Metadata locking in MySQL 5.5
Metadata locking in MySQL 5.5Metadata locking in MySQL 5.5
Metadata locking in MySQL 5.5Kostja Osipov
 
Emarketerwebinarresponsivedesignsolutionpublishersquestionmarketers 130725135...
Emarketerwebinarresponsivedesignsolutionpublishersquestionmarketers 130725135...Emarketerwebinarresponsivedesignsolutionpublishersquestionmarketers 130725135...
Emarketerwebinarresponsivedesignsolutionpublishersquestionmarketers 130725135...Melanie Eisenberg
 
My talk at Topconf.com conference, Tallinn, 1st of November 2012
My talk at Topconf.com conference, Tallinn, 1st of November 2012My talk at Topconf.com conference, Tallinn, 1st of November 2012
My talk at Topconf.com conference, Tallinn, 1st of November 2012Kostja Osipov
 

Viewers also liked (6)

Nossos projetos
Nossos projetosNossos projetos
Nossos projetos
 
Metadata locking in MySQL 5.5
Metadata locking in MySQL 5.5Metadata locking in MySQL 5.5
Metadata locking in MySQL 5.5
 
Nabucco..
  Nabucco..  Nabucco..
Nabucco..
 
Emarketerwebinarresponsivedesignsolutionpublishersquestionmarketers 130725135...
Emarketerwebinarresponsivedesignsolutionpublishersquestionmarketers 130725135...Emarketerwebinarresponsivedesignsolutionpublishersquestionmarketers 130725135...
Emarketerwebinarresponsivedesignsolutionpublishersquestionmarketers 130725135...
 
Highload2o013 osipv
Highload2o013 osipvHighload2o013 osipv
Highload2o013 osipv
 
My talk at Topconf.com conference, Tallinn, 1st of November 2012
My talk at Topconf.com conference, Tallinn, 1st of November 2012My talk at Topconf.com conference, Tallinn, 1st of November 2012
My talk at Topconf.com conference, Tallinn, 1st of November 2012
 

Similar to Good coding-style, a talk made in 2008 to encourage changes in MySQL coding style

Code sense
Code senseCode sense
Code sensenasirj
 
Software Craftmanship - Cours Polytech
Software Craftmanship - Cours PolytechSoftware Craftmanship - Cours Polytech
Software Craftmanship - Cours Polytechyannick grenzinger
 
Autotools, Design Patterns and more
Autotools, Design Patterns and moreAutotools, Design Patterns and more
Autotools, Design Patterns and moreVicente Bolea
 
Software development best practices & coding guidelines
Software development best practices & coding guidelinesSoftware development best practices & coding guidelines
Software development best practices & coding guidelinesAnkur Goyal
 
AN EXERCISE IN CLEANER CODE - FROM LEGACY TO MAINTAINABLE
AN EXERCISE IN CLEANER CODE - FROM LEGACY TO MAINTAINABLEAN EXERCISE IN CLEANER CODE - FROM LEGACY TO MAINTAINABLE
AN EXERCISE IN CLEANER CODE - FROM LEGACY TO MAINTAINABLEGavin Pickin
 
AN EXERCISE IN CLEANER CODE - FROM LEGACY TO MAINTAINABLE - CFObjective() 2017
AN EXERCISE IN CLEANER CODE - FROM LEGACY TO MAINTAINABLE - CFObjective() 2017AN EXERCISE IN CLEANER CODE - FROM LEGACY TO MAINTAINABLE - CFObjective() 2017
AN EXERCISE IN CLEANER CODE - FROM LEGACY TO MAINTAINABLE - CFObjective() 2017Ortus Solutions, Corp
 
Web performance
Web  performance Web  performance
Web performance Major Ye
 
TDD and Simple Design Workshop - Session 1 - March 2019
TDD and Simple Design Workshop - Session 1 - March 2019TDD and Simple Design Workshop - Session 1 - March 2019
TDD and Simple Design Workshop - Session 1 - March 2019Paulo Clavijo
 
Top Tips Every Notes Developer Needs To Know
Top Tips Every Notes Developer Needs To KnowTop Tips Every Notes Developer Needs To Know
Top Tips Every Notes Developer Needs To KnowKathy Brown
 
Femmengeeniring_Kateryna Mishchenko.pdf
Femmengeeniring_Kateryna Mishchenko.pdfFemmengeeniring_Kateryna Mishchenko.pdf
Femmengeeniring_Kateryna Mishchenko.pdfssuserc16f90
 
Session 3 : Competitive programming 1
Session 3 : Competitive programming 1Session 3 : Competitive programming 1
Session 3 : Competitive programming 1Koderunners
 
Uvm cookbook-systemverilog-guidelines-verification-academy
Uvm cookbook-systemverilog-guidelines-verification-academyUvm cookbook-systemverilog-guidelines-verification-academy
Uvm cookbook-systemverilog-guidelines-verification-academyRaghavendra Kamath
 
Effective cplusplus
Effective cplusplusEffective cplusplus
Effective cplusplusMark Veltzer
 
Introduction to C3.net Architecture unit
Introduction to C3.net Architecture unitIntroduction to C3.net Architecture unit
Introduction to C3.net Architecture unitKotresh Munavallimatt
 
Software Design Principles and Best Practices - Satyajit Dey
Software Design Principles and Best Practices - Satyajit DeySoftware Design Principles and Best Practices - Satyajit Dey
Software Design Principles and Best Practices - Satyajit DeyCefalo
 
C STANDARDS (C17).pptx
C STANDARDS (C17).pptxC STANDARDS (C17).pptx
C STANDARDS (C17).pptxSKUP1
 

Similar to Good coding-style, a talk made in 2008 to encourage changes in MySQL coding style (20)

Code sense
Code senseCode sense
Code sense
 
Software Craftmanship - Cours Polytech
Software Craftmanship - Cours PolytechSoftware Craftmanship - Cours Polytech
Software Craftmanship - Cours Polytech
 
Autotools, Design Patterns and more
Autotools, Design Patterns and moreAutotools, Design Patterns and more
Autotools, Design Patterns and more
 
Software development best practices & coding guidelines
Software development best practices & coding guidelinesSoftware development best practices & coding guidelines
Software development best practices & coding guidelines
 
AN EXERCISE IN CLEANER CODE - FROM LEGACY TO MAINTAINABLE
AN EXERCISE IN CLEANER CODE - FROM LEGACY TO MAINTAINABLEAN EXERCISE IN CLEANER CODE - FROM LEGACY TO MAINTAINABLE
AN EXERCISE IN CLEANER CODE - FROM LEGACY TO MAINTAINABLE
 
AN EXERCISE IN CLEANER CODE - FROM LEGACY TO MAINTAINABLE - CFObjective() 2017
AN EXERCISE IN CLEANER CODE - FROM LEGACY TO MAINTAINABLE - CFObjective() 2017AN EXERCISE IN CLEANER CODE - FROM LEGACY TO MAINTAINABLE - CFObjective() 2017
AN EXERCISE IN CLEANER CODE - FROM LEGACY TO MAINTAINABLE - CFObjective() 2017
 
DDD with Behat
DDD with BehatDDD with Behat
DDD with Behat
 
Code Metrics
Code MetricsCode Metrics
Code Metrics
 
Web performance
Web  performance Web  performance
Web performance
 
TDD and Simple Design Workshop - Session 1 - March 2019
TDD and Simple Design Workshop - Session 1 - March 2019TDD and Simple Design Workshop - Session 1 - March 2019
TDD and Simple Design Workshop - Session 1 - March 2019
 
Top Tips Every Notes Developer Needs To Know
Top Tips Every Notes Developer Needs To KnowTop Tips Every Notes Developer Needs To Know
Top Tips Every Notes Developer Needs To Know
 
Femmengeeniring_Kateryna Mishchenko.pdf
Femmengeeniring_Kateryna Mishchenko.pdfFemmengeeniring_Kateryna Mishchenko.pdf
Femmengeeniring_Kateryna Mishchenko.pdf
 
midterm_fa07.pdf
midterm_fa07.pdfmidterm_fa07.pdf
midterm_fa07.pdf
 
Effective C++
Effective C++Effective C++
Effective C++
 
Session 3 : Competitive programming 1
Session 3 : Competitive programming 1Session 3 : Competitive programming 1
Session 3 : Competitive programming 1
 
Uvm cookbook-systemverilog-guidelines-verification-academy
Uvm cookbook-systemverilog-guidelines-verification-academyUvm cookbook-systemverilog-guidelines-verification-academy
Uvm cookbook-systemverilog-guidelines-verification-academy
 
Effective cplusplus
Effective cplusplusEffective cplusplus
Effective cplusplus
 
Introduction to C3.net Architecture unit
Introduction to C3.net Architecture unitIntroduction to C3.net Architecture unit
Introduction to C3.net Architecture unit
 
Software Design Principles and Best Practices - Satyajit Dey
Software Design Principles and Best Practices - Satyajit DeySoftware Design Principles and Best Practices - Satyajit Dey
Software Design Principles and Best Practices - Satyajit Dey
 
C STANDARDS (C17).pptx
C STANDARDS (C17).pptxC STANDARDS (C17).pptx
C STANDARDS (C17).pptx
 

Recently uploaded

Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsHyundai Motor Group
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetEnjoy Anytime
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 

Recently uploaded (20)

Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 

Good coding-style, a talk made in 2008 to encourage changes in MySQL coding style

  • 1. Good coding style A drama in 12 parts with an epilogue Konstantin Osipov Staff Engineer Sun/MySQL kostja@sun.com These slides released under the Creative Commons  Attribution­Noncommercial­Share Alike License
  • 2. Agenda ● It's all Monty's fault! Or maybe not? ● Define the problem ● What can be done ● Call to arms ● Thank you & References
  • 3. What's a good coding style? ● C++ FAQ Lite: Thank you for reading this answer rather than just trying to set your own coding standards. But beware that some people on comp.lang.c++ are very sensitive on this issue. Nearly every software engineer has, at some point, been exploited by someone who used coding standards as a "power play." Furthermore some attempts to set C++ coding standards have been made by those who didn't know what they were talking about, so the standards end up being based on what was the state-of-the-art when the standards setters were writing code. Such impositions generate an attitude of mistrust for coding standards.
  • 4. Why is it a problem: the style is obsolete kostja@bodhi:~/work/mysql-6.0-runtime/sql$ grep '<true>' *.{h,cc} | grep -v sql_yacc.cc | wc -l 356356 kostja@bodhi:~/work/mysql-6.0-runtime/sql$ grep '<false>' *. {h,cc} | grep -v sql_yacc.cc | wc -l 212
  • 5. Why is it a problem: the style is ignored struct st_bstream_snapshot_info class QUICK_RANGE class DsMrr_impl class MDL_context and class DDL_blocker_class typedef struct st_table_ref TABLE_REF class NdbScanOperation and class TableEvent class sp_head and sp_instr_jump
  • 6. Why is it a problem: maintenance Foo::Foo(int a_arg, int b_arg, int c_arg) : a(a_arg), b(b_arg), c(c_arg) -> rename or add a member int descriptive_identifier_name1= 1; char not_so_descriptive= 2; -> now add a declaration of very_long_and_descriptive_identifier3 My_long_class_name::My_long_class_name(int param1, Type1 param 2, Type2 param3); -> rename the class or the method
  • 7. Why is It a problem: practice ● sheer neglect to copy constructors and assignment operators ● all members are public, in new code as well ● -> C++ practice guide is missing
  • 8. Define a good coding style, attempt #2 ● helps readability ● prevents coding mistakes ● simplifies maintenance ● easy to learn ● unambiguous ● comes with a best practices guide
  • 9. A change is called for! Possible immediate steps: ● prefer new/delete to malloc()/free() wherever possible ● TRUE -> true, FALSE -> false switch ● m_ prefixes for private class members ● remove typedef st_name {} NAME constructs ● your pet peeve can be here, if it's also everybody's
  • 10. The criticism ● what we have is good enough, and everybody is used to it ● there are more important problems (AKA re- engineering is our savior) ● a change means the code is always half-way through it. Doxygen comments adoption. ● changes in the style is a revision history noise
  • 11. What can be done? ● let's talk about it, but not too much ● accept and follow the current status quo ● improve what we have, with care
  • 13. References ● MySQL coding guidelines : http://forge.mysql.com/wiki/MySQL_Internals_Coding_Guidelines ● C++ FAQ lite: http://www.parashift.com/c++-faq-lite/ ● Bjarne Stroustrup's FAQ: http://www.research.att.com/~bs/bs_faq.html ● C++ Style Guide from Geosoft.no: http://geosoft.no/development/cppstyle.html ● Collection of other styles: http://www.chris-lott.org/resources/cstyle/