SlideShare a Scribd company logo
1 of 41
Download to read offline
The road to green
code (with Sonar)
olivierlegoaer
The limits to (software) growth
How it started (2011) How it's going (2022)
The software eco-*
Software eco-design
eco-coding
eco-writing code
eco-programmiNg
green coding
“the most responsible software is
the one we don't build”
(S)Low-tech
Crossroads: make your choice
High-tech
+ eco-coding
First law of eco-coding
energy = (more code)2
e = mc2
Energy versus Performance
Computer/Device A B
Energy (in joules) 30 20
Time (in seconds) 10 20
Energy-efficient vs Run-time-efficient
Basic eco-coding incentives
💰 Money
The fewer resources SmartContracts* consume,
the lower the costs
⭐ Reputation
Bad reviews left on app stores can ruin your
business
*programs running within a BlockChain
French roadmap
JUILLET
Stratégie d’accélération
numérique
écoresponsable
Haut Comité pour le
Numérique
Écoresponsable
2023
Towards an eco-score
cyber-score (effective in oct. 2023) eco-score (open challenge)
source source
What if an eco-score?
Information
App stores display the eco-score to the
end-users (and include it in their ranking algorithm)
Regulation
(Sustainable) Cloud providers refuse the
deployment of program lower than D
A
D
eco-score
Think global & mobile-first
Ecological impact
Direct Indirect
10% (FR)
25%
90% (FR)
75%
Lifespan
(...more devices!!!)
Energy
consumption
eq. CO2, water, abiotic resources
🔋Li-ion battery wear
Loosely adapted from “iNUM : impacts environnementaux du numérique en France” (Jan. 2021)
On the need of eco-friendly apps
source: pCloud
source: Atos & Greenspector
Limited impacts
Green programming languages?
You don't always have a choice!
What about the runtime?
Mobile apps are programs, but rarely algorithms*
programming language: there is no silver bullet!
Rui Pereira et al. “Ranking Programming Languages
by Energy Efficiency”. Science of Computer
Programming, volume 205. Elsevier, 2021.
*mathematically provable object
Code smells: The good old classics
● Feature Envy
● God Class
● Blob Class
● Long Method
● Long Parameter List
...
Code smells: The new challengers
● Internal Setter
● Leaking Thread
● Leaking Inner Class
● Member Ignoring Method
● No Low Memory Resolver
● Hashmap Usage
● Init OnDraw
...
Greater impacts
Why Android-specific matters
Battery-killers are nestled at the platform-level, not the language-level
Luckily, every Android project has a well-defined, meaningful structure
More than just source code needs to be inspected:
Energy-greedy components
Hardware-related Component Avg. energy consumption (J)
display 139.784567875382
camera 84.1856142588254
microphone 81.8998646885348
gravity 71.3078291080087
magnetic_field 69.6877663025097
gyroscope 69.3777997221
accelerometer 67.9535327322522
cpu 66.6925401713931
room_database 66.0762976599094
speaker 65.6659164078901
gps 65.6478179873468
local_storage 64.5536233840085
ambientlight 63.0030057575923
networking 62.6477966616013
Back to the 2 scopes
Ecological impact
Direct Indirect
10% (FR)
25%
90% (FR)
75%
Lifespan
(...more devices!!!)
Energy
consumption
eq. CO2, water, abiotic resources
Scope #1: energy consumption
🪄 Avoid extraneous animation 💤 Avoid keep screen on
Scope #2: device lifespan
⚖ Fight software obesity ♻ Support aging devices
Green code
smells
Open source catalog
Licence CC BY-NC-ND
40+ code smells arranged in 8 categories,
crosscutting scope 1 & 2
Description based on Java (but Kotlin-ready)
Smells ≠ bugs ≠ refactorings
https://github.com/cnumr/best-practices-mobile
R&D taxonomy
Finding and Fixing
Energy inefficiencies
Developer-centric User-centric
Finding Fixing
Static Analysis Dynamic Analysis Instrumentation Refactoring Collaborative Standalone
Finding Fixing
User-driven Autonomous
Adapted from Marimuthu C. et al., “Energy Diagnosis of Android Applications: A Thematic Taxonomy and Survey”. ACM Comput. Surv. 53, 6, Article 117 (February 2021)
Here comes
ecoCode
Rationales
World-class solution to
improve code quality
No guidelines on how to
write energy-friendly apps
“Green as You Code” sounds good
Screenshots*
*self-hosted instance of the ecoCode SonarQube plugin
Bypassing limitations
Outdated On-going
Related works
Academic
EcoAndroid [Ribeiro et al., 2021]
E-Debitum [Maia et al., 2020]
xAL [Fatimaa et al., 2020]
aDoctor [Iannone et al., 2020]
Green Android Lint [Le Goaer, 2019]
Non-Academic
Green Software Insights [CAST, 2023]
EcoSonar [Accenture, 2022]
Greensight Sonar [Capgemini, 2022]
Ecoscan [Enedis, 2020]
Digital commons
Avoid reinventing the wheel every time
Open Source improves IT sustainability. ecoCode
cannot but be OSS
Build a community first (e.g., through
hackathons). The lines of code will follow
Many to watch, few to make
Green Code Initiative (GCI)
https://github.com/green-code-initiative
Food for thought
How clean|green code relate?
Clean Code
Green Code
Code Quality
Clean Code Green Code
or
is-a-kind-of
is-composed-of
Green software supply chain
Greening the software is noble, but greening the software supply chain too
Motto: Wherever there is code, there can be best practices for green
The “Everything-as-code” is a huge potential reservoir of green code smells :
infrastructure-as-code, configuration-as-code, platform-as-code, …
Static analysis: The great filter
Very few general rules of thumb withstand
the filter of static program analysis
(“use cache”, “not too much videos”, etc.)
Pro Tips: Must be rooted at syntax-level
Bottom-up approach is the preferred way
to find new rules/patterns/best-practices
source
source
The art of static detection
Challenges
🛑 Post-processing
🔎 Cross-scanning
🚩 False positive/negative
Opportunities
🎨 Taint analysis
🕸 Call Graph/Control Flow Graph
🧠 Machine-Learning
The plague of evaluation
Unlike 90’s code smells, green code smells are still in their infancy
Do not expect green code to do what clean code has barely done
Sometimes common sense is enough
Android is a fast-paced platform, which makes things even more challenging
Round-trip engineering
design-time run-time
ETSdiff
UX/UI
“Wow effect” is important to engage early-adopters
Our revamped UI was hardcoded. A new menu entry is recommended by Sonar
Tailoring the SonarQube UI to green-specific concepts would require diving deep
Developers can find green code burdensome. Gamification can help
The end.

