SlideShare une entreprise Scribd logo
1  sur  42
Télécharger pour lire hors ligne
Clean Code on Android!
DroidCon Dubai
Danny Preussler
Groupon

The	
  Living	
  Room,	
  Colin	
  and	
  Sarah	
  Northway,	
  CC	
  by	
  2.0	
  
h<ps://www.flickr.com/photos/apes_abroad/1479254938	
  
Groupon is the global 

leader in local commerce,
making it easy for people around the world to search !
and discover great businesses at unbeatable prices.

Source: Internal data,, March 2014
WORLDWIDE!
260M+ subscribers 53.9M active customers 500+ markets 900M+ deals sold
2
$5B+ in annual billings 12,000+ global employees
Leading the way in mobile commerce
Our mobile app is available in 43 countries. 
Groupon’s vibrant mobile marketplace connects!
consumers with their local economy
3	
  Sources: Internal Data; iTunes ranking for US stores available here - https://itunes.apple.com/WebObjects/
MZStore.woa/wa/viewFeature?id=500873243&mt=8&v0=www-itunes25Bcountdown-appstore 
Nearly 110 million people worldwide have
downloaded our mobile app at the end of Q4 2014.
One of the 25 most downloaded free
apps of all time
More than 50% of our Global transactions were
completed on a mobile device by the end of Q4
2014
Groupon Berlin
Groupon Merchant App
Obsessed with beautiful code
SOLID
FOUNDATIONFlughafen Berlin-Brandenburg, Blick in die Abflughalle by Muns CC BY 3.0
http://commons.wikimedia.org/wiki/File:120513-BER-innen.JPG
violating
the most basics
principles
of Software Engineering!
flickr.com/photos/cobblucas/4831501753,	
  Stop	
  by	
  Lucas	
  Cobb,	
  CC	
  by	
  2.0	
  
Separation of concerns (1974)!
•  Modularize, Encapsulate, Layer!
Example: Don‘t do HTTP request in Activities/Fragments!
flickr.com/photos/ionics/6337522871,	
  Black	
  Sheep	
  Meets	
  White	
  Sheep	
  by	
  Leon	
  Riskin,	
  CC	
  by	
  2.0	
  
Don‘t !
repeat !
ourself!!
Boris	
  Bikes	
  DLR,	
  Les	
  Haines,	
  CC	
  by	
  2.0	
  
flickr.com/photos/leshaines123/8370292862	
  
ViolaTons	
  of	
  DRY	
  are	
  typically	
  
referred	
  to	
  as	
  WET	
  soluTons,	
  
which	
  is	
  commonly	
  taken	
  to	
  
stand	
  for	
  either	
  "write	
  everything	
  
twice"	
  or	
  "we	
  enjoy	
  typing”	
  	
  
