SlideShare a Scribd company logo
1 of 24
Download to read offline
CODING TIPS
Don’t just code, code SMART
TIME AND SPACE COMPLEXITIES
 Know the space consuming of your code
 How often it is called
 Code time consuming
 AVOID:
 For Loops, Calling too much data, Primitive data structures.
LOW LEVEL LANGUAGE
 Understand the low level language of your coding high level language.
 In assembly:
 Function has more than 5 passed params is forced to store params in
memory rather than hash.
 Jne and je are faster than jle and jge
COMMON RULES
 The shorter, the merrier! << Lese byte codes
 Don’t repeat yourself
 Use libraries << Faster algorithms Except you know for sure the library
implementation is not optimized.
 Use different data structures.
 Don’t traverse one data block more than once in same function unless
necessary.
 Know your coding language capabilities.
 Don’t pass unneeded params. remember passing struct by value
 Don’t call function within a loop.
COMMON RULES
 Write your code gradually, from bottom to top; most frequent to use first <<
Exceptions are first lines of our services.
 Use the fastest shapes of statements: and operation rather than %, or
operation rather than comparting to None then setting.
 Reuse local params. Remember registers capacities.
 Does the compiler optimize operations: bit-shift of power 2 multiplication?
 Multithreading for heavy blocks.
 Extract repeated blocks into functions.
 BE SURE THAT YOUR CHANGE IN CODE IMPROVED THE PERFORMANCE
INDEED!
CODE EXAMPLES
IMPORTS
IMPORTS
OR Operator
IF CONDITION
IF CONDITION
IF CONDITION
REDUCE FUNCTION CALLS
RDUCE FUNCTION CALLS
RDUCE FUNCTION CALLS
LANG ATTRIBUTES
DICT USAGE
DICT USAGE
Frappe.get_all()
== Manipulation
TEST
TEST
TEST
TEST

More Related Content

Similar to Coding tips

FPL - Part 1 (Sem - I 2013 )
FPL - Part 1  (Sem - I  2013 ) FPL - Part 1  (Sem - I  2013 )
FPL - Part 1 (Sem - I 2013 )
Yogesh Deshpande
 
1. Coding Conventions [Part 1]
1. Coding Conventions [Part 1]1. Coding Conventions [Part 1]
1. Coding Conventions [Part 1]
Hardik Patel
 

Similar to Coding tips (20)

FPL - Part 1 (Sem - I 2013 )
FPL - Part 1  (Sem - I  2013 ) FPL - Part 1  (Sem - I  2013 )
FPL - Part 1 (Sem - I 2013 )
 
DAA Unit 1.pdf
DAA Unit 1.pdfDAA Unit 1.pdf
DAA Unit 1.pdf
 
Reading Notes : the practice of programming
Reading Notes : the practice of programmingReading Notes : the practice of programming
Reading Notes : the practice of programming
 
Lecture 8
Lecture 8Lecture 8
Lecture 8
 
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 conventions
Coding conventionsCoding conventions
Coding conventions
 
Kata Your Way to SW Craftsmanship
Kata Your Way to SW CraftsmanshipKata Your Way to SW Craftsmanship
Kata Your Way to SW Craftsmanship
 
Introduction to Functional Programming
Introduction to Functional ProgrammingIntroduction to Functional Programming
Introduction to Functional Programming
 
1. Coding Conventions [Part 1]
1. Coding Conventions [Part 1]1. Coding Conventions [Part 1]
1. Coding Conventions [Part 1]
 
PPT 19.pptx
PPT 19.pptxPPT 19.pptx
PPT 19.pptx
 
Clean code
Clean codeClean code
Clean code
 
Software development best practices & coding guidelines
Software development best practices & coding guidelinesSoftware development best practices & coding guidelines
Software development best practices & coding guidelines
 
Coding standard and coding guideline
Coding standard and coding guidelineCoding standard and coding guideline
Coding standard and coding guideline
 
EC8691-MPMC-PPT.pptx
EC8691-MPMC-PPT.pptxEC8691-MPMC-PPT.pptx
EC8691-MPMC-PPT.pptx
 
week 2 - INTRO TO PROGRAMMING.pptx
week 2 - INTRO TO PROGRAMMING.pptxweek 2 - INTRO TO PROGRAMMING.pptx
week 2 - INTRO TO PROGRAMMING.pptx
 
Classification of Programming Languages
Classification of Programming LanguagesClassification of Programming Languages
Classification of Programming Languages
 
N5 Code Efficiency
N5 Code EfficiencyN5 Code Efficiency
N5 Code Efficiency
 
Putting Compilers to Work
Putting Compilers to WorkPutting Compilers to Work
Putting Compilers to Work
 
Clean Code - Part 2
Clean Code - Part 2Clean Code - Part 2
Clean Code - Part 2
 

Recently uploaded

Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills KuwaitKuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
jaanualu31
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power Play
Epec Engineered Technologies
 
Hospital management system project report.pdf
Hospital management system project report.pdfHospital management system project report.pdf
Hospital management system project report.pdf
Kamal Acharya
 
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
HenryBriggs2
 
Introduction to Robotics in Mechanical Engineering.pptx
Introduction to Robotics in Mechanical Engineering.pptxIntroduction to Robotics in Mechanical Engineering.pptx
Introduction to Robotics in Mechanical Engineering.pptx
hublikarsn
 
Digital Communication Essentials: DPCM, DM, and ADM .pptx
Digital Communication Essentials: DPCM, DM, and ADM .pptxDigital Communication Essentials: DPCM, DM, and ADM .pptx
Digital Communication Essentials: DPCM, DM, and ADM .pptx
pritamlangde
 