More Related Content

Similar to Eco-friendly mobile app development best practices

IT Solution through IoT Development
IT Solution through IoT DevelopmentIT Solution through IoT Development
IT Solution through IoT DevelopmentAndri Yadi
 
European Green IT Webinar 2014 - Kaliterre (France)
European Green IT Webinar 2014 - Kaliterre (France)European Green IT Webinar 2014 - Kaliterre (France)
European Green IT Webinar 2014 - Kaliterre (France)GreenLabCenter
 
Using Natural Language Processing(NLP), Voice Recognition and Internet of Thi...
Using Natural Language Processing(NLP), Voice Recognition and Internet of Thi...Using Natural Language Processing(NLP), Voice Recognition and Internet of Thi...
Using Natural Language Processing(NLP), Voice Recognition and Internet of Thi...IRJET Journal
 
Slideshare startup contest
Slideshare startup contestSlideshare startup contest
Slideshare startup contestThierry LEBOUCQ
 
IRJET - Automatic Toll E-Tickting System for Transportation and Finding o...
IRJET -  	  Automatic Toll E-Tickting System for Transportation and Finding o...IRJET -  	  Automatic Toll E-Tickting System for Transportation and Finding o...
IRJET - Automatic Toll E-Tickting System for Transportation and Finding o...IRJET Journal
 
Automatic Car Parking
Automatic Car ParkingAutomatic Car Parking
Automatic Car ParkingIRJET Journal
 
IoT Programmable Block
IoT Programmable BlockIoT Programmable Block
IoT Programmable BlockAntor Ahmed
 
AIoT: Intelligence on Microcontroller
AIoT: Intelligence on MicrocontrollerAIoT: Intelligence on Microcontroller
AIoT: Intelligence on MicrocontrollerAndri Yadi
 
Technical Seminar ppt.pptx
Technical Seminar ppt.pptxTechnical Seminar ppt.pptx
Technical Seminar ppt.pptxKarunGowda3
 
GREEN PAUWARE - For a power-thrifty mobile app marketplace
GREEN PAUWARE - For a power-thrifty mobile app marketplaceGREEN PAUWARE - For a power-thrifty mobile app marketplace
GREEN PAUWARE - For a power-thrifty mobile app marketplaceOlivier Le Goaër
 
