SlideShare ist ein Scribd-Unternehmen logo
1 von 15
Downloaden Sie, um offline zu lesen
Tips to Comment the Code
       based on 13 Tips to Comment Your Code




                             www.softheme.com
1. Comment each level

Comment each code block, using a uniform approach for each level. For example:

    •    For each class, include a brief description, author and date of last modification
    •    For each method, include a description of its purpose, functions, parameters and
         results

Adopting comment standards is important when working with a team. Of course, it is
acceptable and even advisable to use comment conventions and tools (such as XML in
C# or Javadoc for Java) to facilitate this task.




             www.softheme.com   Outsourcing to Softheme™ Tips to Comment the Code
2. Use paragraph comments

Break code blocks into multiple “paragraphs” that each perform a single task, then
add a comment at the beginning of each block to instruct the reader on what is
about to happen.

              // Check that all data records
              // are correct
              foreach (Record record in records)
              {
                  if (rec.checkStatus()==Status.OK)
                  {
                      . . .
                  }
              }
              // Now we begin to perform
              // transactions
              Context ctx = new ApplicationContext();
              ctx.BeginTransaction();
              . . .



             www.softheme.com   Outsourcing to Softheme™ Tips to Comment the Code
3. Align comments in consecutive lines

For multiple lines of code with trailing comments, align the comments so they will
be easy to read.

    const MAX_ITEMS = 10; // maximum number of packets
    const MASK = 0x1F;    // mask bit TCP

Some developers use tabs to align comments, while others use spaces. Because
tab stops can vary among editors and IDEs, the best approach is to use spaces.




             www.softheme.com   Outsourcing to Softheme™ Tips to Comment the Code
4. Don´t insult the reader´s intelligence

Avoid obvious comments such as:

    if (a == 5)      // if a equals 5
        counter = 0; // set the counter to zero

This wastes your time writing needless comments and distracts the reader with details
that can be easily deduced from the code.




             www.softheme.com   Outsourcing to Softheme™ Tips to Comment the Code
5. Be polite

Avoid rude comments like, “Notice the stupid user has entered a negative number,”
or “This fixes the side effect produced by the pathetically inept implementation of
the initial developer.” Such comments do not reflect well upon their author, and
you never know who may read these comments in the future: your boss, a
customer, or the pathetically inept developer you just insulted.




             www.softheme.com   Outsourcing to Softheme™ Tips to Comment the Code
6. Get to the point

Don’t write more in comments than is needed to convey the idea. Avoid ASCII art,
jokes, poetry and hyperverbosity. In short, keep the comments simple and direct.




            www.softheme.com   Outsourcing to Softheme™ Tips to Comment the Code
7. Use a consistent style

Some people believe that comments should be written so that non-programmers
can understand them. Others believe that comments should be directed at
developers only. In any event, as stated in Successful Strategies for Commenting
Code, what matters is that comments are consistent and always targeted to the
same audience. Personally, I doubt many non-developers will be reading code, so
comments should target other developers.




            www.softheme.com   Outsourcing to Softheme™ Tips to Comment the Code
8. Use special tags for internal use

When working on code as a team, adopt a consistent set of tags to communicate
among programmers. For example, many teams use a “TODO:” tag to indicate a
section of code that requires additional work:

    int Estimate(int x, int y)
    {
        // TODO: implement the calculations
        return 0;
    }

Tag comments don’t explain code; rather they seek attention or deliver a
message. But if you use this technique, remember to follow up and actually do what
the message is asking.




            www.softheme.com   Outsourcing to Softheme™ Tips to Comment the Code
9. Comment code while writing it

Add comments while you write code and it’s fresh in your memory. If you leave
comments until the end, it will take you twice as long, if you do it at all. “I have no
time to comment,” “I’m in a hurry,” and “The project is delayed” are all simply
excuses to avoid documenting your code. Some developers believe you should
write comments before code as a way to plan out your ultimate solution. For
example:

     public   void ProcessOrder()
     {
         //   Make sure the products are available
         //   Check that the customer is valid
         //   Send the order to the store
         //   Generate bill
     }




              www.softheme.com   Outsourcing to Softheme™ Tips to Comment the Code
10. Write comments as if they were for you (in fact, they are)

When it comes to commenting code, think not only about the developers who will
maintain your code in the future, but also think about yourself. In the words of the
great Phil Haack:

“As soon as a line of code is laid on the screen, you’re in maintenance mode on that
piece of code.”

As a result, we ourselves will be the first beneficiaries (or victims) of our good (or
bad) comments.




             www.softheme.com   Outsourcing to Softheme™ Tips to Comment the Code
11. Update comments when you update the code

There is no point in commenting correctly on code if the comments are not changed
with the code. Both code and comments must move in parallel, otherwise the
comments will actually make life more difficult for developers who maintain your
code. Pay special attention to refactoring tools that automatically update code but
leave comments unchanged and hence obsolete in the same instant.




             www.softheme.com   Outsourcing to Softheme™ Tips to Comment the Code
12. The golden rule of comments: readable code

One of the basic principles for many developers: Let your code speak for itself. Although one
suspects this movement is led by programmers who do not like to write comments, it is true
that self-explanatory code can go a long way toward making code that’s easier to understand
and can even render comments unnecessary. For example, the code in my Fluid Interfaces
article shows how clear self-explanatory code can be:

     Calculator calc = new Calculator();
     calc.Set(0);
     calc.Add(10);
     calc.Multiply(2);
     calc.Subtract(4);
     Console.WriteLine( "Result: {0}", calc.Get() );

In this example, comments are not needed and would likely violate tip #4. To facilitate
readable code, you might consider using proper names (as described in the classic Ottinger’s
Rules), ensure correct indentation, and adopt coding style guides. Failure to comply with this
tip may result in comments that seem to apologize for bad code.



              www.softheme.com   Outsourcing to Softheme™ Tips to Comment the Code
13. Share these tips with your colleagues

Although tip #10 shows how we ourselves benefit immediately from good
comments, these tips will benefit all developers, especially in the context of team
working together. Therefore, feel free to share these commenting tips with your
colleagues to create code that is easier to understand and maintain.




             www.softheme.com   Outsourcing to Softheme™ Tips to Comment the Code
Thank you!

                 Questions?     →        info@softheme.com

2010 | Softheme Team | Kyiv, Ukraine | Software Outsourcing Solutions




                  www.softheme.com   »    Outsourcing to Softheme™

Weitere ähnliche Inhalte

Andere mochten auch

Matrix of mutual interest of the citizens , government and business.
Matrix of mutual interest of the citizens , government and business.Matrix of mutual interest of the citizens , government and business.
Matrix of mutual interest of the citizens , government and business.Anatoliy Amelin
 
HWC LLC News - gradual easing of currency control in ukraine
HWC LLC News - gradual easing of currency control in ukraineHWC LLC News - gradual easing of currency control in ukraine
HWC LLC News - gradual easing of currency control in ukraineSven Henniger
 
Salesforce Development and Integration Services for Your Business
Salesforce Development and Integration Services for Your BusinessSalesforce Development and Integration Services for Your Business
Salesforce Development and Integration Services for Your BusinessSoftheme
 
IT due diligence and software quality for fintech startups
IT due diligence and software quality for fintech startupsIT due diligence and software quality for fintech startups
IT due diligence and software quality for fintech startupsSieuwert van Otterloo
 
Mobile development services
Mobile development servicesMobile development services
Mobile development servicesSoftheme
 
BDO Payroll Services
BDO Payroll ServicesBDO Payroll Services
BDO Payroll ServicesBDO Indonesia
 
Outsourcing to CEE. Country Overview. Ukraine
Outsourcing to CEE. Country Overview. UkraineOutsourcing to CEE. Country Overview. Ukraine
Outsourcing to CEE. Country Overview. UkraineHI-TECH_Org_Ua
 
Tax reform as a tool modenizatsii economy
Tax reform as a tool modenizatsii economyTax reform as a tool modenizatsii economy
Tax reform as a tool modenizatsii economyAnatoliy Amelin
 
Archer Software Presentation
Archer Software  PresentationArcher Software  Presentation
Archer Software PresentationHI-TECH_Org_Ua
 
Refactor Ukraine - Concept
Refactor Ukraine - ConceptRefactor Ukraine - Concept
Refactor Ukraine - ConceptRoman Khmil
 
The forecast for 2017. Challenges and Opportunities for Ukraine.
The forecast for 2017. Challenges and Opportunities for Ukraine.The forecast for 2017. Challenges and Opportunities for Ukraine.
The forecast for 2017. Challenges and Opportunities for Ukraine.Anatoliy Amelin
 
Outsourcing to Ukraine. Country Overview. Webinar 13.01.10.
Outsourcing to Ukraine. Country Overview. Webinar 13.01.10.Outsourcing to Ukraine. Country Overview. Webinar 13.01.10.
Outsourcing to Ukraine. Country Overview. Webinar 13.01.10.Victor_Maznyuk
 
Ukraine: an Emerging Software Outsourcing Destination
Ukraine: an Emerging Software Outsourcing DestinationUkraine: an Emerging Software Outsourcing Destination
Ukraine: an Emerging Software Outsourcing DestinationSoftheme
 
Infopulse presentation
Infopulse presentation Infopulse presentation
Infopulse presentation HI-TECH_Org_Ua
 
Ukraine in Doing Business 2017
Ukraine in Doing Business 2017Ukraine in Doing Business 2017
Ukraine in Doing Business 2017DIA_investment
 
"Прогноз рекламного рынка на 2017 год". Алексей Вирко, Havas Media Ukraine
"Прогноз рекламного рынка на 2017 год". Алексей Вирко, Havas Media Ukraine"Прогноз рекламного рынка на 2017 год". Алексей Вирко, Havas Media Ukraine
"Прогноз рекламного рынка на 2017 год". Алексей Вирко, Havas Media UkraineTVbusinessconference
 

Andere mochten auch (19)

Matrix of mutual interest of the citizens , government and business.
Matrix of mutual interest of the citizens , government and business.Matrix of mutual interest of the citizens , government and business.
Matrix of mutual interest of the citizens , government and business.
 
HWC LLC News - gradual easing of currency control in ukraine
HWC LLC News - gradual easing of currency control in ukraineHWC LLC News - gradual easing of currency control in ukraine
HWC LLC News - gradual easing of currency control in ukraine
 
Salesforce Development and Integration Services for Your Business
Salesforce Development and Integration Services for Your BusinessSalesforce Development and Integration Services for Your Business
Salesforce Development and Integration Services for Your Business
 
IT due diligence and software quality for fintech startups
IT due diligence and software quality for fintech startupsIT due diligence and software quality for fintech startups
IT due diligence and software quality for fintech startups
 
Mobile development services
Mobile development servicesMobile development services
Mobile development services
 
BDO Payroll Services
BDO Payroll ServicesBDO Payroll Services
BDO Payroll Services
 
Outsourcing to CEE. Country Overview. Ukraine
Outsourcing to CEE. Country Overview. UkraineOutsourcing to CEE. Country Overview. Ukraine
Outsourcing to CEE. Country Overview. Ukraine
 
Tax reform as a tool modenizatsii economy
Tax reform as a tool modenizatsii economyTax reform as a tool modenizatsii economy
Tax reform as a tool modenizatsii economy
 
Rx formations sdd-b2-b
Rx formations sdd-b2-bRx formations sdd-b2-b
Rx formations sdd-b2-b
 
Archer Software Presentation
Archer Software  PresentationArcher Software  Presentation
Archer Software Presentation
 
Ukrainian GDP 2030
Ukrainian GDP 2030Ukrainian GDP 2030
Ukrainian GDP 2030
 
Refactor Ukraine - Concept
Refactor Ukraine - ConceptRefactor Ukraine - Concept
Refactor Ukraine - Concept
 
Kyiv Maker Faire 2015_06_06
Kyiv Maker Faire 2015_06_06Kyiv Maker Faire 2015_06_06
Kyiv Maker Faire 2015_06_06
 
The forecast for 2017. Challenges and Opportunities for Ukraine.
The forecast for 2017. Challenges and Opportunities for Ukraine.The forecast for 2017. Challenges and Opportunities for Ukraine.
The forecast for 2017. Challenges and Opportunities for Ukraine.
 
Outsourcing to Ukraine. Country Overview. Webinar 13.01.10.
Outsourcing to Ukraine. Country Overview. Webinar 13.01.10.Outsourcing to Ukraine. Country Overview. Webinar 13.01.10.
Outsourcing to Ukraine. Country Overview. Webinar 13.01.10.
 
Ukraine: an Emerging Software Outsourcing Destination
Ukraine: an Emerging Software Outsourcing DestinationUkraine: an Emerging Software Outsourcing Destination
Ukraine: an Emerging Software Outsourcing Destination
 
Infopulse presentation
Infopulse presentation Infopulse presentation
Infopulse presentation
 
Ukraine in Doing Business 2017
Ukraine in Doing Business 2017Ukraine in Doing Business 2017
Ukraine in Doing Business 2017
 
"Прогноз рекламного рынка на 2017 год". Алексей Вирко, Havas Media Ukraine
"Прогноз рекламного рынка на 2017 год". Алексей Вирко, Havas Media Ukraine"Прогноз рекламного рынка на 2017 год". Алексей Вирко, Havas Media Ukraine
"Прогноз рекламного рынка на 2017 год". Алексей Вирко, Havas Media Ukraine
 

Ähnlich wie Tips to Comment the Code

Commenting Best Practices
Commenting Best PracticesCommenting Best Practices
Commenting Best Practicesmh_azad
 
Documenting code yapceu2016
Documenting code yapceu2016Documenting code yapceu2016
Documenting code yapceu2016Søren Lund
 
Code review best practice
Code review best practiceCode review best practice
Code review best practiceOren Digmi
 
Create first android app with MVVM Architecture
Create first android app with MVVM ArchitectureCreate first android app with MVVM Architecture
Create first android app with MVVM Architecturekhushbu thakker
 
Getting Started in Custom Programming for Talent Sourcing
Getting Started in Custom Programming for Talent SourcingGetting Started in Custom Programming for Talent Sourcing
Getting Started in Custom Programming for Talent SourcingGlenn Gutmacher
 
Software Development Standard Operating Procedure
Software Development Standard Operating Procedure Software Development Standard Operating Procedure
Software Development Standard Operating Procedure rupeshchanchal
 
Documenting Code - Patterns and Anti-patterns - NLPW 2016
Documenting Code - Patterns and Anti-patterns - NLPW 2016Documenting Code - Patterns and Anti-patterns - NLPW 2016
Documenting Code - Patterns and Anti-patterns - NLPW 2016Søren Lund
 
Prefer Code to Comments
Prefer Code to CommentsPrefer Code to Comments
Prefer Code to CommentsKevlin Henney
 
How to manage a big scale HTML/CSS project
How to manage a big scale HTML/CSS projectHow to manage a big scale HTML/CSS project
How to manage a big scale HTML/CSS projectRenoir Boulanger
 
Code Review Looking for a vulnerable code. Vlad Savitsky.
Code Review Looking for a vulnerable code. Vlad Savitsky.Code Review Looking for a vulnerable code. Vlad Savitsky.
Code Review Looking for a vulnerable code. Vlad Savitsky.DrupalCampDN
 
Code Review
Code ReviewCode Review
Code ReviewRavi Raj
 
Can't Handle My Scale v2
Can't Handle My Scale v2Can't Handle My Scale v2
Can't Handle My Scale v2Michele Titolo
 
How to Use CodePen - Learn with us!
How to Use CodePen - Learn with us!How to Use CodePen - Learn with us!
How to Use CodePen - Learn with us!Mars Devs
 
10 Code Anti-Patterns to Avoid in Software Development.pdf
10 Code Anti-Patterns to Avoid in Software Development.pdf10 Code Anti-Patterns to Avoid in Software Development.pdf
10 Code Anti-Patterns to Avoid in Software Development.pdfAhmed Salama
 
Stanislav Khorunzhyi, "Front-end it like a PRO"
Stanislav Khorunzhyi, "Front-end it like a PRO"Stanislav Khorunzhyi, "Front-end it like a PRO"
Stanislav Khorunzhyi, "Front-end it like a PRO"Sigma Software
 

Ähnlich wie Tips to Comment the Code (20)

Commenting Best Practices
Commenting Best PracticesCommenting Best Practices
Commenting Best Practices
 
Documenting code yapceu2016
Documenting code yapceu2016Documenting code yapceu2016
Documenting code yapceu2016
 
Code review best practice
Code review best practiceCode review best practice
Code review best practice
 
Create first android app with MVVM Architecture
Create first android app with MVVM ArchitectureCreate first android app with MVVM Architecture
Create first android app with MVVM Architecture
 
Getting Started in Custom Programming for Talent Sourcing
Getting Started in Custom Programming for Talent SourcingGetting Started in Custom Programming for Talent Sourcing
Getting Started in Custom Programming for Talent Sourcing
 
9-Coding.ppt
9-Coding.ppt9-Coding.ppt
9-Coding.ppt
 
Software Development Standard Operating Procedure
Software Development Standard Operating Procedure Software Development Standard Operating Procedure
Software Development Standard Operating Procedure
 
Documenting Code - Patterns and Anti-patterns - NLPW 2016
Documenting Code - Patterns and Anti-patterns - NLPW 2016Documenting Code - Patterns and Anti-patterns - NLPW 2016
Documenting Code - Patterns and Anti-patterns - NLPW 2016
 
Prefer Code to Comments
Prefer Code to CommentsPrefer Code to Comments
Prefer Code to Comments
 
6-Error Handling.pptx
6-Error Handling.pptx6-Error Handling.pptx
6-Error Handling.pptx
 
Switch case looping
Switch case loopingSwitch case looping
Switch case looping
 
How to manage a big scale HTML/CSS project
How to manage a big scale HTML/CSS projectHow to manage a big scale HTML/CSS project
How to manage a big scale HTML/CSS project
 
Code Review Looking for a vulnerable code. Vlad Savitsky.
Code Review Looking for a vulnerable code. Vlad Savitsky.Code Review Looking for a vulnerable code. Vlad Savitsky.
Code Review Looking for a vulnerable code. Vlad Savitsky.
 
Code Review
Code ReviewCode Review
Code Review
 
Can't Handle My Scale v2
Can't Handle My Scale v2Can't Handle My Scale v2
Can't Handle My Scale v2
 
Lecture 2
Lecture 2Lecture 2
Lecture 2
 
INTRODUCTIONS OF HTML
INTRODUCTIONS OF HTMLINTRODUCTIONS OF HTML
INTRODUCTIONS OF HTML
 
How to Use CodePen - Learn with us!
How to Use CodePen - Learn with us!How to Use CodePen - Learn with us!
How to Use CodePen - Learn with us!
 
10 Code Anti-Patterns to Avoid in Software Development.pdf
10 Code Anti-Patterns to Avoid in Software Development.pdf10 Code Anti-Patterns to Avoid in Software Development.pdf
10 Code Anti-Patterns to Avoid in Software Development.pdf
 
Stanislav Khorunzhyi, "Front-end it like a PRO"
Stanislav Khorunzhyi, "Front-end it like a PRO"Stanislav Khorunzhyi, "Front-end it like a PRO"
Stanislav Khorunzhyi, "Front-end it like a PRO"
 

Mehr von Softheme

10 Best Ways of Improving English Level
10 Best Ways of Improving English Level10 Best Ways of Improving English Level
10 Best Ways of Improving English LevelSoftheme
 
Why to Improve your English?
Why to Improve your English?Why to Improve your English?
Why to Improve your English?Softheme
 
Mobile application testing
Mobile application testingMobile application testing
Mobile application testingSoftheme
 
Acceptance criteria
Acceptance criteriaAcceptance criteria
Acceptance criteriaSoftheme
 
2011 European IT Outsourcing Predictions and Expectations
2011 European IT Outsourcing Predictions and Expectations2011 European IT Outsourcing Predictions and Expectations
2011 European IT Outsourcing Predictions and ExpectationsSoftheme
 
Training: Effective Business Letter Writing
Training: Effective Business Letter WritingTraining: Effective Business Letter Writing
Training: Effective Business Letter WritingSoftheme
 
Training: Making Small Talk
Training: Making Small TalkTraining: Making Small Talk
Training: Making Small TalkSoftheme
 
Software Outsourcing: Why, When, What
Software Outsourcing: Why, When, WhatSoftware Outsourcing: Why, When, What
Software Outsourcing: Why, When, WhatSoftheme
 
Software Outsourcing: Events Calendar
Software Outsourcing: Events CalendarSoftware Outsourcing: Events Calendar
Software Outsourcing: Events CalendarSoftheme
 
Software Outsourcing: Outsource Your Project or Build a Team
Software Outsourcing: Outsource Your Project or Build a TeamSoftware Outsourcing: Outsource Your Project or Build a Team
Software Outsourcing: Outsource Your Project or Build a TeamSoftheme
 
Software Testing: History, Trends, Perspectives - a Brief Overview
Software Testing: History, Trends, Perspectives - a Brief OverviewSoftware Testing: History, Trends, Perspectives - a Brief Overview
Software Testing: History, Trends, Perspectives - a Brief OverviewSoftheme
 
IT Professional Certification
IT Professional CertificationIT Professional Certification
IT Professional CertificationSoftheme
 
Software Outsourcing. Realities and Perspectives: Brief Overview
Software Outsourcing. Realities and Perspectives: Brief OverviewSoftware Outsourcing. Realities and Perspectives: Brief Overview
Software Outsourcing. Realities and Perspectives: Brief OverviewSoftheme
 
Software Development: Trends and Perspectives
Software Development: Trends and PerspectivesSoftware Development: Trends and Perspectives
Software Development: Trends and PerspectivesSoftheme
 
Software Outsourcing Practices
Software Outsourcing PracticesSoftware Outsourcing Practices
Software Outsourcing PracticesSoftheme
 
Softheme: Internet Applications Development Services
Softheme: Internet Applications Development ServicesSoftheme: Internet Applications Development Services
Softheme: Internet Applications Development ServicesSoftheme
 
Softheme: Software Outsourcing Practices
Softheme: Software Outsourcing PracticesSoftheme: Software Outsourcing Practices
Softheme: Software Outsourcing PracticesSoftheme
 
Dedicated Offshore Development Centers: a popular trend in outsourcing
Dedicated Offshore Development Centers: a popular trend in outsourcingDedicated Offshore Development Centers: a popular trend in outsourcing
Dedicated Offshore Development Centers: a popular trend in outsourcingSoftheme
 
Guide to Ukraine: helpful information for foreign visitors
Guide to Ukraine: helpful information for foreign visitorsGuide to Ukraine: helpful information for foreign visitors
Guide to Ukraine: helpful information for foreign visitorsSoftheme
 
Risks and Responsibilities in Software Outsourcing Projects
Risks and Responsibilities in Software Outsourcing ProjectsRisks and Responsibilities in Software Outsourcing Projects
Risks and Responsibilities in Software Outsourcing ProjectsSoftheme
 

Mehr von Softheme (20)

10 Best Ways of Improving English Level
10 Best Ways of Improving English Level10 Best Ways of Improving English Level
10 Best Ways of Improving English Level
 
Why to Improve your English?
Why to Improve your English?Why to Improve your English?
Why to Improve your English?
 
Mobile application testing
Mobile application testingMobile application testing
Mobile application testing
 
Acceptance criteria
Acceptance criteriaAcceptance criteria
Acceptance criteria
 
2011 European IT Outsourcing Predictions and Expectations
2011 European IT Outsourcing Predictions and Expectations2011 European IT Outsourcing Predictions and Expectations
2011 European IT Outsourcing Predictions and Expectations
 
Training: Effective Business Letter Writing
Training: Effective Business Letter WritingTraining: Effective Business Letter Writing
Training: Effective Business Letter Writing
 
Training: Making Small Talk
Training: Making Small TalkTraining: Making Small Talk
Training: Making Small Talk
 
Software Outsourcing: Why, When, What
Software Outsourcing: Why, When, WhatSoftware Outsourcing: Why, When, What
Software Outsourcing: Why, When, What
 
Software Outsourcing: Events Calendar
Software Outsourcing: Events CalendarSoftware Outsourcing: Events Calendar
Software Outsourcing: Events Calendar
 
Software Outsourcing: Outsource Your Project or Build a Team
Software Outsourcing: Outsource Your Project or Build a TeamSoftware Outsourcing: Outsource Your Project or Build a Team
Software Outsourcing: Outsource Your Project or Build a Team
 
Software Testing: History, Trends, Perspectives - a Brief Overview
Software Testing: History, Trends, Perspectives - a Brief OverviewSoftware Testing: History, Trends, Perspectives - a Brief Overview
Software Testing: History, Trends, Perspectives - a Brief Overview
 
IT Professional Certification
IT Professional CertificationIT Professional Certification
IT Professional Certification
 
Software Outsourcing. Realities and Perspectives: Brief Overview
Software Outsourcing. Realities and Perspectives: Brief OverviewSoftware Outsourcing. Realities and Perspectives: Brief Overview
Software Outsourcing. Realities and Perspectives: Brief Overview
 
Software Development: Trends and Perspectives
Software Development: Trends and PerspectivesSoftware Development: Trends and Perspectives
Software Development: Trends and Perspectives
 
Software Outsourcing Practices
Software Outsourcing PracticesSoftware Outsourcing Practices
Software Outsourcing Practices
 
Softheme: Internet Applications Development Services
Softheme: Internet Applications Development ServicesSoftheme: Internet Applications Development Services
Softheme: Internet Applications Development Services
 
Softheme: Software Outsourcing Practices
Softheme: Software Outsourcing PracticesSoftheme: Software Outsourcing Practices
Softheme: Software Outsourcing Practices
 
Dedicated Offshore Development Centers: a popular trend in outsourcing
Dedicated Offshore Development Centers: a popular trend in outsourcingDedicated Offshore Development Centers: a popular trend in outsourcing
Dedicated Offshore Development Centers: a popular trend in outsourcing
 
Guide to Ukraine: helpful information for foreign visitors
Guide to Ukraine: helpful information for foreign visitorsGuide to Ukraine: helpful information for foreign visitors
Guide to Ukraine: helpful information for foreign visitors
 
Risks and Responsibilities in Software Outsourcing Projects
Risks and Responsibilities in Software Outsourcing ProjectsRisks and Responsibilities in Software Outsourcing Projects
Risks and Responsibilities in Software Outsourcing Projects
 

Kürzlich hochgeladen

POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 

Kürzlich hochgeladen (20)

POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 

Tips to Comment the Code

  • 1. Tips to Comment the Code based on 13 Tips to Comment Your Code www.softheme.com
  • 2. 1. Comment each level Comment each code block, using a uniform approach for each level. For example: • For each class, include a brief description, author and date of last modification • For each method, include a description of its purpose, functions, parameters and results Adopting comment standards is important when working with a team. Of course, it is acceptable and even advisable to use comment conventions and tools (such as XML in C# or Javadoc for Java) to facilitate this task. www.softheme.com Outsourcing to Softheme™ Tips to Comment the Code
  • 3. 2. Use paragraph comments Break code blocks into multiple “paragraphs” that each perform a single task, then add a comment at the beginning of each block to instruct the reader on what is about to happen. // Check that all data records // are correct foreach (Record record in records) { if (rec.checkStatus()==Status.OK) { . . . } } // Now we begin to perform // transactions Context ctx = new ApplicationContext(); ctx.BeginTransaction(); . . . www.softheme.com Outsourcing to Softheme™ Tips to Comment the Code
  • 4. 3. Align comments in consecutive lines For multiple lines of code with trailing comments, align the comments so they will be easy to read. const MAX_ITEMS = 10; // maximum number of packets const MASK = 0x1F; // mask bit TCP Some developers use tabs to align comments, while others use spaces. Because tab stops can vary among editors and IDEs, the best approach is to use spaces. www.softheme.com Outsourcing to Softheme™ Tips to Comment the Code
  • 5. 4. Don´t insult the reader´s intelligence Avoid obvious comments such as: if (a == 5) // if a equals 5 counter = 0; // set the counter to zero This wastes your time writing needless comments and distracts the reader with details that can be easily deduced from the code. www.softheme.com Outsourcing to Softheme™ Tips to Comment the Code
  • 6. 5. Be polite Avoid rude comments like, “Notice the stupid user has entered a negative number,” or “This fixes the side effect produced by the pathetically inept implementation of the initial developer.” Such comments do not reflect well upon their author, and you never know who may read these comments in the future: your boss, a customer, or the pathetically inept developer you just insulted. www.softheme.com Outsourcing to Softheme™ Tips to Comment the Code
  • 7. 6. Get to the point Don’t write more in comments than is needed to convey the idea. Avoid ASCII art, jokes, poetry and hyperverbosity. In short, keep the comments simple and direct. www.softheme.com Outsourcing to Softheme™ Tips to Comment the Code
  • 8. 7. Use a consistent style Some people believe that comments should be written so that non-programmers can understand them. Others believe that comments should be directed at developers only. In any event, as stated in Successful Strategies for Commenting Code, what matters is that comments are consistent and always targeted to the same audience. Personally, I doubt many non-developers will be reading code, so comments should target other developers. www.softheme.com Outsourcing to Softheme™ Tips to Comment the Code
  • 9. 8. Use special tags for internal use When working on code as a team, adopt a consistent set of tags to communicate among programmers. For example, many teams use a “TODO:” tag to indicate a section of code that requires additional work: int Estimate(int x, int y) { // TODO: implement the calculations return 0; } Tag comments don’t explain code; rather they seek attention or deliver a message. But if you use this technique, remember to follow up and actually do what the message is asking. www.softheme.com Outsourcing to Softheme™ Tips to Comment the Code
  • 10. 9. Comment code while writing it Add comments while you write code and it’s fresh in your memory. If you leave comments until the end, it will take you twice as long, if you do it at all. “I have no time to comment,” “I’m in a hurry,” and “The project is delayed” are all simply excuses to avoid documenting your code. Some developers believe you should write comments before code as a way to plan out your ultimate solution. For example: public void ProcessOrder() { // Make sure the products are available // Check that the customer is valid // Send the order to the store // Generate bill } www.softheme.com Outsourcing to Softheme™ Tips to Comment the Code
  • 11. 10. Write comments as if they were for you (in fact, they are) When it comes to commenting code, think not only about the developers who will maintain your code in the future, but also think about yourself. In the words of the great Phil Haack: “As soon as a line of code is laid on the screen, you’re in maintenance mode on that piece of code.” As a result, we ourselves will be the first beneficiaries (or victims) of our good (or bad) comments. www.softheme.com Outsourcing to Softheme™ Tips to Comment the Code
  • 12. 11. Update comments when you update the code There is no point in commenting correctly on code if the comments are not changed with the code. Both code and comments must move in parallel, otherwise the comments will actually make life more difficult for developers who maintain your code. Pay special attention to refactoring tools that automatically update code but leave comments unchanged and hence obsolete in the same instant. www.softheme.com Outsourcing to Softheme™ Tips to Comment the Code
  • 13. 12. The golden rule of comments: readable code One of the basic principles for many developers: Let your code speak for itself. Although one suspects this movement is led by programmers who do not like to write comments, it is true that self-explanatory code can go a long way toward making code that’s easier to understand and can even render comments unnecessary. For example, the code in my Fluid Interfaces article shows how clear self-explanatory code can be: Calculator calc = new Calculator(); calc.Set(0); calc.Add(10); calc.Multiply(2); calc.Subtract(4); Console.WriteLine( "Result: {0}", calc.Get() ); In this example, comments are not needed and would likely violate tip #4. To facilitate readable code, you might consider using proper names (as described in the classic Ottinger’s Rules), ensure correct indentation, and adopt coding style guides. Failure to comply with this tip may result in comments that seem to apologize for bad code. www.softheme.com Outsourcing to Softheme™ Tips to Comment the Code
  • 14. 13. Share these tips with your colleagues Although tip #10 shows how we ourselves benefit immediately from good comments, these tips will benefit all developers, especially in the context of team working together. Therefore, feel free to share these commenting tips with your colleagues to create code that is easier to understand and maintain. www.softheme.com Outsourcing to Softheme™ Tips to Comment the Code
  • 15. Thank you! Questions? → info@softheme.com 2010 | Softheme Team | Kyiv, Ukraine | Software Outsourcing Solutions www.softheme.com » Outsourcing to Softheme™