INTERRUPT CONTROLLER 8259 MICROPROCESSOR
INTERRUPT CONTROLLER 8259 MICROPROCESSORINTERRUPT CONTROLLER 8259 MICROPROCESSOR
INTERRUPT CONTROLLER 8259 MICROPROCESSOR
TanishkaHira1
 

Recently uploaded (20)

Ground Improvement Technique: Earth Reinforcement
Ground Improvement Technique: Earth ReinforcementGround Improvement Technique: Earth Reinforcement
Ground Improvement Technique: Earth Reinforcement
 
Signal Processing and Linear System Analysis
Signal Processing and Linear System AnalysisSignal Processing and Linear System Analysis
Signal Processing and Linear System Analysis
 
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills KuwaitKuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
 
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
 
Unsatisfied Bhabhi ℂall Girls Ahmedabad Book Esha 6378878445 Top Class ℂall G...
Unsatisfied Bhabhi ℂall Girls Ahmedabad Book Esha 6378878445 Top Class ℂall G...Unsatisfied Bhabhi ℂall Girls Ahmedabad Book Esha 6378878445 Top Class ℂall G...
Unsatisfied Bhabhi ℂall Girls Ahmedabad Book Esha 6378878445 Top Class ℂall G...
 
Fundamentals of Internet of Things (IoT) Part-2
Fundamentals of Internet of Things (IoT) Part-2Fundamentals of Internet of Things (IoT) Part-2
Fundamentals of Internet of Things (IoT) Part-2
 
Hostel management system project report..pdf
Hostel management system project report..pdfHostel management system project report..pdf
Hostel management system project report..pdf
 
Worksharing and 3D Modeling with Revit.pptx
Worksharing and 3D Modeling with Revit.pptxWorksharing and 3D Modeling with Revit.pptx
Worksharing and 3D Modeling with Revit.pptx
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power Play
 
Hospital management system project report.pdf
Hospital management system project report.pdfHospital management system project report.pdf
Hospital management system project report.pdf
 
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
 
Introduction to Robotics in Mechanical Engineering.pptx
Introduction to Robotics in Mechanical Engineering.pptxIntroduction to Robotics in Mechanical Engineering.pptx
Introduction to Robotics in Mechanical Engineering.pptx
 
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptxS1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
 
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
COST-EFFETIVE  and Energy Efficient BUILDINGS ptxCOST-EFFETIVE  and Energy Efficient BUILDINGS ptx
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
 
litvinenko_Henry_Intrusion_Hong-Kong_2024.pdf
litvinenko_Henry_Intrusion_Hong-Kong_2024.pdflitvinenko_Henry_Intrusion_Hong-Kong_2024.pdf
litvinenko_Henry_Intrusion_Hong-Kong_2024.pdf
 
Digital Communication Essentials: DPCM, DM, and ADM .pptx
Digital Communication Essentials: DPCM, DM, and ADM .pptxDigital Communication Essentials: DPCM, DM, and ADM .pptx
Digital Communication Essentials: DPCM, DM, and ADM .pptx
 
Max. shear stress theory-Maximum Shear Stress Theory ​ Maximum Distortional ...
Max. shear stress theory-Maximum Shear Stress Theory ​  Maximum Distortional ...Max. shear stress theory-Maximum Shear Stress Theory ​  Maximum Distortional ...
Max. shear stress theory-Maximum Shear Stress Theory ​ Maximum Distortional ...
 
Danikor Product Catalog- Screw Feeder.pdf
Danikor Product Catalog- Screw Feeder.pdfDanikor Product Catalog- Screw Feeder.pdf
Danikor Product Catalog- Screw Feeder.pdf
 
Computer Networks Basics of Network Devices
Computer Networks  Basics of Network DevicesComputer Networks  Basics of Network Devices
Computer Networks Basics of Network Devices
 
INTERRUPT CONTROLLER 8259 MICROPROCESSOR
INTERRUPT CONTROLLER 8259 MICROPROCESSORINTERRUPT CONTROLLER 8259 MICROPROCESSOR
INTERRUPT CONTROLLER 8259 MICROPROCESSOR
 

Coding tips

  • 1. CODING TIPS Don’t just code, code SMART
  • 2. TIME AND SPACE COMPLEXITIES  Know the space consuming of your code  How often it is called  Code time consuming  AVOID:  For Loops, Calling too much data, Primitive data structures.
  • 3. LOW LEVEL LANGUAGE  Understand the low level language of your coding high level language.  In assembly:  Function has more than 5 passed params is forced to store params in memory rather than hash.  Jne and je are faster than jle and jge
  • 4. COMMON RULES  The shorter, the merrier! << Lese byte codes  Don’t repeat yourself  Use libraries << Faster algorithms Except you know for sure the library implementation is not optimized.  Use different data structures.  Don’t traverse one data block more than once in same function unless necessary.  Know your coding language capabilities.  Don’t pass unneeded params. remember passing struct by value  Don’t call function within a loop.
  • 5. COMMON RULES  Write your code gradually, from bottom to top; most frequent to use first << Exceptions are first lines of our services.  Use the fastest shapes of statements: and operation rather than %, or operation rather than comparting to None then setting.  Reuse local params. Remember registers capacities.  Does the compiler optimize operations: bit-shift of power 2 multiplication?  Multithreading for heavy blocks.  Extract repeated blocks into functions.  BE SURE THAT YOUR CHANGE IN CODE IMPROVED THE PERFORMANCE INDEED!
  • 21. TEST
  • 22. TEST
  • 23. TEST
  • 24. TEST