IEEE College of Technology MAES SE 2020 - Coding Fun
IEEE College of Technology MAES SE 2020 - Coding FunIEEE College of Technology MAES SE 2020 - Coding Fun
IEEE College of Technology MAES SE 2020 - Coding FunMadelenReyes
 
iotppt-170729110848.pdf
iotppt-170729110848.pdfiotppt-170729110848.pdf
iotppt-170729110848.pdfKishor Mhaske
 
IRJET- Efficient IoT based Smart Dustbin for Clean Environment
IRJET- Efficient IoT based Smart Dustbin for Clean EnvironmentIRJET- Efficient IoT based Smart Dustbin for Clean Environment
IRJET- Efficient IoT based Smart Dustbin for Clean EnvironmentIRJET Journal
 
IoT Based Garbage Monitoring System ppt
IoT Based Garbage Monitoring System pptIoT Based Garbage Monitoring System ppt
IoT Based Garbage Monitoring System pptRanjan Gupta
 
Exploring the Trend Toward the Edge | Eclipse IoT Day Santa Clara 2019
Exploring the Trend Toward the Edge | Eclipse IoT Day Santa Clara 2019Exploring the Trend Toward the Edge | Eclipse IoT Day Santa Clara 2019
Exploring the Trend Toward the Edge | Eclipse IoT Day Santa Clara 2019Eclipse IoT
 
Finding Resource Manipulation Bugs in Linux Code
Finding Resource Manipulation Bugs in Linux CodeFinding Resource Manipulation Bugs in Linux Code
Finding Resource Manipulation Bugs in Linux CodeAndrzej Wasowski
 

Similar to Eco-friendly mobile app development best practices (20)

IT Solution through IoT Development
IT Solution through IoT DevelopmentIT Solution through IoT Development
IT Solution through IoT Development
 
European Green IT Webinar 2014 - Kaliterre (France)
European Green IT Webinar 2014 - Kaliterre (France)European Green IT Webinar 2014 - Kaliterre (France)
European Green IT Webinar 2014 - Kaliterre (France)
 
Using Natural Language Processing(NLP), Voice Recognition and Internet of Thi...
Using Natural Language Processing(NLP), Voice Recognition and Internet of Thi...Using Natural Language Processing(NLP), Voice Recognition and Internet of Thi...
Using Natural Language Processing(NLP), Voice Recognition and Internet of Thi...
 
Slideshare startup contest
Slideshare startup contestSlideshare startup contest
Slideshare startup contest
 
IRJET - Automatic Toll E-Tickting System for Transportation and Finding o...
IRJET -  	  Automatic Toll E-Tickting System for Transportation and Finding o...IRJET -  	  Automatic Toll E-Tickting System for Transportation and Finding o...
IRJET - Automatic Toll E-Tickting System for Transportation and Finding o...
 
New resume 2years exp
New resume 2years expNew resume 2years exp
New resume 2years exp
 
Automatic Car Parking
Automatic Car ParkingAutomatic Car Parking
Automatic Car Parking
 
IoT Programmable Block
IoT Programmable BlockIoT Programmable Block
IoT Programmable Block
 
12682076.ppt
12682076.ppt12682076.ppt
12682076.ppt
 
AIoT: Intelligence on Microcontroller
AIoT: Intelligence on MicrocontrollerAIoT: Intelligence on Microcontroller
AIoT: Intelligence on Microcontroller
 
Technical Seminar ppt.pptx
Technical Seminar ppt.pptxTechnical Seminar ppt.pptx
Technical Seminar ppt.pptx
 
GREEN PAUWARE - For a power-thrifty mobile app marketplace
GREEN PAUWARE - For a power-thrifty mobile app marketplaceGREEN PAUWARE - For a power-thrifty mobile app marketplace
GREEN PAUWARE - For a power-thrifty mobile app marketplace
 
IEEE College of Technology MAES SE 2020 - Coding Fun
IEEE College of Technology MAES SE 2020 - Coding FunIEEE College of Technology MAES SE 2020 - Coding Fun
IEEE College of Technology MAES SE 2020 - Coding Fun
 
iotppt-170729110848.pdf
iotppt-170729110848.pdfiotppt-170729110848.pdf
iotppt-170729110848.pdf
 
IRJET- Efficient IoT based Smart Dustbin for Clean Environment
IRJET- Efficient IoT based Smart Dustbin for Clean EnvironmentIRJET- Efficient IoT based Smart Dustbin for Clean Environment
IRJET- Efficient IoT based Smart Dustbin for Clean Environment
 
