Wallbox energy management system app for easy data visualization.
Table of Contents
About The Project
This project is an exercise for the interview process at Wallbox. The aim of this code is to show my personal expertise on several aspects of iOS development, including:
- Architecture: I chose MVVM as the project architecture given it’s suitable for small to medium sized projects and enables reactive programming seamlessly.
- SwiftUI/Combine are used in the app to allow the use of latest technologies from Apple (like Swift Charts) and reactive programming.
- It follows SOLID code principles, so for example in the networking layer protocols are used to uncouple the modules.
- Testing: The XCTest cases implemeneted cover a big part of the code, making it safer to maintain and refactor, increasing it’s quality.
To get a local copy up and running follow these simple steps:
- Xcode 14.0
- Swift 5.7
The project is prepared so everything you need to do is clone the repository, open the xcodeproj and run it.
You can run the unit tests with Cmd + U.
On the dashboard screen you will see the information from the EMS. If you tap on the Statistics view, you will navigate to the detail view containing the charts.
*By following the commits you can see the changes implied
- I started thinking about the architecture. As the project has a limited scope and I want to use some reactive code and tests, I chose MVVM as it allows SOLID principles with a limited code overload.
- First, I created the models and its unit tests.
- I also added the services, implementing protocols to keep the concrete implementations uncoupled and apply the dependency inversion principle.
- I added the tests for the services. At this point I had to leave some of the tests (related to the fetch functions) to a later moment due to time constraints.
- Then, with all the tests passing, I implemented the Views and ViewModels on top of the model and networking modules already created.
- At this point, I saw that it was possible to optimize the view models and reduce them to one. I started by extracting the ChartElement as a separate model object and the EnergySourceType to the common view model.
- Then I reduced the number of VMs to one. At that point, I saw that it was possible to improve this architecture by adding an extra layer. That would make it feel more like a MVVMC architecture (similar to VIPER but with MVVM naming), with an interactor dealing with networking code (fetch functions mainly). But again, due to the time constraints inherent to this kind of tests I couldn’t complete the refactor.
- Finally, I saw that I could improve the test coverage (from 70%) and implemented some new tests for the view models, incrementing it to 75%.
Distributed under the GNU General Public License v3.0. See
LICENSE.txt for more information.
Rubén Expósito Marín – [email protected]
Project Link: https://github.com/RubenEsposito/WallboxEMS
- You can check the exercise specs from this app here.