Are the Methods in Your DAOs in the Right Place? A Preliminary - - PowerPoint PPT Presentation

are the methods in your daos in the right place
SMART_READER_LITE
LIVE PREVIEW

Are the Methods in Your DAOs in the Right Place? A Preliminary - - PowerPoint PPT Presentation

Are the Methods in Your DAOs in the Right Place? A Preliminary Study Maurcio Aniche Gustavo Oliva Marco Aurlio Gerosa What are DAOs ? public class InvoiceDAO { @Inject private EntityManager em; public List<Invoice> getAll() {


slide-1
SLIDE 1

Are the Methods in Your DAOs in the Right Place?

A Preliminary Study

Maurício Aniche Gustavo Oliva Marco Aurélio Gerosa

slide-2
SLIDE 2

What are

DAOs ?

slide-3
SLIDE 3

public class InvoiceDAO { @Inject private EntityManager em; public List<Invoice> getAll() { String sql = "select … from Invoice where ..."; return em.createQuery(sql).getResultList(); } public void save(Invoice inv) { em.save(inv); } }

slide-4
SLIDE 4

They can get complicated!

SELECT p.name as project, c.id as commitId, a.name as artifactName, a.path as artifactPath FROM Projects p JOIN Commits c ON c.project_id = p.id JOIN Artifacts a on a.commit_id = c.id WHERE p.repository = ’Apache’;

slide-5
SLIDE 5

They can get complicated!

SELECT p.name as project, c.id as commitId, a.name as artifactName, a.path as artifactPath FROM Projects p JOIN Commits c ON c.project_id = p.id JOIN Artifacts a on a.commit_id = c.id WHERE p.repository = ’Apache’;

Belongs to ProjectDAO?

slide-6
SLIDE 6

… and more complicated!

SELECT p.name as project, c.id as commitId, a.name as artifactName, a.path as artifactPath FROM Commits c JOIN Projects p ON c.project_id = p.id JOIN Artifacts a on a.commit_id = c.id WHERE p.repository = ’Apache’;

  • r CommitDAO?
slide-7
SLIDE 7

… and more complicated!

SELECT p.name as project, c.id as commitId, a.name as artifactName, a.path as artifactPath FROM Commits c JOIN Projects p ON c.project_id = p.id JOIN Artifacts a on a.commit_id = c.id WHERE p.repository = ’Apache’;

ArtifactDAO!

slide-8
SLIDE 8

Where

to put this query?

slide-9
SLIDE 9

finding the right place is

very problematic!

modularity violation = bugs duplicated code spend time searching

slide-10
SLIDE 10

How can one automatically identify methods that may have been placed in the wrong or in ambiguous DAOs ?

RQ:

slide-11
SLIDE 11

Heuristic Implement a Tool Select Projects Qualitative Analysis

Research Design

slide-12
SLIDE 12

the heuristic

basically looks to

the method signature!

public class InvoiceDAO { public Invoice findById(int id) { … } public ShoppingCart find(User u) { … }) public List<Invoice> getAll() { … } public void save(Invoice inv) { ...} }

slide-13
SLIDE 13

the projects were...

Project # of classes # of commits # of DAOs # of methods Gnarus 924 10451 39 233 Caelumweb 1321 12077 81 590 Codesheriff 56 339 10 70

java web MVC VRaptor Hibernate unit tested

slide-14
SLIDE 14

and the heuristic found out...

Project # of DAO methods # of right methods # of wrong methods % of wrong methods Caelumweb 590 511 79 13.38% Codesheriff 70 57 13 18.57% Gnarus 233 200 33 14.16%

slide-15
SLIDE 15

the developers agreed!

Project # of inspected methods # of agreement % of agreement Caelumweb 79 59 74.68% Codesheriff 13 8 61.53% Gnarus 33 16 48.48%

slide-16
SLIDE 16

What

have we learned?

A quick and cheap approach to identify methods in wrong DAOs

Filters 13% to 18% of all methods and it is correct 50% to 75% of the cases

slide-17
SLIDE 17
  • Only three projects
  • Point of view of a single developer
  • We only validated the ones the

heuristic has selected

Threats to Validity

slide-18
SLIDE 18
  • Understand the cost of this TD
  • Improve the heuristic

What

are the next steps?

slide-19
SLIDE 19

maurício aniche (aniche@ime.usp.br) gustavo oliva (goliva@ime.usp.br) marco gerosa (gerosa@ime.usp.br)

Thank you!