IoT Based Garbage Monitoring System ppt
IoT Based Garbage Monitoring System pptIoT Based Garbage Monitoring System ppt
IoT Based Garbage Monitoring System ppt
 
Exploring the Trend Toward the Edge | Eclipse IoT Day Santa Clara 2019
Exploring the Trend Toward the Edge | Eclipse IoT Day Santa Clara 2019Exploring the Trend Toward the Edge | Eclipse IoT Day Santa Clara 2019
Exploring the Trend Toward the Edge | Eclipse IoT Day Santa Clara 2019
 
Finding Resource Manipulation Bugs in Linux Code
Finding Resource Manipulation Bugs in Linux CodeFinding Resource Manipulation Bugs in Linux Code
Finding Resource Manipulation Bugs in Linux Code
 
GreenDroid
GreenDroidGreenDroid
GreenDroid
 
GreenDroid
GreenDroidGreenDroid
GreenDroid
 

More from Olivier Le Goaër

Ecological Impact of Native vs. Cross-Platform Mobile Apps: a Preliminary Study
 Ecological Impact of Native vs. Cross-Platform Mobile Apps: a Preliminary Study Ecological Impact of Native vs. Cross-Platform Mobile Apps: a Preliminary Study
Ecological Impact of Native vs. Cross-Platform Mobile Apps: a Preliminary StudyOlivier Le Goaër
 
