Slide 1

Slide 1 text

Building a career in Android Development @magdamiu

Slide 2

Slide 2 text

ABOUT ME ● Squad Leader Developer @Orange ● Android Google Developers Expert ● Trainer & Speaker ● Co-organiser GDG Pitesti & WTM Romania

Slide 3

Slide 3 text

Employment history Web Developer Aug 2010 - Oct 2010 Android Developer Nov 2010 - Aug 2015 Android Technical Lead Sept 2015 - Dec 2019 Squad Lead Developer Jan 2019 - Present GDE Android Feb 2019 - Present

Slide 4

Slide 4 text

OOP Q: What’s the object-oriented way to become wealthy? A: Inheritance

Slide 5

Slide 5 text

Cohesion

Slide 6

Slide 6 text

Coupling

Slide 7

Slide 7 text

Best case scenario Cohesion Coupling high low

Slide 8

Slide 8 text

● Don’t Repeat Yourself ● Applicable whenever we copy / paste a piece of code D.R.Y.

Slide 9

Slide 9 text

● Keep It Simple and Stupid ● Whenever we want to implement a method to do all things K.I.S.S.

Slide 10

Slide 10 text

● You Ain’t Gonna Need It ● Don’t write code which is not yet necessary Y.A.G.N.I.

Slide 11

Slide 11 text

● Single responsibility (SRP) ● Open-closed (OCP) ● Liskov substitution (LSP) ● Interface segregation (ISP) ● Dependency inversion (DIP) S.O.L.I.D.

Slide 12

Slide 12 text

Design Patterns

Slide 13

Slide 13 text

Law of Demeter A B B is a friend of A C C is a friend of B *Note: A friend of a friend is a stranger Messages from A to B are OK Messages from A to C are discouraged

Slide 14

Slide 14 text

“Tell, Don't Ask” Principle

Slide 15

Slide 15 text

Objects vs Data Tell, don’t ask. Don’t talk to strangers. Dealing with Objects? Dealing with Data?

Slide 16

Slide 16 text

Kotlin A modern and pragmatic language for the industry, not an academic one.

Slide 17

Slide 17 text

No content

Slide 18

Slide 18 text

No content

Slide 19

Slide 19 text

● General-purpose ● FP + OOP ● Open source (Apache 2.0) ● Developed by JetBrains ● Static typing What is Kotlin?

Slide 20

Slide 20 text

Kotlin is 100% interoperable with Java *.kt *.java Kotlin compiler Java compiler *.class *.jar App Kotlin runtime

Slide 21

Slide 21 text

No content

Slide 22

Slide 22 text

// Elvis operator val name: String? = null val lengthOfName = name?.length ?: -1 println(lengthOfName)

Slide 23

Slide 23 text

// Elvis operator val name: String? = null val lengthOfName = name?.length ?: -1 println(lengthOfName) // => -1

Slide 24

Slide 24 text

