SlideShare ist ein Scribd-Unternehmen logo
1 von 13
Downloaden Sie, um offline zu lesen
Creating your own
coding style
Dr. Ir. Philippe Faes
● What is coding style
● Purpose of a coding style
● Types of coding rules
● Quality criteria for coding rules
● Enforcing coding style
Overview
What is a coding style?
Programming style is a set of rules or guidelines used
when writing the source code for a computer program. It is
often claimed that following a particular programming style
will help programmers to read and understand source code
conforming to the style, and help to avoid introducing
errors. [wikipedia]
Brought to attention in 1974 by Kernighan and Plauger
book: “The Elements of Programming Style”
synonyms:
[coding | programming | style] [style | conventions | rules]
What is its Purpose?
● Increase readability and maintainability
(= reusability)
● Reduce risk of defects
●
Rules severities
Good practice:
Try to avoid this, but we won’t complain if you
break this rule.
Recommendation:
Avoid this. You have to document when you
break this rule.
Strong Recommendation:
Don’t break this rule. No excuses.
Useful rules are rules that have important
implications, and there is a good reason for
having this rule, even if there may be
arguments against it.
Arbitrary rules don’t have large practical
implications. Sometimes arbitrary rules are
used for consistency.
Adverse rules don’t have any benefit. The
claimed benefit may be incorrect or outdated.
How to read rules
Useful rules: examples
● sensitivity lists
● rules for clock domain crossing
● recommended third-party or in-house libraries
● deprecated libraries
ieee.std_logic_unsigned
● style for Finite State Machines
● reset strategy, initial values of signals or
variables
● allowed / disallowed preprocessor code
Arbitrary rules: examples
Usually rules that improve code consistency.
● Capitalisation: UPPER and lower case
● Indentation and whitespace
● Naming conventions like rst_n
● File structure, copyright headers
Formalise what you have.
Don’t overdo these rules.
Adverse rules
Many rules that include “weasel terms” like:
○ “... may result in larger circuit”
○ “... may result in slower clock speed”
Ask yourself:
● Is this documented?
○ Can I verify this for my current synthesis tool?
○ Which code snippet and with which tool chain?
=> TEST it yourself
● Is it important?
○ error-free, on time, on budget
versus saving two LUTs or 5% of clock speed
=> use common sense
“Some synthesis tools may not support this.”
Ask youself: which synthesis tools?
(not AcmeSynth from 1994?)
If you sell IP cores, you may have to adhere to the
greatest common denominator of current (not historical!)
synthesis tools.
If you build your own design, you should only worry about
your current tool chain, or a few common and modern tool
chains.
Not supported for synthesis?
Do NOT start from somebody else’s style book!
● You are prone to copy their errors
● Instead: read a few style books and then put
them away for a week.
● Be critical of rules and validate their reason
for existing
How to start writing
your own style guide
Example stylebook structure
● file and directory structure and naming
● file headers, what to put in a file
● naming conventions
Creating your own coding style

Weitere ähnliche Inhalte

Ähnlich wie Creating your own coding style

The View - 30 proven Lotuscript tips
The View - 30 proven Lotuscript tipsThe View - 30 proven Lotuscript tips
The View - 30 proven Lotuscript tips
Bill Buchan
 
The View - Lotusscript coding best practices
The View - Lotusscript coding best practicesThe View - Lotusscript coding best practices
The View - Lotusscript coding best practices
Bill Buchan
 
The "Evils" of Optimization
The "Evils" of OptimizationThe "Evils" of Optimization
The "Evils" of Optimization
BlackRabbitCoder
 

Ähnlich wie Creating your own coding style (20)

The View - 30 proven Lotuscript tips
The View - 30 proven Lotuscript tipsThe View - 30 proven Lotuscript tips
The View - 30 proven Lotuscript tips
 
The View - Lotusscript coding best practices
The View - Lotusscript coding best practicesThe View - Lotusscript coding best practices
The View - Lotusscript coding best practices
 
Developers Best Practices
Developers Best PracticesDevelopers Best Practices
Developers Best Practices
 
Coding standards
Coding standardsCoding standards
Coding standards
 
Capability Building for Cyber Defense: Software Walk through and Screening
Capability Building for Cyber Defense: Software Walk through and Screening Capability Building for Cyber Defense: Software Walk through and Screening
Capability Building for Cyber Defense: Software Walk through and Screening
 
Reading Notes : the practice of programming
Reading Notes : the practice of programmingReading Notes : the practice of programming
Reading Notes : the practice of programming
 
Code Review for iOS
Code Review for iOSCode Review for iOS
Code Review for iOS
 
The "Evils" of Optimization
The "Evils" of OptimizationThe "Evils" of Optimization
The "Evils" of Optimization
 
PHP Code Quality
PHP Code QualityPHP Code Quality
PHP Code Quality
 
The automation of the process of caring for the quality of the code in PHP an...
The automation of the process of caring for the quality of the code in PHP an...The automation of the process of caring for the quality of the code in PHP an...
The automation of the process of caring for the quality of the code in PHP an...
 
Automating C# Coding Standards using StyleCop and FxCop
Automating C# Coding Standards using StyleCop and FxCopAutomating C# Coding Standards using StyleCop and FxCop
Automating C# Coding Standards using StyleCop and FxCop
 
Agile Software Development
Agile Software DevelopmentAgile Software Development
Agile Software Development
 
Software development best practices & coding guidelines
Software development best practices & coding guidelinesSoftware development best practices & coding guidelines
Software development best practices & coding guidelines
 