PowDroid: Energy Profiling of Android Applications (ASE 2021 [Workshop] SUSTA...
PowDroid: Energy Profiling of Android Applications (ASE 2021 [Workshop] SUSTA...PowDroid: Energy Profiling of Android Applications (ASE 2021 [Workshop] SUSTA...
PowDroid: Energy Profiling of Android Applications (ASE 2021 [Workshop] SUSTA...Olivier Le Goaër
 
Enforcing Green Code With Android Lint
Enforcing Green Code With Android LintEnforcing Green Code With Android Lint
Enforcing Green Code With Android LintOlivier Le Goaër
 
Les Web Services en 60 diapos chrono !
Les Web Services en 60 diapos chrono !Les Web Services en 60 diapos chrono !
Les Web Services en 60 diapos chrono !Olivier Le Goaër
 
Executable modeling & dynamic adaptation
Executable modeling & dynamic adaptationExecutable modeling & dynamic adaptation
Executable modeling & dynamic adaptationOlivier Le Goaër
 
Adaptation d'exécution de modèles : vers des iDSML adaptables
Adaptation d'exécution de modèles : vers des iDSML adaptablesAdaptation d'exécution de modèles : vers des iDSML adaptables
Adaptation d'exécution de modèles : vers des iDSML adaptablesOlivier Le Goaër
 
Android executable modeling: beyond android programming
Android executable modeling: beyond android programmingAndroid executable modeling: beyond android programming
Android executable modeling: beyond android programmingOlivier Le Goaër
 
Yet another DSL for cross platforms mobile development
Yet another DSL for cross platforms mobile developmentYet another DSL for cross platforms mobile development
Yet another DSL for cross platforms mobile developmentOlivier Le Goaër
 
Introduction à l'approche ADM de l'OMG
Introduction à l'approche ADM de l'OMGIntroduction à l'approche ADM de l'OMG
Introduction à l'approche ADM de l'OMGOlivier Le Goaër
 
Syntaxe concrète des DSL en IDM [avec Xtext]
Syntaxe concrète des DSL en IDM [avec Xtext]Syntaxe concrète des DSL en IDM [avec Xtext]
Syntaxe concrète des DSL en IDM [avec Xtext]Olivier Le Goaër
 

More from Olivier Le Goaër (14)

Ecological Impact of Native vs. Cross-Platform Mobile Apps: a Preliminary Study
 Ecological Impact of Native vs. Cross-Platform Mobile Apps: a Preliminary Study Ecological Impact of Native vs. Cross-Platform Mobile Apps: a Preliminary Study
Ecological Impact of Native vs. Cross-Platform Mobile Apps: a Preliminary Study
 
PowDroid: Energy Profiling of Android Applications (ASE 2021 [Workshop] SUSTA...
PowDroid: Energy Profiling of Android Applications (ASE 2021 [Workshop] SUSTA...PowDroid: Energy Profiling of Android Applications (ASE 2021 [Workshop] SUSTA...
PowDroid: Energy Profiling of Android Applications (ASE 2021 [Workshop] SUSTA...
 
Enforcing Green Code With Android Lint
Enforcing Green Code With Android LintEnforcing Green Code With Android Lint
Enforcing Green Code With Android Lint
 
Introduction au langage SQL
Introduction au langage SQLIntroduction au langage SQL
Introduction au langage SQL
 
Les Web Services en 60 diapos chrono !
Les Web Services en 60 diapos chrono !Les Web Services en 60 diapos chrono !
Les Web Services en 60 diapos chrono !
 
Executable modeling & dynamic adaptation
Executable modeling & dynamic adaptationExecutable modeling & dynamic adaptation
Executable modeling & dynamic adaptation
 
Cours JavaScript
Cours JavaScriptCours JavaScript
Cours JavaScript
 
Adaptation d'exécution de modèles : vers des iDSML adaptables
Adaptation d'exécution de modèles : vers des iDSML adaptablesAdaptation d'exécution de modèles : vers des iDSML adaptables
Adaptation d'exécution de modèles : vers des iDSML adaptables
 
Formation VBA Excel
Formation VBA ExcelFormation VBA Excel
Formation VBA Excel
 
Android executable modeling: beyond android programming
Android executable modeling: beyond android programmingAndroid executable modeling: beyond android programming
Android executable modeling: beyond android programming
 
Yet another DSL for cross platforms mobile development
Yet another DSL for cross platforms mobile developmentYet another DSL for cross platforms mobile development
Yet another DSL for cross platforms mobile development
 
Introduction à l'approche ADM de l'OMG
Introduction à l'approche ADM de l'OMGIntroduction à l'approche ADM de l'OMG
Introduction à l'approche ADM de l'OMG
 
Syntaxe concrète des DSL en IDM [avec Xtext]
Syntaxe concrète des DSL en IDM [avec Xtext]Syntaxe concrète des DSL en IDM [avec Xtext]
Syntaxe concrète des DSL en IDM [avec Xtext]
 
Programmation sous Android
Programmation sous AndroidProgrammation sous Android
Programmation sous Android
 

Recently uploaded

Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfCionsystems
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Clustering techniques data mining book ....
Clustering techniques data mining book ....Clustering techniques data mining book ....
Clustering techniques data mining book ....ShaimaaMohamedGalal
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendArshad QA
 

Recently uploaded (20)

Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdf
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Clustering techniques data mining book ....
Clustering techniques data mining book ....Clustering techniques data mining book ....
Clustering techniques data mining book ....
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and Backend
 

Eco-friendly mobile app development best practices

  • 1. The road to green code (with Sonar) olivierlegoaer
  • 2. The limits to (software) growth How it started (2011) How it's going (2022)
  • 3. The software eco-* Software eco-design eco-coding eco-writing code eco-programmiNg green coding “the most responsible software is the one we don't build”
  • 4. (S)Low-tech Crossroads: make your choice High-tech + eco-coding
  • 5. First law of eco-coding energy = (more code)2 e = mc2
  • 6. Energy versus Performance Computer/Device A B Energy (in joules) 30 20 Time (in seconds) 10 20 Energy-efficient vs Run-time-efficient
  • 7. Basic eco-coding incentives 💰 Money The fewer resources SmartContracts* consume, the lower the costs ⭐ Reputation Bad reviews left on app stores can ruin your business *programs running within a BlockChain
  • 9. Towards an eco-score cyber-score (effective in oct. 2023) eco-score (open challenge) source source
  • 10. What if an eco-score? Information App stores display the eco-score to the end-users (and include it in their ranking algorithm) Regulation (Sustainable) Cloud providers refuse the deployment of program lower than D A D eco-score
  • 11. Think global & mobile-first Ecological impact Direct Indirect 10% (FR) 25% 90% (FR) 75% Lifespan (...more devices!!!) Energy consumption eq. CO2, water, abiotic resources 🔋Li-ion battery wear Loosely adapted from “iNUM : impacts environnementaux du numérique en France” (Jan. 2021)
  • 12. On the need of eco-friendly apps source: pCloud source: Atos & Greenspector
  • 14. Green programming languages? You don't always have a choice! What about the runtime? Mobile apps are programs, but rarely algorithms* programming language: there is no silver bullet! Rui Pereira et al. “Ranking Programming Languages by Energy Efficiency”. Science of Computer Programming, volume 205. Elsevier, 2021. *mathematically provable object
  • 15. Code smells: The good old classics ● Feature Envy ● God Class ● Blob Class ● Long Method ● Long Parameter List ...
  • 16. Code smells: The new challengers ● Internal Setter ● Leaking Thread ● Leaking Inner Class ● Member Ignoring Method ● No Low Memory Resolver ● Hashmap Usage ● Init OnDraw ...
  • 18. Why Android-specific matters Battery-killers are nestled at the platform-level, not the language-level Luckily, every Android project has a well-defined, meaningful structure More than just source code needs to be inspected:
  • 19. Energy-greedy components Hardware-related Component Avg. energy consumption (J) display 139.784567875382 camera 84.1856142588254 microphone 81.8998646885348 gravity 71.3078291080087 magnetic_field 69.6877663025097 gyroscope 69.3777997221 accelerometer 67.9535327322522 cpu 66.6925401713931 room_database 66.0762976599094 speaker 65.6659164078901 gps 65.6478179873468 local_storage 64.5536233840085 ambientlight 63.0030057575923 networking 62.6477966616013
  • 20. Back to the 2 scopes Ecological impact Direct Indirect 10% (FR) 25% 90% (FR) 75% Lifespan (...more devices!!!) Energy consumption eq. CO2, water, abiotic resources
  • 21. Scope #1: energy consumption 🪄 Avoid extraneous animation 💤 Avoid keep screen on
  • 22. Scope #2: device lifespan ⚖ Fight software obesity ♻ Support aging devices
  • 24. Open source catalog Licence CC BY-NC-ND 40+ code smells arranged in 8 categories, crosscutting scope 1 & 2 Description based on Java (but Kotlin-ready) Smells ≠ bugs ≠ refactorings https://github.com/cnumr/best-practices-mobile
  • 25. R&D taxonomy Finding and Fixing Energy inefficiencies Developer-centric User-centric Finding Fixing Static Analysis Dynamic Analysis Instrumentation Refactoring Collaborative Standalone Finding Fixing User-driven Autonomous Adapted from Marimuthu C. et al., “Energy Diagnosis of Android Applications: A Thematic Taxonomy and Survey”. ACM Comput. Surv. 53, 6, Article 117 (February 2021)
  • 27. Rationales World-class solution to improve code quality No guidelines on how to write energy-friendly apps
  • 28. “Green as You Code” sounds good
  • 29. Screenshots* *self-hosted instance of the ecoCode SonarQube plugin
  • 31. Related works Academic EcoAndroid [Ribeiro et al., 2021] E-Debitum [Maia et al., 2020] xAL [Fatimaa et al., 2020] aDoctor [Iannone et al., 2020] Green Android Lint [Le Goaer, 2019] Non-Academic Green Software Insights [CAST, 2023] EcoSonar [Accenture, 2022] Greensight Sonar [Capgemini, 2022] Ecoscan [Enedis, 2020]
  • 32. Digital commons Avoid reinventing the wheel every time Open Source improves IT sustainability. ecoCode cannot but be OSS Build a community first (e.g., through hackathons). The lines of code will follow Many to watch, few to make Green Code Initiative (GCI) https://github.com/green-code-initiative
  • 34. How clean|green code relate? Clean Code Green Code Code Quality Clean Code Green Code or is-a-kind-of is-composed-of
  • 35. Green software supply chain Greening the software is noble, but greening the software supply chain too Motto: Wherever there is code, there can be best practices for green The “Everything-as-code” is a huge potential reservoir of green code smells : infrastructure-as-code, configuration-as-code, platform-as-code, …
  • 36. Static analysis: The great filter Very few general rules of thumb withstand the filter of static program analysis (“use cache”, “not too much videos”, etc.) Pro Tips: Must be rooted at syntax-level Bottom-up approach is the preferred way to find new rules/patterns/best-practices source source
  • 37. The art of static detection Challenges 🛑 Post-processing 🔎 Cross-scanning 🚩 False positive/negative Opportunities 🎨 Taint analysis 🕸 Call Graph/Control Flow Graph 🧠 Machine-Learning
  • 38. The plague of evaluation Unlike 90’s code smells, green code smells are still in their infancy Do not expect green code to do what clean code has barely done Sometimes common sense is enough Android is a fast-paced platform, which makes things even more challenging
  • 40. UX/UI “Wow effect” is important to engage early-adopters Our revamped UI was hardcoded. A new menu entry is recommended by Sonar Tailoring the SonarQube UI to green-specific concepts would require diving deep Developers can find green code burdensome. Gamification can help