Abstract
Clean Architecture (CA) aims to address the need for more loosely coupled components and better cohesion. CA focuses on preparing software engineers to write more stable, durable, and flexible applications capable of distinguishing between details (e.g., what framework it uses) and the business logic requirements. A literature review shows that considerable effort has been devoted to cataloging and solving code smells related to code, often called code smells. However, the same does not apply to architecture smells – its software architecture counterpart. Similar research regarding other programming languages such as Java, PHP, or C# represents noteworthy works in the area, but they do not address Python applications directly. This work directs efforts towards redesigning and adapting existing Python programs to the CA principles by detecting the code smells that break the CA constraints through the developed CALint tool. Moreover, this approach proposes two extended refactoring techniques to solve these smells efficiently by grouping and comparing static code analysis and reuse them to enforce Clean Architecture’s Dependency Rule programmatically. To demonstrate the feasibility of the two refactoring techniques described in this work and the CALint tool, we applied them to three different case studies. The major findings of this work include two extended refactoring techniques and the development of a tool to verify non-conformities related to the Clean Architecture dependency rule. The results show common cases where the dependency rule was violated and highlighted by the CALint tool, which are fixed with the support of refactoring steps.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
References
Beltrão, A., Farzat, F., Travassos, G.: Technical debt: a clean architecture implementation. In: Anais Estendidos do XI Congresso Brasileiro de Software: Teoria e Prática. SBC, Porto Alegre, RS, Brasil, pp. 131–134 (2020). https://doi.org/10.5753/cbsoft_estendido.2020.14620. https://sol.sbc.org.br/index.php/cbsoft_estendido/article/view/14620
Bui, D.: Reactive programming and clean architecture in Android development. Metropolia Ammattikorkeakoulu (2017)
Chen, T.H., et al.: An empirical study on the practice of maintaining object-relational mapping code in Java systems. In: 2016 IEEE/ACM 13th Working Conference on Mining Software Repositories (MSR), pp. 165–176. IEEE (2016)
Cockburn, A.: Hexagonal architecture (2005). https://alistair.cockburn.us/hexagonal-architecture/
Ferrante, J., Ottenstein, K.J., Warren, J.D.: The program dependence graph and its use in optimization. ACM Trans. Program. Lang. Syst. (TOPLAS) 9(3), 319–349 (1987)
Fontana, F.A., Pigazzini, I., Roveda, R., Tamburri, D., Zanoni, M., Di Nitto, E.: Arcan: a tool for architectural smells detection. In: 2017 IEEE International Conference on Software Architecture Workshops (ICSAW), pp. 282–285. IEEE (2017)
Python Software Foundation: Python language reference, modules (2022). https://docs.python.org/3/tutorial/modules.html
Fowler, M.: Refactoring: Improving the Design of Existing Code. Addison-Wesley, Reading (1999)
Garcia, J., Popescu, D., Edwards, G., Medvidovic, N.: Toward a catalogue of architectural bad smells. In: Mirandola, R., Gorton, I., Hofmeister, C. (eds.) QoSA 2009. LNCS, vol. 5581, pp. 146–162. Springer, Heidelberg (2009). https://doi.org/10.1007/978-3-642-02351-4_10
Giordani, L.: Clean Architectures in Python, 2nd edn. Leanpub (2018). https://leanpub.com/clean-architectures-in-python
Guo, Y., et al.: Tracking technical debt - an exploratory case study. In: ICSM 2011: Proceedings of the 2011 27th IEEE International Conference on Software Maintenance, pp. 528–531, September 2011. https://doi.org/10.1109/ICSM.2011.6080824
Heumsi: Python clean architecture example (2020). https://github.com/heumsi/python-clean-architecture-example
Hotta, K., Higo, Y., Kusumoto, S.: Identifying, tailoring, and suggesting form template method refactoring opportunities with program dependence graph. In: 2012 16th European Conference on Software Maintenance and Reengineering, pp. 53–62. IEEE (2012)
Louden, K.C.: Compiler Construction. Cengage Learning, Boston (1997)
Martin, R.C.: Clean Architecture: A Craftsman’s Guide to Software Structure and Design. Robert C. Martin Series. Prentice Hall, Boston (2017). https://www.safaribooksonline.com/library/view/clean-architecture-a/9780134494272/
Microsoft:net microservices - architecture e-book (2021). https://docs.microsoft.com/en-us/dotnet/architecture/microservices/microservice-ddd-cqrs-patterns/infrastructure-persistence-layer-design
Milojkovic, N., Ghafari, M., Nierstrasz, O.: It’s duck (typing) season! In: 2017 IEEE/ACM 25th International Conference on Program Comprehension (ICPC), pp. 312–315. IEEE (2017)
Prajapati, M., et al.: ASP.NET MVC-generic repository pattern and unit of work. Int. J. All Res. Writ. 1(1), 23–30 (2019)
Razina, E., Janzen, D.S.: Effects of dependency injection on maintainability. In: Proceedings of the 11th IASTED International Conference on Software Engineering and Applications, Cambridge, MA, p. 7 (2007)
Rhodes, B.: The clean architecture in Python (2014). https://archive.org/details/pyvideo_2840___The_Clean_Architecture_in_Python
Rizzi, L., Fontana, F.A., Roveda, R.: Support for architectural smell refactoring. In: Proceedings of the 2nd International Workshop on Refactoring, pp. 7–10 (2018)
Velasco-Elizondo, P., Castañeda-Calvillo, L., García-Fernandez, A., Vazquez-Reyes, S.: Towards detecting MVC architectural smells. In: Mejia, J., Muñoz, M., Rocha, Á., Quiñonez, Y., Calvo-Manzano, J. (eds.) CIMPS 2017. AISC, vol. 688, pp. 251–260. Springer, Cham (2018). https://doi.org/10.1007/978-3-319-69341-5_23
Acknowledgments
The authors would like to thank the São Paulo Research Foundation (FAPESP) grant 2018/22064-4 – for financial support.
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2022 The Author(s), under exclusive license to Springer Nature Switzerland AG
About this paper
Cite this paper
de Oliveira Junior, C.O., Carvalho, J., Silveira, F.F., da Silva, T.S., Guerra, E.M. (2022). CALint: A Tool for Enforcing the Clean Architecture’s Dependency Rule in Python. In: Gervasi, O., Murgante, B., Misra, S., Rocha, A.M.A.C., Garau, C. (eds) Computational Science and Its Applications – ICCSA 2022 Workshops. ICCSA 2022. Lecture Notes in Computer Science, vol 13381. Springer, Cham. https://doi.org/10.1007/978-3-031-10548-7_39
Download citation
DOI: https://doi.org/10.1007/978-3-031-10548-7_39
Published:
Publisher Name: Springer, Cham
Print ISBN: 978-3-031-10547-0
Online ISBN: 978-3-031-10548-7
eBook Packages: Computer ScienceComputer Science (R0)