3

What We Learned from Working with Modules: Summary

 2 years ago
source link: https://hackernoon.com/what-we-learned-from-working-with-modules-summary-3h1q37yx
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

What We Learned from Working with Modules: Summary

@kruglyakSasha Kruglyak

iOS Teck Lead. I work at TRIARE.net

In part 1, we reviewed the work with modular architecture in depth. In this article, I want to finalize our findings.

0 reactions
heart.png
light.png
money.png
thumbs-down.png

Key takeaways from Modular Architecture:

  • The diversity of projects on MVC, MVVM and other legacy code peculiarities can leave you knackered, while modules offer clarity.
  • The seams need to be sustained, and the best way is to separate logic.
  • Modules contribute to a unified approach, well-coordinated teamwork, and delineated areas of responsibility.
  • Modules help with iterations and adjusting to new requirements.
  • The amount of extraneous code is reduced.
  • There’s a ready-made foundation for each new project.
  • The most important benefit of modules is independence.
  • Of course, there are disadvantages, but they're easy to get used to.  

Why did we begin to use modules?

We have received many projects built on various architectures. So, every time, we’ve put a lot of effort to sort the code out. Projects have their peculiarities depending on the country they come from. For some reason, many have half of their legacy code in Objective C and the other half in Swift. In all the cases, clients want to introduce changes to the existing code, which is really hard to maintain.

0 reactions
heart.png
light.png
money.png
thumbs-down.png

The seams we were trying to save and sustain were cut all the time, so we had to create little pieces of code to glue it together. Thus, we were changing the architecture. It led us to the idea of taking those pieces out into separate files, to mark our areas of responsibility in case something went wrong.

0 reactions
heart.png
light.png
money.png
thumbs-down.png

These factors led us to modules, code standardization, and the habit of writing and reading code correctly. The seams were taken out in separate modules, and problems with functional tasks were solved in isolation.

0 reactions
heart.png
light.png
money.png
thumbs-down.png

That is when we started to realize the many benefits of modular design.

0 reactions
heart.png
light.png
money.png
thumbs-down.png

Let’s analyze the pros!

From time to time, developers make rotations between projects, which are built on different architectures. Areas of responsibility on monoliths are not explicit – while modules are clear cut. A unified approach also made onboarding newcomers easier. We use one style when writing a module, and learn to speak one language when writing the docs.

0 reactions
heart.png
light.png
money.png
thumbs-down.png

Worthy to note, that each module can have a different implementation approach – and this does not affect the overall structure. As long as it passes code review, and everyone’s satisfied. The only caveat being the necessity to arrange the correct access levels. There should only be one module “owner” to make decisions. Such a system teaches developers not to be lazy and decreases stress levels.

0 reactions
heart.png
light.png
money.png
thumbs-down.png

Modules help iterations. We create a scheme of modules and their splices at the very beginning of the project, before accumulating the code inside each module. Firstly, it prevents harm to the project in case there's a mistake inside one module. Secondly, iteration helps when developing large projects with fast vector changes. Modules are interchangeable, which means that we can adjust the business value at any time.

0 reactions
heart.png
light.png
money.png
thumbs-down.png

In addition, we have reduced the amount of extraneous code. Over time, after developing 10+ modules, we began to cover the functionality that usually comes from the libraries: onboarding, REST API, ImagePickers, ColorPickers, etc.

0 reactions
heart.png
light.png
money.png
thumbs-down.png

Each new project has a ready-made foundation, so we can switch between them quickly. Therefore, we decrease the time for estimation at the beginning.

0 reactions
heart.png
light.png
money.png
thumbs-down.png

What is the benefit of modular design?

If you asked me about one most important benefit – it's independence. When I need to introduce very quick changes to see the big picture, I can sketch something and come back later to polish it. That's common practice among developers. Even if the module is written badly on the inside, it will perform well on the outside due to the predetermined splices with other parts of the project.

0 reactions
heart.png
light.png
money.png
thumbs-down.png

What are the disadvantages of modular programming?

  • When transitioning to modular programming, you will have to be patient and habituate yourself to describe the code and documentation.
  • You need to cultivate a vision of dependencies, learn to define and divide functionality in modules.
  • Also, it is necessary to keep modules up-to-date both in the main project and in the module repository.
  • Since each module is a separate framework, you’ll have to define an integration path for SPM / CocoaPods / .framework.
  • The developer on the team should not distract the module developer. A module is considered dead if there are no docs.

Our experience in modular programming

We have created six active modular applications and 10+ modules that continue to be intensively developed (in various independent projects). The benefits of a modular approach to app development have been clear:

0 reactions
heart.png
light.png
money.png
thumbs-down.png
  • The speed of initialization of projects and development has been increasing due to the accumulation of ready-made code.
  • Developers transmit knowledge via the description of the module code and documentation.
  • A new navigation module has been built that covers the Router's needs and weaknesses (check how it looks in the previous article).
  • Integration of tests, implementation of TDD have been simplified.
  • Code always remains up-to-date due to module reuse. It saves days on updating projects that have been on a long stand-by.
  • It’s easier for developers to switch between projects and tasks, the bus factor is reduced.

To sum up

When I first started learning about modules, everything seemed too complicated. Now I can tell you it’s not. I want my team to develop code – easily. No complicated architectures that take 5-6 hours to deploy. No projects with legacy code taking 8 hours daily to maintain.

0 reactions
heart.png
light.png
money.png
thumbs-down.png

A project must be simple for every team member as well as for external use. To me, that's the key to developing quality code and creating successful projects.

0 reactions
heart.png
light.png
money.png
thumbs-down.png

Also published on: https://triare.net/insights/modular-architecture-2/

0 reactions
heart.png
light.png
money.png
thumbs-down.png
3
heart.pngheart.pngheart.pngheart.png
light.pnglight.pnglight.pnglight.png
boat.pngboat.pngboat.pngboat.png
money.pngmoney.pngmoney.pngmoney.png
by Sasha Kruglyak @kruglyak. iOS Teck Lead. I work at TRIARE.netRead my stories
Join Hacker Noon

Create your free account to unlock your custom reading experience.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK