Date post: | 24-Jan-2018 |
Category: |
Technology |
Upload: | mauricio-aniche |
View: | 199 times |
Download: | 2 times |
CodequalityinMVCsystems
Maurício Aniche@mauricioaniche
60kand110klinesofJavacode!
Me beautifulcode
5
Sugarlevel150[70,120]
6
Coupling10<15
Howtofindthisnumber?
7
Benchmarking
Benchmarkin Controllers
8
Why? theirownconcernseachpartofthearchitecture
has!
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.
11
Expertsexplained to us
SATT for the rescue12
13
14
Talktodevelopersyoushould,youngpadawan!
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.
16
Theyareindeedbad…(pronetochangeandtodefects)
Itindeedbecameatool!
17
Bettercodehub likeit!J
Database-centriccodeBecauseinthewrong
place,theyare!It’sveryhardtofindsomeSQLqueriesinmycodebase…
Project #ofclasses
#ofcommits
#ofDAOs #ofmethods
Gnarus 924 10451 39 233
Caelumweb 1321 12077 81 590
There aremany queries!
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?
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?
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.
PhilCalçado just(re-)bloggedaboutit!
http://philcalcado.com/2010/12/23/how_to_write_a_repository.html
TestcodestabilityNothappenitshould!
Wehatesystemtestingbecausewehavetorewritethem
often!
Largeseleniumcodeis!
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.
Thanks!@mauricioaniche
YoungmeworkingonalowqualitycodethatIwrotemyselfat
myfirstinternationalproject(DominicanRepublic,2006).
Sorryaboutmyhair.
Mybossesdoingpeerpress…oops,pairprogramming!