Enforcing Style Guide Rules for Technical Documents
Enforcing Style Guide Rules for Technical DocumentsEnforcing Style Guide Rules for Technical Documents
Enforcing Style Guide Rules for Technical Documents
 
Design Like a Pro: Scripting Best Practices
Design Like a Pro: Scripting Best PracticesDesign Like a Pro: Scripting Best Practices
Design Like a Pro: Scripting Best Practices
 
Design Like a Pro: Scripting Best Practices
Design Like a Pro: Scripting Best PracticesDesign Like a Pro: Scripting Best Practices
Design Like a Pro: Scripting Best Practices
 
Coding
CodingCoding
Coding
 
An Introduction To Software Development - Implementation
An Introduction To Software Development - ImplementationAn Introduction To Software Development - Implementation
An Introduction To Software Development - Implementation
 
YAGNI Principle and Clean Code
YAGNI Principle and Clean CodeYAGNI Principle and Clean Code
YAGNI Principle and Clean Code
 
Coding conventions
Coding conventionsCoding conventions
Coding conventions
 

Mehr von Sigasi (8)

The future of teaching hdl with Sigasi Studio
The future of teaching hdl with Sigasi StudioThe future of teaching hdl with Sigasi Studio
The future of teaching hdl with Sigasi Studio
 
Domain specific languages in eclipse with Xtext (Zeus, UGent)
Domain specific languages in eclipse with Xtext (Zeus, UGent)Domain specific languages in eclipse with Xtext (Zeus, UGent)
Domain specific languages in eclipse with Xtext (Zeus, UGent)
 
Shortening the feedback loop: faster and better code development
Shortening the feedback loop: faster and better code developmentShortening the feedback loop: faster and better code development
Shortening the feedback loop: faster and better code development
 
Plc2 2015 first time right coding
Plc2 2015 first time right codingPlc2 2015 first time right coding
Plc2 2015 first time right coding
 
Plc2 2015 your own ide
Plc2 2015 your own idePlc2 2015 your own ide
Plc2 2015 your own ide
 
Graphical Programming is Dead
Graphical Programming is DeadGraphical Programming is Dead
Graphical Programming is Dead
 
Building a software business — lessons learned
Building a software business — lessons learnedBuilding a software business — lessons learned
Building a software business — lessons learned
 
EclipseCon Europe 2011
EclipseCon Europe 2011EclipseCon Europe 2011
EclipseCon Europe 2011
 

Kürzlich hochgeladen

+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@
 

Kürzlich hochgeladen (20)

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
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
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
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
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...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
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...
 
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...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
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
 

Creating your own coding style

  • 1. Creating your own coding style Dr. Ir. Philippe Faes
  • 2. ● What is coding style ● Purpose of a coding style ● Types of coding rules ● Quality criteria for coding rules ● Enforcing coding style Overview
  • 3. What is a coding style? Programming style is a set of rules or guidelines used when writing the source code for a computer program. It is often claimed that following a particular programming style will help programmers to read and understand source code conforming to the style, and help to avoid introducing errors. [wikipedia] Brought to attention in 1974 by Kernighan and Plauger book: “The Elements of Programming Style” synonyms: [coding | programming | style] [style | conventions | rules]
  • 4. What is its Purpose? ● Increase readability and maintainability (= reusability) ● Reduce risk of defects ●
  • 5. Rules severities Good practice: Try to avoid this, but we won’t complain if you break this rule. Recommendation: Avoid this. You have to document when you break this rule. Strong Recommendation: Don’t break this rule. No excuses.
  • 6. Useful rules are rules that have important implications, and there is a good reason for having this rule, even if there may be arguments against it. Arbitrary rules don’t have large practical implications. Sometimes arbitrary rules are used for consistency. Adverse rules don’t have any benefit. The claimed benefit may be incorrect or outdated. How to read rules
  • 7. Useful rules: examples ● sensitivity lists ● rules for clock domain crossing ● recommended third-party or in-house libraries ● deprecated libraries ieee.std_logic_unsigned ● style for Finite State Machines ● reset strategy, initial values of signals or variables ● allowed / disallowed preprocessor code
  • 8. Arbitrary rules: examples Usually rules that improve code consistency. ● Capitalisation: UPPER and lower case ● Indentation and whitespace ● Naming conventions like rst_n ● File structure, copyright headers Formalise what you have. Don’t overdo these rules.
  • 9. Adverse rules Many rules that include “weasel terms” like: ○ “... may result in larger circuit” ○ “... may result in slower clock speed” Ask yourself: ● Is this documented? ○ Can I verify this for my current synthesis tool? ○ Which code snippet and with which tool chain? => TEST it yourself ● Is it important? ○ error-free, on time, on budget versus saving two LUTs or 5% of clock speed => use common sense
  • 10. “Some synthesis tools may not support this.” Ask youself: which synthesis tools? (not AcmeSynth from 1994?) If you sell IP cores, you may have to adhere to the greatest common denominator of current (not historical!) synthesis tools. If you build your own design, you should only worry about your current tool chain, or a few common and modern tool chains. Not supported for synthesis?
  • 11. Do NOT start from somebody else’s style book! ● You are prone to copy their errors ● Instead: read a few style books and then put them away for a week. ● Be critical of rules and validate their reason for existing How to start writing your own style guide
  • 12. Example stylebook structure ● file and directory structure and naming ● file headers, what to put in a file ● naming conventions