Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
161 views
in Technique[技术] by (71.8m points)

.net - How to avoid delivering unnecessary inner layer code with an installable client app?

In Onion Architecture, business logic lives in an inner layer. So it can be referenced by outer layers like the UI, in my case a Web App.

Now I want to create a small companion app that users can install on their phones or computers. Naturally, I'll need a few bits from the business logic, so I'd have to reference the inner circle in my companion app. This would also mean that my whole inner layer will be installed on my users devices Even only a small part of that layer is really used. I have some concerns with that approach:

  1. Some business logic (not used in the companion app) is "secret". Or at least I don't want to expose it like that on a silver plate.
  2. The companion app should be as lightweight as possible. Why deliver code that won't be executed anyway?

I thought about splitting the inner layer into two assemblies. One containing only the stuff needed in the companion app and the other with the rest. I think technically that would work, but it feels wrong because currently there is one clear place for business logic and in future there would be two. And where does it end? What if I had another app, which needs logic from the companion-app-specific assembly?

question from:https://stackoverflow.com/questions/65910389/how-to-avoid-delivering-unnecessary-inner-layer-code-with-an-installable-client

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

This would also mean that my whole inner layer will be installed on my users devices Even only a small part of that layer is really used.

Business logic should not be shipped as part of UI. Rather, it should be packed as a set of APIs inside a secured space of yours which makes it much easier to manage restrictions you mentioned.

This way, for example, companion app access a small set of APIs you have defined.

Also, size of code being delivered becomes no issue since you only deliver UI.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...