27
An Empirical Study on the Practice of Maintaining Object-Relational Mapping Code in Java Systems 1 Mohamed Nasser, Parminder Flora Tse-Hsun(Peter) Chen Ahmed E. Hassan Weiyi Shang Jinqiu Yang Michael W. Godfre

MSR2016 - An Empirical Study on the Practice of Maintaining Object-Relational Mapping Code in Java Systems

Embed Size (px)

Citation preview

Page 1: MSR2016 - An Empirical Study on the Practice of Maintaining Object-Relational Mapping Code in Java Systems

1

An Empirical Study on the Practice of Maintaining Object-Relational Mapping

Code in Java Systems

Mohamed Nasser, Parminder Flora

Tse-Hsun(Peter) Chen Ahmed E. HassanWeiyi Shang Jinqiu Yang Michael W. Godfrey

Page 2: MSR2016 - An Empirical Study on the Practice of Maintaining Object-Relational Mapping Code in Java Systems

2

Databases are essential in modern large-scale software systems

Database

Page 3: MSR2016 - An Empirical Study on the Practice of Maintaining Object-Relational Mapping Code in Java Systems

3

Object-Relational Mapping (ORM) eliminates the gap between objects and SQL

Database

• Less boilerplate code • Object-DB translations are done automatically

JavaClasses

Benefits over raw SQLs

ORM

Much less code and shorter development time

Page 4: MSR2016 - An Empirical Study on the Practice of Maintaining Object-Relational Mapping Code in Java Systems

ORM provides another layer of abstraction

4

ORM

Database mapping code@Table(name = “user”)

Performance configurationquery.cache()

ORM query codeUser u = q.getSingleResult();

Page 5: MSR2016 - An Empirical Study on the Practice of Maintaining Object-Relational Mapping Code in Java Systems

5

ORM is not a silver bullet

Using ORM comes with some hidden costs…

We have been working on helping developers improve ORM code for the past few years

Page 6: MSR2016 - An Empirical Study on the Practice of Maintaining Object-Relational Mapping Code in Java Systems

Developers are often not aware of database access

Wow! I don’t need to worry

about DB code!

ORM code with performance anti-patterns

6

Bad system performance

The performance impact can be SIGNIFICANT (ICSE 2014)!

Page 7: MSR2016 - An Empirical Study on the Practice of Maintaining Object-Relational Mapping Code in Java Systems

ORM is hard to configure

7

Hundreds of ORM performance-related

configuration

Un-optimal ORM configuration is common and causes significantly performance

problem (TSE 2016)!

Bad system Performance if

configured incorrectly

Page 8: MSR2016 - An Empirical Study on the Practice of Maintaining Object-Relational Mapping Code in Java Systems

Studying maintenance activities of Java ORM code

8

Expect: ORM-related changes are localized

Expect: Frequently tuning configurations

Expect: Tooling support due to ORM

popularity

Page 9: MSR2016 - An Empirical Study on the Practice of Maintaining Object-Relational Mapping Code in Java Systems

Studied Java systems

Large open-source e-commence system Enterprise system

9

Portal Content management system

Page 10: MSR2016 - An Empirical Study on the Practice of Maintaining Object-Relational Mapping Code in Java Systems

Studying maintenance activities of Java ORM code

10

Expect: ORM-related changes are localized

Expect: Frequently tuning configurations

Expect: Tooling support due to ORM

popularity

Page 11: MSR2016 - An Empirical Study on the Practice of Maintaining Object-Relational Mapping Code in Java Systems

Lack of bug detection tool support for Java ORM

11

Coverity PMD Google error-prone

Facebook InferFindBugs

More than 67% of Java developers use ORM, but there is limited tooling support (ICSE SEIP 2016)

Page 12: MSR2016 - An Empirical Study on the Practice of Maintaining Object-Relational Mapping Code in Java Systems

Studying maintenance activities of Java ORM code

12

Expect: ORM-related changes are localized

Expect: Frequently tuning configurations

Expect: Tooling support due to ORM

popularity

No! There is limited tooling

support

Page 13: MSR2016 - An Empirical Study on the Practice of Maintaining Object-Relational Mapping Code in Java Systems

Studying maintenance activities of Java ORM code

13

Expect: ORM-related changes are localized

Expect: Frequently tuning configurations

Expect: Tooling support due to ORM

popularity

No! There is limited tooling

support

Page 14: MSR2016 - An Empirical Study on the Practice of Maintaining Object-Relational Mapping Code in Java Systems

ORM configurations are rarely tuned

14

Most ORM code changes are related to ORM queries (35%) and ORM database mapping code (55%)

ORM performance configurations are rarely tuned (less than 10%)

Page 15: MSR2016 - An Empirical Study on the Practice of Maintaining Object-Relational Mapping Code in Java Systems

Studying maintenance activities of Java ORM code

15

Expect: ORM-related changes are localized

Expect: Frequently tuning configurations

Expect: Tooling support due to ORM

popularity

No! There is limited tooling

support

No! ORM configurations

are rarely tuned

Page 16: MSR2016 - An Empirical Study on the Practice of Maintaining Object-Relational Mapping Code in Java Systems

Studying maintenance activities of Java ORM code

16

Expect: ORM-related changes are localized

Expect: Frequently tuning configurations

Expect: Tooling support due to ORM

popularity

No! There is limited tooling

support

No! ORM configurations

are rarely tuned

Page 17: MSR2016 - An Empirical Study on the Practice of Maintaining Object-Relational Mapping Code in Java Systems

ORM code changes are more scattered

17

Series10

2

4

6

8

10

12

14

ORMnon-ORM

Med

ian

mod

ified

file

s in

a co

mm

it

Such high change scatteredness may be caused by ORM’s inability to completely

abstract DB accesses

Page 18: MSR2016 - An Empirical Study on the Practice of Maintaining Object-Relational Mapping Code in Java Systems

Studying maintenance activities of Java ORM code

18

Expect: ORM-related changes are localized

Expect: Frequently tuning configurations

Expect: Tooling support due to ORM

popularity

No! There is limited tooling

support

No! ORM configurations

are rarely tuned

No! ORM code changes are

more scattered

Page 19: MSR2016 - An Empirical Study on the Practice of Maintaining Object-Relational Mapping Code in Java Systems

19

Page 20: MSR2016 - An Empirical Study on the Practice of Maintaining Object-Relational Mapping Code in Java Systems

20

Page 21: MSR2016 - An Empirical Study on the Practice of Maintaining Object-Relational Mapping Code in Java Systems

21

Page 22: MSR2016 - An Empirical Study on the Practice of Maintaining Object-Relational Mapping Code in Java Systems

22

Page 23: MSR2016 - An Empirical Study on the Practice of Maintaining Object-Relational Mapping Code in Java Systems

23

Page 24: MSR2016 - An Empirical Study on the Practice of Maintaining Object-Relational Mapping Code in Java Systems

24

Page 25: MSR2016 - An Empirical Study on the Practice of Maintaining Object-Relational Mapping Code in Java Systems

25

Page 26: MSR2016 - An Empirical Study on the Practice of Maintaining Object-Relational Mapping Code in Java Systems

26

Page 27: MSR2016 - An Empirical Study on the Practice of Maintaining Object-Relational Mapping Code in Java Systems

27

Tse-Hsun (Peter) Chen [email protected]