How to reduce the coupling __ data structure of the platform and business data structures

Source: Internet
Author: User
Tags data structures

Issue background:

The modules of the system are divided into the platform and the business, respectively maintaining the respective code by the Platform group and the business group.

typedef struct PLAT_CONTAINER

{

int A1; /* Platform with */

int A2; /* Platform with */

....

int *p_an; /* Platform with */

int serv11; /* Business 1 Use */

int SERV12;/* Business 1 Use */

.....

int SERVN; /* Business N Use */

}plat_container_s;

As mentioned above, the large number of business data ingestion leads to a very large data structure. Above is an example, in fact certainly more complex, there are pointers and concurrency protection mechanism.

The following disadvantages:

1, the data structure is huge, the maintainability is poor

2. A large number of businesses may generate coupling through this data structure and platform.

Such a large amount of business data into the plug, as we eat hot pot constantly to add material, so I laughed that this data structure is "hot pot mode."

This data structure may be a lot of people are accustomed to, are so written, not afraid of jokes, I am now the project team is doing so, so I want to do an experiment to optimize this data structure,

Reduce the coupling of this business and platform.

My idea is as follows:

typedef struct PLAT_CONTAINER

{

int A1; /* Platform with */

int A2; /* Platform with */

....

int *p_an; /* Platform with */

struct list serv_list; /* Business chain, the business can be dynamically expanded, of course, you can also consider using a specified length of the array, such as support for up to 1024 business features */

}plat_container_s;

The platform provides the business registration interface, when the business is initialized, calls the interface platform to allocate space for the business, and then returns the memory address to the business. Platform to hang the business node in the platform lock maintenance

The Business chain list. After the business gets the memory space allocated by the platform, the love stores what data to place with the business. Business data is completely transparent to the platform. The platform also does not see the data structure of the business.

This is my idea, and I seldom see anyone doing that. So send to discuss with you, if you have a better implementation then welcome advice.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.