当前位置:网站首页>Bypass technology to talk about 'cross end'

Bypass technology to talk about 'cross end'

2022-06-25 16:22:00 InfoQ

Come to the point , I know that many industry leaders or organizations are deeply involved in cross end development , My little brother is not very talented , No posturing at the technical level , Let's bypass technology today 、 Just talk about cross end development from the perspective of architecture .

The essence of cross - end is reuse

Is cross - end development difficult ? It's not hard at all , You are rich and powerful. You can recruit a group of people to develop at each end , How many ends are not a matter . So we're talking about how to save labor costs across the end 、 Time cost “ Cross end reuse ”.

This is an open topic , It's not just about development technology , You can talk about architecture ideas , Even team management 、 We can also talk about resource allocation ...

Why not cross the end

Let's go back and think about why applications can't cross end ? Thinking logic knows no borders , You can use any language to describe and express , and Javascript The runtime is also widely supported by a variety of operating platforms , It should not be difficult to cross the end .

This
The magic barrier is UI/UE
, This is an emotional thing 、 It's flexible 、 There is no standard, but also the pursuit of individuality . Each end adheres to its own user habits 、 Design style 、 The traditional culture 、 Personality expression 、 Default optimization 、 Dialect conventions, etc , This is no longer a matter of technology , Even if you force it flat , We can only attend to one thing and lose the other ...

Why back-end interfaces don't need cross - end development ?( Even if it is necessary, it is just a BFF Adaptive layer ). Because the back end is business logic oriented development , The front end is oriented to UI Interface development .

So the simplest cross end idea is :

Facing directly UI Personalization of , Base this layer on the perceptual 、 Peel off non-standard things , And make it as thin as possible .

From idealism to realism

although
Write once run anywhere...
It is a dream pursued by many people , But I don't like it , Because even if you do , You may also lose platform optimization 、 Lose your individuality 、 Become a second-class citizen in the platform ecology .

Then retreat to the next place
Learn Once, Write Anywhere...
, Not so perfect , Can reuse
Business logic
Their thinking
Apply skeleton
Core code
, It is also a matter of contentment .

From business logic to domain model

What is the core of the application ? It's the rules of the game , yes
Business logic
, No matter how the running platform of an application changes , Its business logic is always the same . If we further domain model the business logic , Get rid of those fancy decorations 、 Make the business model abstract 、 pure 、 Refine , Then we will get the most valuable 、 The most stable and firm 、 The core logic that can be applied everywhere .

as for UI Performance should be personalized ? Be platform oriented ? Then make a beautiful coat again ...

null

UI Functions

UI Only 2 individual : Input and output , That's it . It is the collector of instructions and the feedback of results , It should not be the executor of the instruction .

When you follow this line , that UI layer /UI The frame doesn't matter . I posted an article a few days ago :
Artillery command , Don't let one UI The frame has ruined you
, The excessive dependence of the front end UI frame , hold UI The framework acts as the skeleton of the application , This leads to code confusion , The coupling is tight 、 It makes your application more generic .

How to land

The key is to have a layered architecture , decoupling UI Logic and business logic 、 Write thin UI layer :

  • First , With the help of a cross platform MVC The framework is layered .
  • secondly , When writing code, be careful not to face UI The incident is over , Change to business action oriented .
  • Last , Take business logic from UI Completely removed from the layer .

We can refer to :
Artillery command , Don't let one UI The frame has ruined you
, Mainly :

  • from  State  To  Model
  • from  Event  To  Action

Examples demonstrate

Last , In order to prove that this idea is not on paper , Take a look at my open source framework :
Elux- be based on “ Micro module ” and “ Model driven ” cross-platform 、 Cross framework 『 Isomorphic schemes 』
, It is designed based on the above ideas . have access to React/Vue/ Other third-party frameworks , Can be used for development :Web( browser )、Micro( Microfront )、SSR( Server render )、MP( Applet )、APP( Mobile phone application ).

Installation method :

npm create [email protected]  or  yarn create elux

Applet development uses by default TaroJS, The principle is to put TaroJS As a third party UI frame , Theoretically uni-app Or others can be accessed :

@elux/[email protected]
New projects : /Users/hiisea/work/elux/aaa
totally [44P] templates are pulled from ...

?  Please select platform architecture  
 CSR:  Browser based rendering applications  [16P] 
 SSR:  Server based rendering  +  Isomorphic application of browser rendering  [8P] 
 Micro:  be based on Webpack5 Micro front end  +  Micro module scheme  [8P] 
* Taro:  be based on Taro Cross platform application of ( Various small programs ) [8P] 
 RN:  be based on ReactNative The native APP( In development ...) [4P] 

throw away a brick in order to get a gem , You may not really use it , But it may bring you new ideas ...
原网站

版权声明
本文为[InfoQ]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/176/202206251532220306.html