Onion architecture design question

I recently started working on a new project where the team was considering use onion architecture, which I was not very familiar with, so I started reading about it.

The application is a simple 3D format converter. It will read a sql database, convert the data and then write the new format in another MySql database. The first database is very complex itself, but I don’t think it’s mather. The application concept is very simple: read from A, convert, write to B. I won’t have any services or special infrastructure for it.

It will be a desktop application.

Based on these facts, I ask:

  1. Everything I read about onion is related to web applications. Is there any special reason why it’s not very popular in a desktop application?

  2. I also read it’s most indicated in complex enterprises. Will would it be effective and have practical advantages on such a simple application?

  3. If we go for the onion path, what would be in the domain layer? Please fell free to comment the following layers:

    L1) Source Layer: will represent the data in the source database
    L2) Output Layer: will represent the data in the output database
    L3) Database Reader Layer: will be responsible for reading source database and populate Layer 1
    L4) Converter Layer: will be an adapter that will receive Layer 1 and populate Layer 2 with the converted data
    L5) Database Writer Layer: will write the Layer 2 to database

    Would layers 1 and 2 be the my domain layer?
    Would layers 3 and 5 be infrastructure?
    And layer 4 would be an application or domain service?

3

I’m not so sure that the onion architecture makes much sense in this case.

What you can keep from the onion architecture is the principle that your application core (the translators) should be decoupled from the data access. But overall your requirement is much more like a pipeline.

read -> transform -> write

Now, read and write are impure (difficult to test). Transform could be pure (easy to test) if it does not call write directly. So if you decouple by having the core of your app (transform) return the data to be written, or publish to a queue/observable/bus, then you’ve effectively isolated your core and made it testable. This is the principle of the onion architecture.

About your questions:

  1. Typically nowadays server applications have complex business logic, but there’s no reason why the pattern should not apply to any other type application

  2. There are always benefits to separating core functionality from interfaces to other systems

  3. The domain layer would be the business entities that your DBs ultimately are meant to represent

Whether or not you choose to have a “common” object type, and 2 object types that more closely resemble the representation in your database, in my opinion, is a possibility but not a strict requirement; it just depends on the type of data. You could use your relational model as domain model, and convert to the denormalized model. (I see many applications that duplicate identical objects across layers, ending up with lots of representations for the same data; this is not a good design IMO.)

Your Input Database and your Output Database are each at Layer 1.

Layer 2 will contain two Translators, one for each Database at Layer 1, that translates between the particular database objects and a “common” (or “universal”) object type.

Layer 3, your “application”, manipulates the common objects.

You could view this as a pipeline bent into a “U” shape.

2

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