0

I have searched a lot through internet read so many Article but couldn't find even a single answer to my question, that exactly which design pattern[MVC, MVP, MVVM, VIPER] should I use in my watch OS app.

I have a fitness app which tracks the running and show the calories, pace distance and the path followed while running for both iPhone and Apple watch. My iPhone app is well managed as I have used the MVVM but I didn't have any idea how to make my code more modular in case of watch. As my WKInterfaceController Class are extensively heavy and It is really painful to code in unstructured way.

Please help me understand how can I make my code more standard and structured.

Thanks in Advance

1 Answers1

0

I think it's pretty well to you that's you discover your code must be better. when developers face this, there are ready to know more about architecture and writing better code and structure.

I think its not about just a specific design pattern. It's about Architecture and the project structure.

Beforehand, Developers used three separate layers in the project to separate presentation, logic(BLL), and database(DLL) from each other for a more well-organized structure. It just helps us to make everything around the database, But nowadays, developers have been encouraging to put everything around the domain(CORE). The domain is your business elements and everything around your business is details such as third-party services, database, and so on.

There are some specific names for this architecture such as onion, Port-adapters, Hexagonal and etc. All of this structure recommends us to put all of your domain things like Domain objects and others in the center of the project and anything else is around there.

I prefer to follow Uncle Bob naming which is "Clean architecture" that he describes it in his book "Clean Code: A Handbook of Agile Software Craftsmanship".

according to "Robert C.Martin" (Uncle Bob) descriptions, your architecture must be and screaming architecture It means everything in your architecture must be screamed when you see your architecture and anything must be clear. I highly recommend reading more about "Clean Architecture" Book. There is also many samples project on Github that implement the clean architecture.

on the other hand, all of your dependency must be injected to your layers but following this rule, Help you to use tests! the test and TDD pattern is very important two to develop and mitigate project bugs.

moreover, To increase your code readability and keep it clean it's very important to write "Clean Code" and also it needs to obey S.O.L.I.D principle rules. to achieve this goal I highly recommended reading "Clean Code" by Uncle Bob. there is a good brief of clean code rules in Java.

For the last word, I'd like to say it's very important to know more about gang of four design patterns. it helps us to solve common problems in code with beautiful well-known solutions. For more information, you can see here.

you can search more and find better things. Be success with your new code style ;)

Mohammad
  • 1,197
  • 2
  • 13
  • 30
  • Currently I have using MVVM and VIPER for iOS app, but as the watch features are limited and I couldn't find anything for watch, that's what the question. If you had ever developed any watch app you would have understand how heavy the code becomes due to limited features in watch development. So my simple question is that which design patter should I use, I am well aware of the design patter and it's advantage. So please if you have done some work on watch app, please do tell me which you followed. – VIJAY SINGH RAGHAV Sep 13 '20 at 18:08