code smells in mvc applications (dutch spring meetup)
TRANSCRIPT
CodesmellsinMVCsystemsMaurício Aniche@mauricioaniche
https://www.aluguetemporada.com.br/imovel/p4086968
A catalogueof smells
specific to MVC(after talking to 20+70 developers)
10
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.
29
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.
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?
Project #ofclasses
#ofcommits
#ofDAOs #ofmethods
Gnarus 924 10451 39 233
Caelumweb 1321 12077 81 590
There aremany queries!
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.
A catalogueof patterns
43
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.
Thesolution?
Howtomeasurereadability,easetomaintain,easetotest,easefor
someoneelsetostarttomaintain,etc,howmuchitslowsmedown?
AnswersIdon’thave…