Is it anti-pattern to use protobuf’s tag numbers in the code for custom purposes?

I am developing a server-driven UI service in my company. I want to know your opinion on whether our approach is anti-pattern of protobuf usage or if it is valid usage even if it is not common.

Thank you for your time reading this long message!

All our APIs for Client(iOS,Android,Web) <-> backend are based on protobuf models, thats why we want to use protobuf for SDUI too.

We want to build a new service that will provide the View structure to the client, which has to be rendered. The client can cache only UI styling and layout, while another service provides the data for it.
Client app has to bind server data to view the structure. The client does not know the schema of the server response, except it is protobuf data.
View Structure and Backend data are protobuf models and use the same types – see examples below.

message Text {
 string label = 1;
  Color color = 2;
}
message VerticalStack {}
message HorizontalStack {}

/// Typical View Structure in protobuf representation
VerticalStack {
  spacing = 20pt
  children = [
   Text { 
     id: 11
     color: .white
    }
   HorizontalStack {
     children: ...
   }
  ]
}

Another service has to provide data for this view structure.

message BackendResponse {
  Text productTitle = 11;
}

BackendResponse schema is NOT known to the client.

We came with idea to use protobuf tag numbers for binding.
You can see that Text.id = 11 and BackendResponse.productTitle = 11

We built the autogenerated interfaces to safely set number 11 to the View structure and ensure that the backend response uses the property with number 11.

On the client
We recursively parse the View Structure and see id (aka tag number) key. We looking for data with same key in Backend response like data[tagNumber: 11] as bytes and merge with the current view (aka Text in the example).

The question of this post: even if it is not a common technique, is it known as anti-pattern?

These binding(tag numbers) numbers are used across the different code stacks:

  • View protos are known to clients, backend and separate DSL repository (repo with View structures)

  • Backend models are known to backend and DSL repository

  • DSL repository is TypeScript code

  • Backend is Go code

  • Clients are Swift, Kotlin, TypeScript/JS

Can the concept of extensions or custom options help us somehow? Do you know more appropriate way?

I was not able to find a similar usage of protobuf structures. We found that developers use descriptors and send whole descriptor models to work with dynamic messages or use FieldMask for filtering.
Using the whole descriptor sounds overkill for this purpose as we don’t need access by name or other field attributes. ID number is auto-injected to DSL by our generators.

New contributor

Yan Zaitsev is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật