+ All Categories
Home > Technology > Code quality in MVC systems - BENEVOL 2016

Code quality in MVC systems - BENEVOL 2016

Date post: 24-Jan-2018
Category:
Upload: mauricio-aniche
View: 199 times
Download: 2 times
Share this document with a friend
29
Code quality in MVC systems Maurício Aniche @mauricioaniche
Transcript
Page 1: Code quality in MVC systems - BENEVOL 2016

CodequalityinMVCsystems

Maurício Aniche@mauricioaniche

Page 2: Code quality in MVC systems - BENEVOL 2016
Page 3: Code quality in MVC systems - BENEVOL 2016

60kand110klinesofJavacode!

Page 4: Code quality in MVC systems - BENEVOL 2016

Me beautifulcode

Page 5: Code quality in MVC systems - BENEVOL 2016

5

Sugarlevel150[70,120]

Page 6: Code quality in MVC systems - BENEVOL 2016

6

Coupling10<15

Howtofindthisnumber?

Page 7: Code quality in MVC systems - BENEVOL 2016

7

Benchmarking

Page 8: Code quality in MVC systems - BENEVOL 2016

Benchmarkin Controllers

8

Page 9: Code quality in MVC systems - BENEVOL 2016

Why? theirownconcernseachpartofthearchitecture

has!

Page 10: Code quality in MVC systems - BENEVOL 2016

10

Quantiles

Coup

ling(CBO

)

Aniche, M., Treude, C., Zaidman, A., van Deursen, A., Gerosa, M.A., “SATT: Tailoring Code Metric Thresholds for Different Software Architectures”. 16th IEEE International Working Conference on Source Code Analysis and Manipulation, 2016.

Page 11: Code quality in MVC systems - BENEVOL 2016

11

Expertsexplained to us

Page 12: Code quality in MVC systems - BENEVOL 2016

SATT for the rescue12

Page 13: Code quality in MVC systems - BENEVOL 2016

13

Page 14: Code quality in MVC systems - BENEVOL 2016

14

Talktodevelopersyoushould,youngpadawan!

Page 15: Code quality in MVC systems - BENEVOL 2016

A catalogueof smells

specific to MVC(after talking to 50 developers)

15

Grrrrrr…Controllers that offer many

servicesGrrrr…

Repositories that deal with many Entities

Grrrrr…

Aniche, Maurício, Bavota, Gabriele, Treude, Christoph, van Deursen, Arie, Gerosa, Marco.“A Validated Set of Smells in Model-View-Controller Architecture”. Software Maintenance and Evolution (ICSME), 2016, 32th International Conference, IEEE, 2016.

Page 16: Code quality in MVC systems - BENEVOL 2016

16

Theyareindeedbad…(pronetochangeandtodefects)

Page 17: Code quality in MVC systems - BENEVOL 2016

Itindeedbecameatool!

17

Page 18: Code quality in MVC systems - BENEVOL 2016

Bettercodehub likeit!J

Page 19: Code quality in MVC systems - BENEVOL 2016

Database-centriccodeBecauseinthewrong

place,theyare!It’sveryhardtofindsomeSQLqueriesinmycodebase…

Page 20: Code quality in MVC systems - BENEVOL 2016

Project #ofclasses

#ofcommits

#ofDAOs #ofmethods

Gnarus 924 10451 39 233

Caelumweb 1321 12077 81 590

There aremany queries!

Page 21: Code quality in MVC systems - BENEVOL 2016

Queriescan get complicated!SELECT

p.name as project,c.id as commitId,a.name as artifactName,a.path as artifactPath

FROMProjects p

JOIN Commits c ON c.project_id = p.id

JOIN Artifacts a ON a.commit_id = c.id

WHEREp.repository = ’Apache’;

WhereshouldIput

it?

Page 22: Code quality in MVC systems - BENEVOL 2016

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

}

Bythemethodsignatureswe

should!

Whereshouldwestart?

Page 23: Code quality in MVC systems - BENEVOL 2016

Project #ofDAOmethods

#of”correct”methods

#of”wrong”methods

%ofwrongmethods

Caelumweb 590 511 79 13.38%

Gnarus 233 200 33 14.16%

Project #ofinspectedmethods

#ofagreement

%ofagreement

Caelumweb 79 59 74.68%

Gnarus 33 16 48.48%

Aniche, Maurício F., Gustavo A. Oliva, and Marco A. Gerosa. “Are the Methods in Your Data Access Objects (DAOs) in the Right Place? A Preliminary Study.”. 6th Workshop on Managing Technical Debt, in conjunction with ICSME2014, Canada. Short paper.

Page 24: Code quality in MVC systems - BENEVOL 2016

PhilCalçado just(re-)bloggedaboutit!

http://philcalcado.com/2010/12/23/how_to_write_a_repository.html

Page 25: Code quality in MVC systems - BENEVOL 2016

TestcodestabilityNothappenitshould!

Wehatesystemtestingbecausewehavetorewritethem

often!

Page 26: Code quality in MVC systems - BENEVOL 2016

Largeseleniumcodeis!

Page 27: Code quality in MVC systems - BENEVOL 2016

A catalogueof patterns

27

Fixture APIID in HTML

Move Fast, Move Slow…

Aniche, M., Guerra, E., Gerosa, M. “A Set of Patterns to Improve Code Quality of Automated Functional Tests of Web Applications”. 21th Conference on Pattern Languages of Programs. 2014.

Page 28: Code quality in MVC systems - BENEVOL 2016
Page 29: Code quality in MVC systems - BENEVOL 2016

Thanks!@mauricioaniche

YoungmeworkingonalowqualitycodethatIwrotemyselfat

myfirstinternationalproject(DominicanRepublic,2006).

Sorryaboutmyhair.

Mybossesdoingpeerpress…oops,pairprogramming!


Recommended