(h<p://en.wikipedia.org/wiki/Don't_repeat_yourself)	
  
Android Firewall by Uncalno, CC BY 2.0
flickr.com/photos/uncalno/8538679708
Clean Code!!
The	
  Living	
  Room,	
  Colin	
  and	
  Sarah	
  Northway,	
  CC	
  by	
  2.0	
  
h<ps://www.flickr.com/photos/apes_abroad/1479254938	
  
Clean	
  Code	
  	
  
by	
  	
  
Robert	
  C.	
  Mar0n	
  
Robert C. Martin – Clean Code!
The	
  Living	
  Room,	
  Colin	
  and	
  Sarah	
  Northway,	
  CC	
  by	
  2.0	
  
h<ps://www.flickr.com/photos/apes_abroad/1479254938	
  
Uncle	
  Bob	
  says:	
  
(Keep	
  it)	
  small!	
  
Robert C. Martin – Clean Code!
The	
  Living	
  Room,	
  Colin	
  and	
  Sarah	
  Northway,	
  CC	
  by	
  2.0	
  
h<ps://www.flickr.com/photos/apes_abroad/1479254938	
  
Uncle	
  Bob	
  says:	
  
Do	
  One	
  Thing!	
  
Robert C. Martin – Clean Code!
The	
  Living	
  Room,	
  Colin	
  and	
  Sarah	
  Northway,	
  CC	
  by	
  2.0	
  
h<ps://www.flickr.com/photos/apes_abroad/1479254938	
  
Uncle	
  Bob	
  says:	
  
One	
  Level	
  of	
  Abstrac0on	
  	
  
per	
  Func0on!	
  
Robert C. Martin – Clean Code!
The	
  Living	
  Room,	
  Colin	
  and	
  Sarah	
  Northway,	
  CC	
  by	
  2.0	
  
h<ps://www.flickr.com/photos/apes_abroad/1479254938	
  
Uncle	
  Bob	
  says:	
  
Reading	
  Code	
  from	
  Top	
  	
  
to	
  BoHom	
  
Robert C. Martin – Clean Code!
The	
  Living	
  Room,	
  Colin	
  and	
  Sarah	
  Northway,	
  CC	
  by	
  2.0	
  
h<ps://www.flickr.com/photos/apes_abroad/1479254938	
  
Uncle	
  Bob	
  says:	
  
Comments	
  Do	
  Not	
  Make	
  Up	
  	
  
for	
  Bad	
  Code	
  
Robert C. Martin – Clean Code!
The	
  Living	
  Room,	
  Colin	
  and	
  Sarah	
  Northway,	
  CC	
  by	
  2.0	
  
h<ps://www.flickr.com/photos/apes_abroad/1479254938	
  
Uncle	
  Bob	
  says:	
  
Avoid	
  switch	
  
	
  It’s	
  [..]	
  hard	
  to	
  make	
  a	
  switch	
  statement	
  that	
  does	
  one	
  thing.	
  	
  
By	
  their	
  nature,	
  switch	
  statements	
  always	
  do	
  N	
  things.	
  
Much more...!
The	
  Living	
  Room,	
  Colin	
  and	
  Sarah	
  Northway,	
  CC	
  by	
  2.0	
  
h<ps://www.flickr.com/photos/apes_abroad/1479254938	
  
A	
  must	
  
Read!	
  
Codesmells....!
Sintra,	
  Portugal,	
  The	
  smell	
  of	
  the	
  portuguese	
  wine,	
  CC	
  by	
  
Si_ng	
  in	
  a	
  Tree,	
  Big	
  Bend	
  NaTonal	
  Park	
  by	
  Adam	
  Baker,	
  CC	
  by	
  2.0,	
  flickr.com/photos/atbaker/5474766579	
  
Watch out for !
Primitive
Obsession!
Ban null !
from !
your code!!
nothing	
  is	
  nothing	
  by	
  darwin	
  Bell,	
  CC	
  by	
  2.0,	
  flickr.com/photos/darwinbell/272818496	
  
private MyParcelable myParceable;
...
Bundle bundle = getArguments();
if (bundle != null) {
myParceable = bundle.getParcelable("ARGUMENT");
}
....
if (myParcaeable != null) {
...
}
...
if (myParcaeable != null) {
...
}
Don‘t:!
Red	
  Stop	
  Bu<on	
  by	
  Ben	
  K	
  Adams,	
  CC	
  by	
  2.0,	
  flickr.com/photos/schtumple/5475697999	
  
Cleaner	
  by	
  atomicjeep,	
  CC	
  by	
  2.0,	
  flickr.com/photos/atomicjeep/144719649	
  
Do: Inject Dependencies!
private MyParcelable myParceable = MyParceable.NONE;
...
Bundle bundle = getArguments();
if (bundle != null &&
bundle.hasParceable(„ARGUMENT“) {
myParceable = bundle.getParcelable("ARGUMENT");
}
....
if (myParcaeable != null) {
...
}
...
if (myParcaeable != null) {
...
}
The power of
Dependency
Injection!
•  Don‘t	
  create	
  dependencies	
  
•  Invert	
  Control!	
  
	
  
•  Inject	
  them!	
  
I	
  love	
  the	
  Light	
  &	
  I	
  dig	
  the	
  Sun	
  by	
  fady	
  habib,	
  CC	
  by	
  2.0,	
  flickr.com/photos/unTtlism/2609684221
public class WetFragment extends Fragment {
MyController controller;
...
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
controller =
new MyController(activity.getApplicationContext());
Don‘t:!
Red	
  Stop	
  Bu<on	
  by	
  Ben	
  K	
  Adams,	
  CC	
  by	
  2.0,	
  flickr.com/photos/schtumple/5475697999	
  
Cleaner	
  by	
  atomicjeep,	
  CC	
  by	
  2.0,	
  flickr.com/photos/atomicjeep/144719649	
  
public class DryFragment extends Fragment {
@Inject MyController controller;
...
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
controller =
new MyController(activity.getApplicationContext());
Do: Inject Dependencies!
public class WetFragment extends Fragment {
EditText myEditField;
@Override
public View onCreateView(LayoutInflater inflater, ...) {
View view = inflater.inflate(......
myEditField = (EditText)view.findViewById(R.id.edit1);
...
Don‘t:!
Red	
  Stop	
  Bu<on	
  by	
  Ben	
  K	
  Adams,	
  CC	
  by	
  2.0,	
  flickr.com/photos/schtumple/5475697999	
  
Cleaner	
  by	
  atomicjeep,	
  CC	
  by	
  2.0,	
  flickr.com/photos/atomicjeep/144719649	
  
public class DryFragment extends Fragment {
@Inject(R.id.edit1) EditText myEditField;
@Override
public View onCreateView(LayoutInflater inflater, ...) {
View view = inflater.inflate(......
myEditField = (EditText)view.findViewById(R.id.edit1);
...
Do: Inject views!
public class WetFragment extends Fragment {
private MyParcelable myParceable;
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
Bundle bundle = getArguments();
if (bundle != null) {
myParceable = bundle.getParcelable("ARGUMENT");
if (myParceable == null) {
myParceable = MyParcelable.NONE;
}
}
}
Don‘t:!
Red	
  Stop	
  Bu<on	
  by	
  Ben	
  K	
  Adams,	
  CC	
  by	
  2.0,	
  flickr.com/photos/schtumple/5475697999	
  
Cleaner	
  by	
  atomicjeep,	
  CC	
  by	
  2.0,	
  flickr.com/photos/atomicjeep/144719649	
  
public class DryFragment extends Fragment {
@Inject(„ARGUMENT“) MyParcelable = myParceable.NONE;
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
Bundle bundle = getArguments();
if (bundle != null) {
myParceable = bundle.getParcelable("ARGUMENT");
if (myParceable == null) {
myParceable = MyParcelable.NONE;
}
}
}
Do: Inject arguments / extras!
public class WetFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ...) {
return inflater.inflate(
R.layout.main_layout, container, false);
}
Don‘t:!
Red	
  Stop	
  Bu<on	
  by	
  Ben	
  K	
  Adams,	
  CC	
  by	
  2.0,	
  flickr.com/photos/schtumple/5475697999	
  
Cleaner	
  by	
  atomicjeep,	
  CC	
  by	
  2.0,	
  flickr.com/photos/atomicjeep/144719649	
  
@InjectLayout(R.layout.main_layout)
public class DryFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ...) {
return inflater.inflate(
R.layout.main_layout, container, false);
}
Do: Inject layout!
Cleaner	
  by	
  atomicjeep,	
  CC	
  by	
  2.0,	
  flickr.com/photos/atomicjeep/144719649	
  
@InjectLayout(R.layout.main_layout)
public class DryFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ...) {
return inflater.inflate(
R.layout.main_layout, container, false);
}
Do: auto (find) layout!
Simply have dry_fragment.xml or dry.xml	
  
©	
  Biblioarchive,	
  CC	
  by	
  2.0,	
  www.flickr.com/photos/lac-­‐bac/4679195538	
  
•  Dagger 

github.com/square/dagger
•  Butterknife 

github.com/JakeWharton/butterknife
•  InjectExtra 

github.com/stephanenicolas/injectextra
•  Autolayout 

github.com/dpreussler/android-autolayout
How to Do:!
©	
  Biblioarchive,	
  CC	
  by	
  2.0,	
  www.flickr.com/photos/lac-­‐bac/4679195538	
  
•  RoboGuice 

github.com/roboguice/roboguice
•  Android-Dart 

github.com/f2prateek/android-dart
•  Spring Android 

github.com/spring-projects/spring-android
•  Transfuse 

github.com/johncarl81/transfuse
•  Android Annotations 

github.com/excilys/androidannotations
Alternative or more Do‘s!
Complicated,	
  Rohit	
  Ma<oo,	
  CC	
  by	
  2.0,	
  flickr.com/photos/mar00ned/229903286	
  
@Override
public void onResume() {
super.onResume();
getFragmentManager()
.beginTransaction()
.add(R.id.fragments, new WetFragment())
. commitAllowingStateLoss();
}
Dont: write untestable code:!
test	
  (c)	
  DaveBleasdale,	
  CC	
  by	
  2.0,	
  www.flickr.com/photos/sidelong/246816211	
  
Do: write testable code:!
@Inject MyTransactionUtil transactions;
@Override
public void onResume() {
super.onResume();
transactions.addAllowingStateLoss(
R.id.fragments, new WetFragment());
}
• Split your Activities
• Alternative Mortar github.com/square/mortar

Do: use the Power of Fragments!
the	
  icon	
  (CC)	
  by	
  MarTn	
  Fisch,	
  CC	
  by	
  2.0,	
  
	
  flickr.com/photos/marfis75/7164769781	
  
h<ps://wiki.jenkins-­‐ci.org/display/JENKINS/Dot+Jenkins+Ci+Dot+Org	
  
Continuous Code Checks...!
Got legacy code?!
Old	
  by	
  Moyan	
  Brenn,	
  flickr.com/photos/aigle_dore/5677012469	
  
Clean = feel good!!
The	
  Living	
  Room,	
  Colin	
  and	
  Sarah	
  Nor
h<ps://www.flickr.com/photos/apes_abr
THANK YOU
Danny Preussler

GROUPON 

Berlin


dpreussler@groupon.com	
  	
  
github.com/groupon
engineering.groupon.com
Michael	
  Burton,	
  Roboguice	
  
Carlos	
  Sessa,	
  50	
  Android	
  hacks	
  
David	
  van	
  der	
  Bokke,	
  RoboRemote	
  
David	
  Willson,	
  Odo	
  
….	
  
Stephane	
  Nicolas,	
  RoboSpice	
  
ParTal	
  Supermen,	
  juliegomoll,	
  CC	
  by	
  2.0,	
  flickr.com/photos/juliegomoll/1352843346	
  

Contenu connexe

En vedette

ANDROID TRAINING IN CHENNAI
ANDROID TRAINING IN CHENNAIANDROID TRAINING IN CHENNAI
ANDROID TRAINING IN CHENNAIJahan Murugassan
 
Android notifications. testing guideline
Android notifications. testing guidelineAndroid notifications. testing guideline
Android notifications. testing guidelineTechMagic
 
Keep calm and write reusable code in Android
Keep calm and write reusable code in AndroidKeep calm and write reusable code in Android
Keep calm and write reusable code in AndroidJuan Camilo Sacanamboy
 
The Big Easy: Native Mobile App Development with Appcelerator Titanium and Ja...
The Big Easy: Native Mobile App Development with Appcelerator Titanium and Ja...The Big Easy: Native Mobile App Development with Appcelerator Titanium and Ja...
The Big Easy: Native Mobile App Development with Appcelerator Titanium and Ja...Adam Paxton
 
Android DevConference - Android Clean Architecture
Android DevConference - Android Clean ArchitectureAndroid DevConference - Android Clean Architecture
Android DevConference - Android Clean ArchitectureiMasters
 
Android technology sunny
Android technology sunnyAndroid technology sunny
Android technology sunnySunny Yadav
 
Beginner android
Beginner androidBeginner android
Beginner androidSmriti Das
 
Android Performance Best Practices
Android Performance Best Practices Android Performance Best Practices
Android Performance Best Practices Amgad Muhammad
 
Architectural Design Pattern: Android
Architectural Design Pattern: AndroidArchitectural Design Pattern: Android
Architectural Design Pattern: AndroidJitendra Kumar
 
Kotlin 初體驗
Kotlin 初體驗Kotlin 初體驗
Kotlin 初體驗哲偉 楊
 
Android Things - Solid Foundations
Android Things - Solid FoundationsAndroid Things - Solid Foundations
Android Things - Solid FoundationsPaul Blundell
 
Modern Android app library stack
Modern Android app library stackModern Android app library stack
Modern Android app library stackTomáš Kypta
 

En vedette (13)

ANDROID TRAINING IN CHENNAI
ANDROID TRAINING IN CHENNAIANDROID TRAINING IN CHENNAI
ANDROID TRAINING IN CHENNAI
 
Android notifications. testing guideline
Android notifications. testing guidelineAndroid notifications. testing guideline
Android notifications. testing guideline
 
Device fragmentation vs clean code
Device fragmentation vs clean codeDevice fragmentation vs clean code
Device fragmentation vs clean code
 
Keep calm and write reusable code in Android
Keep calm and write reusable code in AndroidKeep calm and write reusable code in Android
Keep calm and write reusable code in Android
 
The Big Easy: Native Mobile App Development with Appcelerator Titanium and Ja...
The Big Easy: Native Mobile App Development with Appcelerator Titanium and Ja...The Big Easy: Native Mobile App Development with Appcelerator Titanium and Ja...
The Big Easy: Native Mobile App Development with Appcelerator Titanium and Ja...
 
Android DevConference - Android Clean Architecture
Android DevConference - Android Clean ArchitectureAndroid DevConference - Android Clean Architecture
Android DevConference - Android Clean Architecture
 
Android technology sunny
Android technology sunnyAndroid technology sunny
Android technology sunny
 
Beginner android
Beginner androidBeginner android
Beginner android
 
Android Performance Best Practices
Android Performance Best Practices Android Performance Best Practices
Android Performance Best Practices
 
Architectural Design Pattern: Android
Architectural Design Pattern: AndroidArchitectural Design Pattern: Android
Architectural Design Pattern: Android
 
Kotlin 初體驗
Kotlin 初體驗Kotlin 初體驗
Kotlin 初體驗
 
Android Things - Solid Foundations
Android Things - Solid FoundationsAndroid Things - Solid Foundations
Android Things - Solid Foundations
 
Modern Android app library stack
Modern Android app library stackModern Android app library stack
Modern Android app library stack
 

Similaire à Clean code on Android (Droidcon Dubai 2015)

Arrow SI's December 2016 Instant Insight Webinar
Arrow SI's December 2016 Instant Insight WebinarArrow SI's December 2016 Instant Insight Webinar
Arrow SI's December 2016 Instant Insight WebinarArrow Systems Integration
 
Deploying a Pylons app to Google App Engine
Deploying a Pylons app to Google App EngineDeploying a Pylons app to Google App Engine
Deploying a Pylons app to Google App EngineJazkarta, Inc.
 
Alex Fernández - Has anyone else seen your code? - Codemotion Berlin 2018
Alex Fernández - Has anyone else seen your code? - Codemotion Berlin 2018Alex Fernández - Has anyone else seen your code? - Codemotion Berlin 2018
Alex Fernández - Has anyone else seen your code? - Codemotion Berlin 2018Codemotion
 
Creating Responsive Experiences
Creating Responsive ExperiencesCreating Responsive Experiences
Creating Responsive ExperiencesTim Kadlec
 
Getting Started with iBeacons (Designers of Things 2014)
Getting Started with iBeacons (Designers of Things 2014)Getting Started with iBeacons (Designers of Things 2014)
Getting Started with iBeacons (Designers of Things 2014)Daniel Luxemburg
 
How I hacked the Google Daydream controller
How I hacked the Google Daydream controllerHow I hacked the Google Daydream controller
How I hacked the Google Daydream controllerMatteo Pisani
 
WDE08 BULLETPROOF A to Z
WDE08 BULLETPROOF A to ZWDE08 BULLETPROOF A to Z
WDE08 BULLETPROOF A to ZSatoshi Kikuchi
 
[CB20] DeClang: Anti-hacking compiler by Mengyuan Wan
[CB20] DeClang: Anti-hacking compiler by Mengyuan Wan[CB20] DeClang: Anti-hacking compiler by Mengyuan Wan
[CB20] DeClang: Anti-hacking compiler by Mengyuan WanCODE BLUE
 
60 Gadgets In 60 Minutes
60 Gadgets In 60 Minutes60 Gadgets In 60 Minutes
60 Gadgets In 60 MinutesVickie Kline
 
Py conkr 20150829_docker-python
Py conkr 20150829_docker-pythonPy conkr 20150829_docker-python
Py conkr 20150829_docker-pythonEric Ahn
 
Py conkr 20150829_docker-python
Py conkr 20150829_docker-pythonPy conkr 20150829_docker-python
Py conkr 20150829_docker-pythonEric Ahn
 
Rat Pack Remote Control - a technical Internet of Things (tm) basics primer
Rat Pack Remote Control - a technical Internet of Things (tm) basics primerRat Pack Remote Control - a technical Internet of Things (tm) basics primer
Rat Pack Remote Control - a technical Internet of Things (tm) basics primerSven Kräuter
 
Rat Pack Remote Control – an Internet of Things basics hands on workshop by S...
Rat Pack Remote Control – an Internet of Things basics hands on workshop by S...Rat Pack Remote Control – an Internet of Things basics hands on workshop by S...
Rat Pack Remote Control – an Internet of Things basics hands on workshop by S...Codemotion
 
Keep it simple web development stack
Keep it simple web development stackKeep it simple web development stack
Keep it simple web development stackEric Ahn
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Writing Apps that Can See: Getting Data from CoreImage to Computer Vision - ...
Writing Apps that Can See: Getting Data from CoreImage to Computer  Vision - ...Writing Apps that Can See: Getting Data from CoreImage to Computer  Vision - ...
Writing Apps that Can See: Getting Data from CoreImage to Computer Vision - ...Carl Brown
 
Packing secrets for the high tech traveler
Packing secrets for the high tech travelerPacking secrets for the high tech traveler
Packing secrets for the high tech travelerNetApp Insight
 
Kubernetes Chaos Engineering: Lessons Learned in Networking
Kubernetes Chaos Engineering: Lessons Learned in Networking Kubernetes Chaos Engineering: Lessons Learned in Networking
Kubernetes Chaos Engineering: Lessons Learned in Networking danielepolencic
 
How to make $30 million with a $500 investment
How to make $30 million with a $500 investmentHow to make $30 million with a $500 investment
How to make $30 million with a $500 investmentPhil Calçado
 

Similaire à Clean code on Android (Droidcon Dubai 2015) (20)

Arrow SI's December 2016 Instant Insight Webinar
Arrow SI's December 2016 Instant Insight WebinarArrow SI's December 2016 Instant Insight Webinar
Arrow SI's December 2016 Instant Insight Webinar
 
Deploying a Pylons app to Google App Engine
Deploying a Pylons app to Google App EngineDeploying a Pylons app to Google App Engine
Deploying a Pylons app to Google App Engine
 
Alex Fernández - Has anyone else seen your code? - Codemotion Berlin 2018
Alex Fernández - Has anyone else seen your code? - Codemotion Berlin 2018Alex Fernández - Has anyone else seen your code? - Codemotion Berlin 2018
Alex Fernández - Has anyone else seen your code? - Codemotion Berlin 2018
 
Creating Responsive Experiences
Creating Responsive ExperiencesCreating Responsive Experiences
Creating Responsive Experiences
 
Getting Started with iBeacons (Designers of Things 2014)
Getting Started with iBeacons (Designers of Things 2014)Getting Started with iBeacons (Designers of Things 2014)
Getting Started with iBeacons (Designers of Things 2014)
 
How I hacked the Google Daydream controller
How I hacked the Google Daydream controllerHow I hacked the Google Daydream controller
How I hacked the Google Daydream controller
 
WDE08 BULLETPROOF A to Z
WDE08 BULLETPROOF A to ZWDE08 BULLETPROOF A to Z
WDE08 BULLETPROOF A to Z
 
[CB20] DeClang: Anti-hacking compiler by Mengyuan Wan
[CB20] DeClang: Anti-hacking compiler by Mengyuan Wan[CB20] DeClang: Anti-hacking compiler by Mengyuan Wan
[CB20] DeClang: Anti-hacking compiler by Mengyuan Wan
 
60 Gadgets In 60 Minutes
60 Gadgets In 60 Minutes60 Gadgets In 60 Minutes
60 Gadgets In 60 Minutes
 
Py conkr 20150829_docker-python
Py conkr 20150829_docker-pythonPy conkr 20150829_docker-python
Py conkr 20150829_docker-python
 
Py conkr 20150829_docker-python
Py conkr 20150829_docker-pythonPy conkr 20150829_docker-python
Py conkr 20150829_docker-python
 
Rat Pack Remote Control - a technical Internet of Things (tm) basics primer
Rat Pack Remote Control - a technical Internet of Things (tm) basics primerRat Pack Remote Control - a technical Internet of Things (tm) basics primer
Rat Pack Remote Control - a technical Internet of Things (tm) basics primer
 
Rat Pack Remote Control – an Internet of Things basics hands on workshop by S...
Rat Pack Remote Control – an Internet of Things basics hands on workshop by S...Rat Pack Remote Control – an Internet of Things basics hands on workshop by S...
Rat Pack Remote Control – an Internet of Things basics hands on workshop by S...
 
Keep it simple web development stack
Keep it simple web development stackKeep it simple web development stack
Keep it simple web development stack
 
Cloud Spin - building a photo booth with the Google Cloud Platform
Cloud Spin - building a photo booth with the Google Cloud PlatformCloud Spin - building a photo booth with the Google Cloud Platform
Cloud Spin - building a photo booth with the Google Cloud Platform
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Writing Apps that Can See: Getting Data from CoreImage to Computer Vision - ...
Writing Apps that Can See: Getting Data from CoreImage to Computer  Vision - ...Writing Apps that Can See: Getting Data from CoreImage to Computer  Vision - ...
Writing Apps that Can See: Getting Data from CoreImage to Computer Vision - ...
 
Packing secrets for the high tech traveler
Packing secrets for the high tech travelerPacking secrets for the high tech traveler
Packing secrets for the high tech traveler
 
Kubernetes Chaos Engineering: Lessons Learned in Networking
Kubernetes Chaos Engineering: Lessons Learned in Networking Kubernetes Chaos Engineering: Lessons Learned in Networking
Kubernetes Chaos Engineering: Lessons Learned in Networking
 
How to make $30 million with a $500 investment
How to make $30 million with a $500 investmentHow to make $30 million with a $500 investment
How to make $30 million with a $500 investment
 

Plus de Danny Preussler

We aint got no time - Droidcon Nairobi
We aint got no time - Droidcon NairobiWe aint got no time - Droidcon Nairobi
We aint got no time - Droidcon NairobiDanny Preussler
 
Test Driven Development on Android (Kotlin Kenya)
Test Driven Development on Android (Kotlin Kenya)Test Driven Development on Android (Kotlin Kenya)
Test Driven Development on Android (Kotlin Kenya)Danny Preussler
 
TDD on android. Why and How? (Coding Serbia 2019)
TDD on android. Why and How? (Coding Serbia 2019)TDD on android. Why and How? (Coding Serbia 2019)
TDD on android. Why and How? (Coding Serbia 2019)Danny Preussler
 
TDD on Android (Øredev 2018)
TDD on Android (Øredev 2018)TDD on Android (Øredev 2018)
TDD on Android (Øredev 2018)Danny Preussler
 
Junit5: the next gen of testing, don't stay behind
Junit5: the next gen of testing, don't stay behindJunit5: the next gen of testing, don't stay behind
Junit5: the next gen of testing, don't stay behindDanny Preussler
 
Demystifying dependency Injection: Dagger and Toothpick
Demystifying dependency Injection: Dagger and ToothpickDemystifying dependency Injection: Dagger and Toothpick
Demystifying dependency Injection: Dagger and ToothpickDanny Preussler
 
Unit testing without Robolectric, Droidcon Berlin 2016
Unit testing without Robolectric, Droidcon Berlin 2016Unit testing without Robolectric, Droidcon Berlin 2016
Unit testing without Robolectric, Droidcon Berlin 2016Danny Preussler
 
15 tips to improve your unit tests (Droidcon Berlin 2016 Barcamp)
15 tips to improve your unit tests (Droidcon Berlin 2016 Barcamp)15 tips to improve your unit tests (Droidcon Berlin 2016 Barcamp)
15 tips to improve your unit tests (Droidcon Berlin 2016 Barcamp)Danny Preussler
 
(Android) Developer Survival in Multiscreen World, MobCon Sofia 2016
(Android) Developer Survival in Multiscreen World, MobCon Sofia 2016(Android) Developer Survival in Multiscreen World, MobCon Sofia 2016
(Android) Developer Survival in Multiscreen World, MobCon Sofia 2016Danny Preussler
 
Bye Bye Charles, Welcome Odo, Android Meetup Berlin May 2014
Bye Bye Charles, Welcome Odo, Android Meetup Berlin May 2014Bye Bye Charles, Welcome Odo, Android Meetup Berlin May 2014
Bye Bye Charles, Welcome Odo, Android Meetup Berlin May 2014Danny Preussler
 
Abgeschottete Realität - Testen im Emulator, Mobile Testing Days 2014, Berlin
Abgeschottete Realität - Testen im Emulator, Mobile Testing Days 2014, BerlinAbgeschottete Realität - Testen im Emulator, Mobile Testing Days 2014, Berlin
Abgeschottete Realität - Testen im Emulator, Mobile Testing Days 2014, BerlinDanny Preussler
 
Rockstar Android Testing (Mobile TechCon Munich 2014)
Rockstar Android Testing (Mobile TechCon Munich 2014)Rockstar Android Testing (Mobile TechCon Munich 2014)
Rockstar Android Testing (Mobile TechCon Munich 2014)Danny Preussler
 
Android Code Puzzles (DroidCon Amsterdam 2012)
Android Code Puzzles (DroidCon Amsterdam 2012)Android Code Puzzles (DroidCon Amsterdam 2012)
Android Code Puzzles (DroidCon Amsterdam 2012)Danny Preussler
 

Plus de Danny Preussler (13)

We aint got no time - Droidcon Nairobi
We aint got no time - Droidcon NairobiWe aint got no time - Droidcon Nairobi
We aint got no time - Droidcon Nairobi
 
Test Driven Development on Android (Kotlin Kenya)
Test Driven Development on Android (Kotlin Kenya)Test Driven Development on Android (Kotlin Kenya)
Test Driven Development on Android (Kotlin Kenya)
 
TDD on android. Why and How? (Coding Serbia 2019)
TDD on android. Why and How? (Coding Serbia 2019)TDD on android. Why and How? (Coding Serbia 2019)
TDD on android. Why and How? (Coding Serbia 2019)
 
TDD on Android (Øredev 2018)
TDD on Android (Øredev 2018)TDD on Android (Øredev 2018)
TDD on Android (Øredev 2018)
 
Junit5: the next gen of testing, don't stay behind
Junit5: the next gen of testing, don't stay behindJunit5: the next gen of testing, don't stay behind
Junit5: the next gen of testing, don't stay behind
 
Demystifying dependency Injection: Dagger and Toothpick
Demystifying dependency Injection: Dagger and ToothpickDemystifying dependency Injection: Dagger and Toothpick
Demystifying dependency Injection: Dagger and Toothpick
 
Unit testing without Robolectric, Droidcon Berlin 2016
Unit testing without Robolectric, Droidcon Berlin 2016Unit testing without Robolectric, Droidcon Berlin 2016
Unit testing without Robolectric, Droidcon Berlin 2016
 
15 tips to improve your unit tests (Droidcon Berlin 2016 Barcamp)
15 tips to improve your unit tests (Droidcon Berlin 2016 Barcamp)15 tips to improve your unit tests (Droidcon Berlin 2016 Barcamp)
15 tips to improve your unit tests (Droidcon Berlin 2016 Barcamp)
 
(Android) Developer Survival in Multiscreen World, MobCon Sofia 2016
(Android) Developer Survival in Multiscreen World, MobCon Sofia 2016(Android) Developer Survival in Multiscreen World, MobCon Sofia 2016
(Android) Developer Survival in Multiscreen World, MobCon Sofia 2016
 
Bye Bye Charles, Welcome Odo, Android Meetup Berlin May 2014
Bye Bye Charles, Welcome Odo, Android Meetup Berlin May 2014Bye Bye Charles, Welcome Odo, Android Meetup Berlin May 2014
Bye Bye Charles, Welcome Odo, Android Meetup Berlin May 2014
 
Abgeschottete Realität - Testen im Emulator, Mobile Testing Days 2014, Berlin
Abgeschottete Realität - Testen im Emulator, Mobile Testing Days 2014, BerlinAbgeschottete Realität - Testen im Emulator, Mobile Testing Days 2014, Berlin
Abgeschottete Realität - Testen im Emulator, Mobile Testing Days 2014, Berlin
 
Rockstar Android Testing (Mobile TechCon Munich 2014)
Rockstar Android Testing (Mobile TechCon Munich 2014)Rockstar Android Testing (Mobile TechCon Munich 2014)
Rockstar Android Testing (Mobile TechCon Munich 2014)
 
Android Code Puzzles (DroidCon Amsterdam 2012)
Android Code Puzzles (DroidCon Amsterdam 2012)Android Code Puzzles (DroidCon Amsterdam 2012)
Android Code Puzzles (DroidCon Amsterdam 2012)
 

Dernier

VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnAmarnathKambale
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastPapp Krisztián
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareJim McKeeth
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benonimasabamasaba
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024VictoriaMetrics
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...masabamasaba
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in sowetomasabamasaba
 
WSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2
 
tonesoftg
tonesoftgtonesoftg
tonesoftglanshi9
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrandmasabamasaba
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...Jittipong Loespradit
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrainmasabamasaba
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxAnnaArtyushina1
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...masabamasaba
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfonteinmasabamasaba
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationJuha-Pekka Tolvanen
 
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2
 

Dernier (20)

Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
WSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - Keynote
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptx
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the Situation
 
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
 

Clean code on Android (Droidcon Dubai 2015)

  • 1. Clean Code on Android! DroidCon Dubai Danny Preussler Groupon
 The  Living  Room,  Colin  and  Sarah  Northway,  CC  by  2.0   h<ps://www.flickr.com/photos/apes_abroad/1479254938  
  • 2. Groupon is the global 
 leader in local commerce, making it easy for people around the world to search ! and discover great businesses at unbeatable prices. Source: Internal data,, March 2014 WORLDWIDE! 260M+ subscribers 53.9M active customers 500+ markets 900M+ deals sold 2 $5B+ in annual billings 12,000+ global employees
  • 3. Leading the way in mobile commerce Our mobile app is available in 43 countries. Groupon’s vibrant mobile marketplace connects! consumers with their local economy 3  Sources: Internal Data; iTunes ranking for US stores available here - https://itunes.apple.com/WebObjects/ MZStore.woa/wa/viewFeature?id=500873243&mt=8&v0=www-itunes25Bcountdown-appstore Nearly 110 million people worldwide have downloaded our mobile app at the end of Q4 2014. One of the 25 most downloaded free apps of all time More than 50% of our Global transactions were completed on a mobile device by the end of Q4 2014
  • 4. Groupon Berlin Groupon Merchant App Obsessed with beautiful code
  • 5. SOLID FOUNDATIONFlughafen Berlin-Brandenburg, Blick in die Abflughalle by Muns CC BY 3.0 http://commons.wikimedia.org/wiki/File:120513-BER-innen.JPG
  • 6. violating the most basics principles of Software Engineering! flickr.com/photos/cobblucas/4831501753,  Stop  by  Lucas  Cobb,  CC  by  2.0  
  • 7. Separation of concerns (1974)! •  Modularize, Encapsulate, Layer! Example: Don‘t do HTTP request in Activities/Fragments! flickr.com/photos/ionics/6337522871,  Black  Sheep  Meets  White  Sheep  by  Leon  Riskin,  CC  by  2.0  
  • 8. Don‘t ! repeat ! ourself!! Boris  Bikes  DLR,  Les  Haines,  CC  by  2.0   flickr.com/photos/leshaines123/8370292862  
  • 9. ViolaTons  of  DRY  are  typically   referred  to  as  WET  soluTons,   which  is  commonly  taken  to   stand  for  either  "write  everything   twice"  or  "we  enjoy  typing”     (h<p://en.wikipedia.org/wiki/Don't_repeat_yourself)   Android Firewall by Uncalno, CC BY 2.0 flickr.com/photos/uncalno/8538679708
  • 10. Clean Code!! The  Living  Room,  Colin  and  Sarah  Northway,  CC  by  2.0   h<ps://www.flickr.com/photos/apes_abroad/1479254938   Clean  Code     by     Robert  C.  Mar0n  
  • 11. Robert C. Martin – Clean Code! The  Living  Room,  Colin  and  Sarah  Northway,  CC  by  2.0   h<ps://www.flickr.com/photos/apes_abroad/1479254938   Uncle  Bob  says:   (Keep  it)  small!  
  • 12. Robert C. Martin – Clean Code! The  Living  Room,  Colin  and  Sarah  Northway,  CC  by  2.0   h<ps://www.flickr.com/photos/apes_abroad/1479254938   Uncle  Bob  says:   Do  One  Thing!  
  • 13. Robert C. Martin – Clean Code! The  Living  Room,  Colin  and  Sarah  Northway,  CC  by  2.0   h<ps://www.flickr.com/photos/apes_abroad/1479254938   Uncle  Bob  says:   One  Level  of  Abstrac0on     per  Func0on!  
  • 14. Robert C. Martin – Clean Code! The  Living  Room,  Colin  and  Sarah  Northway,  CC  by  2.0   h<ps://www.flickr.com/photos/apes_abroad/1479254938   Uncle  Bob  says:   Reading  Code  from  Top     to  BoHom  
  • 15. Robert C. Martin – Clean Code! The  Living  Room,  Colin  and  Sarah  Northway,  CC  by  2.0   h<ps://www.flickr.com/photos/apes_abroad/1479254938   Uncle  Bob  says:   Comments  Do  Not  Make  Up     for  Bad  Code  
  • 16. Robert C. Martin – Clean Code! The  Living  Room,  Colin  and  Sarah  Northway,  CC  by  2.0   h<ps://www.flickr.com/photos/apes_abroad/1479254938   Uncle  Bob  says:   Avoid  switch    It’s  [..]  hard  to  make  a  switch  statement  that  does  one  thing.     By  their  nature,  switch  statements  always  do  N  things.  
  • 17. Much more...! The  Living  Room,  Colin  and  Sarah  Northway,  CC  by  2.0   h<ps://www.flickr.com/photos/apes_abroad/1479254938   A  must   Read!  
  • 18. Codesmells....! Sintra,  Portugal,  The  smell  of  the  portuguese  wine,  CC  by  
  • 19. Si_ng  in  a  Tree,  Big  Bend  NaTonal  Park  by  Adam  Baker,  CC  by  2.0,  flickr.com/photos/atbaker/5474766579   Watch out for ! Primitive Obsession!
  • 20. Ban null ! from ! your code!! nothing  is  nothing  by  darwin  Bell,  CC  by  2.0,  flickr.com/photos/darwinbell/272818496  
  • 21. private MyParcelable myParceable; ... Bundle bundle = getArguments(); if (bundle != null) { myParceable = bundle.getParcelable("ARGUMENT"); } .... if (myParcaeable != null) { ... } ... if (myParcaeable != null) { ... } Don‘t:! Red  Stop  Bu<on  by  Ben  K  Adams,  CC  by  2.0,  flickr.com/photos/schtumple/5475697999  
  • 22. Cleaner  by  atomicjeep,  CC  by  2.0,  flickr.com/photos/atomicjeep/144719649   Do: Inject Dependencies! private MyParcelable myParceable = MyParceable.NONE; ... Bundle bundle = getArguments(); if (bundle != null && bundle.hasParceable(„ARGUMENT“) { myParceable = bundle.getParcelable("ARGUMENT"); } .... if (myParcaeable != null) { ... } ... if (myParcaeable != null) { ... }
  • 23. The power of Dependency Injection! •  Don‘t  create  dependencies   •  Invert  Control!     •  Inject  them!   I  love  the  Light  &  I  dig  the  Sun  by  fady  habib,  CC  by  2.0,  flickr.com/photos/unTtlism/2609684221
  • 24. public class WetFragment extends Fragment { MyController controller; ... @Override public void onAttach(Activity activity) { super.onAttach(activity); controller = new MyController(activity.getApplicationContext()); Don‘t:! Red  Stop  Bu<on  by  Ben  K  Adams,  CC  by  2.0,  flickr.com/photos/schtumple/5475697999  
  • 25. Cleaner  by  atomicjeep,  CC  by  2.0,  flickr.com/photos/atomicjeep/144719649   public class DryFragment extends Fragment { @Inject MyController controller; ... @Override public void onAttach(Activity activity) { super.onAttach(activity); controller = new MyController(activity.getApplicationContext()); Do: Inject Dependencies!
  • 26. public class WetFragment extends Fragment { EditText myEditField; @Override public View onCreateView(LayoutInflater inflater, ...) { View view = inflater.inflate(...... myEditField = (EditText)view.findViewById(R.id.edit1); ... Don‘t:! Red  Stop  Bu<on  by  Ben  K  Adams,  CC  by  2.0,  flickr.com/photos/schtumple/5475697999  
  • 27. Cleaner  by  atomicjeep,  CC  by  2.0,  flickr.com/photos/atomicjeep/144719649   public class DryFragment extends Fragment { @Inject(R.id.edit1) EditText myEditField; @Override public View onCreateView(LayoutInflater inflater, ...) { View view = inflater.inflate(...... myEditField = (EditText)view.findViewById(R.id.edit1); ... Do: Inject views!
  • 28. public class WetFragment extends Fragment { private MyParcelable myParceable; @Override public void onAttach(Activity activity) { super.onAttach(activity); Bundle bundle = getArguments(); if (bundle != null) { myParceable = bundle.getParcelable("ARGUMENT"); if (myParceable == null) { myParceable = MyParcelable.NONE; } } } Don‘t:! Red  Stop  Bu<on  by  Ben  K  Adams,  CC  by  2.0,  flickr.com/photos/schtumple/5475697999  
  • 29. Cleaner  by  atomicjeep,  CC  by  2.0,  flickr.com/photos/atomicjeep/144719649   public class DryFragment extends Fragment { @Inject(„ARGUMENT“) MyParcelable = myParceable.NONE; @Override public void onAttach(Activity activity) { super.onAttach(activity); Bundle bundle = getArguments(); if (bundle != null) { myParceable = bundle.getParcelable("ARGUMENT"); if (myParceable == null) { myParceable = MyParcelable.NONE; } } } Do: Inject arguments / extras!
  • 30. public class WetFragment extends Fragment { @Override public View onCreateView(LayoutInflater inflater, ...) { return inflater.inflate( R.layout.main_layout, container, false); } Don‘t:! Red  Stop  Bu<on  by  Ben  K  Adams,  CC  by  2.0,  flickr.com/photos/schtumple/5475697999  
  • 31. Cleaner  by  atomicjeep,  CC  by  2.0,  flickr.com/photos/atomicjeep/144719649   @InjectLayout(R.layout.main_layout) public class DryFragment extends Fragment { @Override public View onCreateView(LayoutInflater inflater, ...) { return inflater.inflate( R.layout.main_layout, container, false); } Do: Inject layout!
  • 32. Cleaner  by  atomicjeep,  CC  by  2.0,  flickr.com/photos/atomicjeep/144719649   @InjectLayout(R.layout.main_layout) public class DryFragment extends Fragment { @Override public View onCreateView(LayoutInflater inflater, ...) { return inflater.inflate( R.layout.main_layout, container, false); } Do: auto (find) layout! Simply have dry_fragment.xml or dry.xml  
  • 33. ©  Biblioarchive,  CC  by  2.0,  www.flickr.com/photos/lac-­‐bac/4679195538   •  Dagger 
 github.com/square/dagger •  Butterknife 
 github.com/JakeWharton/butterknife •  InjectExtra 
 github.com/stephanenicolas/injectextra •  Autolayout 
 github.com/dpreussler/android-autolayout How to Do:!
  • 34. ©  Biblioarchive,  CC  by  2.0,  www.flickr.com/photos/lac-­‐bac/4679195538   •  RoboGuice 
 github.com/roboguice/roboguice •  Android-Dart 
 github.com/f2prateek/android-dart •  Spring Android 
 github.com/spring-projects/spring-android •  Transfuse 
 github.com/johncarl81/transfuse •  Android Annotations 
 github.com/excilys/androidannotations Alternative or more Do‘s!
  • 35. Complicated,  Rohit  Ma<oo,  CC  by  2.0,  flickr.com/photos/mar00ned/229903286   @Override public void onResume() { super.onResume(); getFragmentManager() .beginTransaction() .add(R.id.fragments, new WetFragment()) . commitAllowingStateLoss(); } Dont: write untestable code:!
  • 36. test  (c)  DaveBleasdale,  CC  by  2.0,  www.flickr.com/photos/sidelong/246816211   Do: write testable code:! @Inject MyTransactionUtil transactions; @Override public void onResume() { super.onResume(); transactions.addAllowingStateLoss( R.id.fragments, new WetFragment()); }
  • 37. • Split your Activities • Alternative Mortar github.com/square/mortar Do: use the Power of Fragments! the  icon  (CC)  by  MarTn  Fisch,  CC  by  2.0,    flickr.com/photos/marfis75/7164769781  
  • 39. Got legacy code?! Old  by  Moyan  Brenn,  flickr.com/photos/aigle_dore/5677012469  
  • 40. Clean = feel good!! The  Living  Room,  Colin  and  Sarah  Nor h<ps://www.flickr.com/photos/apes_abr
  • 41. THANK YOU Danny Preussler
 GROUPON 
 Berlin
 dpreussler@groupon.com    
  • 42. github.com/groupon engineering.groupon.com Michael  Burton,  Roboguice   Carlos  Sessa,  50  Android  hacks   David  van  der  Bokke,  RoboRemote   David  Willson,  Odo   ….   Stephane  Nicolas,  RoboSpice   ParTal  Supermen,  juliegomoll,  CC  by  2.0,  flickr.com/photos/juliegomoll/1352843346