class Utility { // infix functions = functions with a single parameter infix fun String.onto(other: String) = Pair(this, other) } fun main(args: Array) { val blueShoes = "blue".onto("shoes") val yellowScarf = "yellow" onto "scarf" println(blueShoes) // => (blue, shoes) println(yellowScarf) // => (yellow, scarf) }

Slide 25

Slide 25 text

fun String.removeFirstLastChar(): String = this.substring(1, this.length - 1) Receiver type Receiver object

Slide 26

Slide 26 text

Data classes are a concise way to create classes that just hold data. Data classes Function Price Getters and Setters 0 Lei equals() & hashCode() 0 Lei toString() 0 Lei componentN() 0 Lei copy() 0 Lei TOTAL FREE!

Slide 27

Slide 27 text

Coroutines are lightweight threads

Slide 28

Slide 28 text

co + routines coroutines Cooperation Functions

Slide 29

Slide 29 text

Clean Code “Clean code is readable. It tells a story.” Uncle Bob, Clean Code

Slide 30

Slide 30 text

No content

Slide 31

Slide 31 text

No content

Slide 32

Slide 32 text

No content

Slide 33

Slide 33 text

Code quality “measure” WTFs/min Few WTFs Developer Many WTFs Developer

Slide 34

Slide 34 text

Use intention-revealing names Types Names Classes and Objects Customer, Account, WikiPage Methods postPayment, deleteAccount, displayPage Solution domain names AccountVisitor Problem domain names churnPerMonth

Slide 35

Slide 35 text

“UNCLEAN” CODE CLEAN CODE

Slide 36

Slide 36 text

users.filter{ it.job == Job.Developer } .map{ it.birthDate.dayOfMonth } .filter{ it <= 10 } .min() WARNING: Use explicit argument names and avoid using too often “it”

Slide 37

Slide 37 text

users.filter{ user -> user.job == Job.Developer } .map{ developer -> developer.birthDate.dayOfMonth } .filter { birthDay -> birthDay <= 10 } .min() WARNING: Use explicit argument names and avoid using too often “it”

Slide 38

Slide 38 text

fun sumUpUserPoints(): Int { var sumAllPoints = 0 for (user in users) { sumAllPoints += user.points sendEmail(user) } return sumAllPoints } No side effects Side effect

Slide 39

Slide 39 text

fun computeSqrt(number: Double): Double { if(number >= 0) { return Math.sqrt(number) } else { throw RuntimeException("No negative please") } } Nothing is something...

Slide 40

Slide 40 text

fun getMovie(id: Int): Movie { val movie = movieRepository.findMovie(id) return movie ?: throw RuntimeException("Movie not found") } Throw exceptions

Slide 41

Slide 41 text

sealed class MovieSearchResult data class MovieFound(val movie: Movie) : MovieSearchResult() object MovieNotFound : MovieSearchResult() object DatabaseOffline : MovieSearchResult() fun getMovie(id: Int): MovieSearchResult { val movie = movieRepository.findMovie(id) return if (movie == null) { MovieNotFound } else { MovieFound(movie) } } Return result class

Slide 42

Slide 42 text

inputStream.use { outputStream.use { // do something with the streams outputStream.write(inputStream.read()) } } “try-with-resources” in Kotlin - initial solution

Slide 43

Slide 43 text

arrayOf(inputStream, outputStream).use { // do something with the streams outputStream.write(inputStream.read()) } “try-with-resources” in Kotlin - improved solution

Slide 44

Slide 44 text

private inline fun Array.use(block: ()->Unit) { // implementation } use implementation

Slide 45

Slide 45 text

Kotlin is about developer’s happiness and productivity.

Slide 46

Slide 46 text

Android Jetpack A set of libraries, tools and guides to help make app building quick and easy.

Slide 47

Slide 47 text

Android Jetpack Follow best practices Fewer crashes and less memory leaks with backwards-compatibility baked in. No boilerplate code You can focus on what makes your app great. Reduce fragmentation Reduce complexity with libraries that work consistently across Android versions and devices.

Slide 48

Slide 48 text

Android Jetpack UI Jetpack Compose Foundation AndroidX, Android KTX Architecture LiveData, ViewModel, Lifecycle, Room, Navigation, Paging, Hilt Behaviour Slices, Security, Permissions

Slide 49

Slide 49 text

*Recommended app architecture Activity / Fragment Model Room Remote Data source Retrofit SQLite REST API ViewModel LiveData Repository

Slide 50

Slide 50 text

Architecture Components: Room for databases Components Entity, Dao, Database “Relations” @Embedded, @Relation, @ForeignKey Queries @Insert, @Update, @Delete, @Query, @RawQuery

Slide 51

Slide 51 text

Tools for Android development CI/CD Pipeline

Slide 52

Slide 52 text

Learning Plan “A goal without a plan is just a wish.” Antoine de Saint-Exupéry

Slide 53

Slide 53 text

Achievable Learning Plan @Work Code review & Pull Request @Home SWOT & OKRs

Slide 54

Slide 54 text

@Work Code review & Pull Request

Slide 55

Slide 55 text

Reviewer Author

Slide 56

Slide 56 text

Author

Slide 57

Slide 57 text

Writing the code ● Make sure you understand your task ● Refactor the code if it’s unreadable ● Write tests and follow the team conventions ● Format your code before commit it

Slide 58

Slide 58 text

The boy scout rule Leave the campground cleaner than you found it.

Slide 59

Slide 59 text

Before the code review ● Add relevant commit comments ● Send pull requests often ● Have minimum 2 reviewers (one is senior)

Slide 60

Slide 60 text

After the code review ● Be humble ● You are on the same side with your reviewer(s) ● Know when to unlearn the old habits

Slide 61

Slide 61 text

Reviewer

Slide 62

Slide 62 text

Use I… comments ● I think… ● I would… ● I believe… ● I suggest...

Slide 63

Slide 63 text

Ask questions ● Have you consider using… ? ● What do you think about… ? ● Have you tried to… ?

Slide 64

Slide 64 text

It’s about the code, not about the coder ● This code… ● This function… ● This line of code...

Slide 65

Slide 65 text

Feedback equation* Observation of a behavior Impact of the behavior Question or Request I observed this function has 60 lines. This makes it difficult for me to understand the logic. I suggest extracting a part of the code into other functions and give them relevant names. * Defined by Lara Hogan

Slide 66

Slide 66 text

@Home SWOT & OKRs

Slide 67

Slide 67 text

The “process” SWOT Where I am now Retro How it was and what’s next OKRs What I want to achieve Review What I achieved 01 02 04 03

Slide 68

Slide 68 text

Personal SWOT Analysis ME Weaknesses Skills that should be improved (technical or work habits) Threats Impediments at work, changes, weaknesses lead to threats Strengths Advantages like: skills, achievements, certifications, education, connections Opportunities Events, conferences, new role/project, industry growing

Slide 69

Slide 69 text

● Goal setting in a collaborative way ● Objective => WHAT ● Key results => HOW ● “It’s not a key result unless it has a number” OKRs

Slide 70

Slide 70 text

● Superpower #1 => focus and commit to priorities ● Superpower #2 => align and connect for teamwork ● Superpower #3 => track for accountability ● Superpower #4 => stretch for amazing OKRs superpowers

Slide 71

Slide 71 text

● 0.7 to 1.0 = green (we delivered) ● 0.4 to 0.6 = yellow (we made progress, but fell short of completion) ● 0.0 to 0.3 = red (we failed to make real progress) Scoring @Google

Slide 72

Slide 72 text

OKR sample Learn Kotlin for Android Development 6 months / weekly review Quantity Goal Quality Goal Result 1 Kotlin Koan per week Learn specific features of the language => 1 feature / week Exercise often and on a set of Koans proposed by JetBrains Write one detailed article about a specific topic per month Improve my writing skills and learn by teaching to others Learn new things, help the community and get feedback 3 code samples runned per week Get a repo with samples that I can re-check (use ktlint) Gain real experience in programming using Kotlin

Slide 73

Slide 73 text

● Score your results ● Keep notes of your accomplishments ● Look for feedback because development is continuous ● Surround yourself with people who motivate and inspire you ● Find a mentor Review

Slide 74

Slide 74 text

● Did I accomplish all of my objectives? ○ YES => what contributed to my success? ○ NO => what obstacles did I encounter? ● If I were to rewrite a goal achieved in full, what would I change? ● What have I learned that might alter my approach to the next cycle’s OKRs? ● Understand what is your WHY ● Repeat the process Retrospective

Slide 75

Slide 75 text

Official Documentation from Google Blogs and Websites Code Examples (Codelabs & GitHub) Newsletters Books & Online Courses From where to learn more... Videos & Youtube Channels Podcasts ‍‍Twitter Conferences & Meetups Troubleshooting https://magdamiu.com/2019/09/22/lets-talk-android/

Slide 76

Slide 76 text

● Define with your colleagues a set of conventions ● Justify technology use ● Enforce good practices (XP) ● Question until you understand ● Criticize ideas, not people ● Testing, testing, testing ● Integrate early, integrate often ● Emphasize collective ownership of code ● Prioritize and actively evaluate trade-offs ● Listen to users My summary

Slide 77

Slide 77 text

CREDITS: This presentation template was created by Slidesgo, including icons by Flaticon, images from Unsplash, and infographics & images by Freepik. THANKS! magdamiu.com @magdamiu