Software engineering technical problem (2)

zhaozj2021-02-16  41

The interface signed a contract between the provider and the user of the service, and the specific implementation of the service will be packaged, and the stability of the functional call is provided in the respective independence of both sides. When software modifications, upgrades, or other changes, both sides can vary independently, but this contract cannot be changed, this is the guarantee of software stability.

"Interface programming, rather than implementation programming" 2. In order to make the software architecture more reasonable, and for the cooperation between the team, the first work of software design, the first work of software design, is a call interface for the various horizontal and longitudinal parts of the software.

Special note is that when we design a database-based application, we should avoid the use of methods directly in the database, and should call the module defined interface method in the program. Otherwise, any modification of the database will bring a nightmare problem. Call the interface method instead of manipulating the database.

Let's take a specific example:

This is an example of a BBS. For the sake of clear explanation, let us simplify the problem as possible. There are two components of this system now: user login information maintenance and forum posting.

We can divide this system into two modules: UserSystem and Articlesystem.

UserSystem will contain the following features:

l New user registration

l Modify user information

l User login

Therefore, the functionality of usersystem can be represented by code as follows:

Public Class UserSystem

{

Public void CreateNewaccount (Account Acount)

Public void updateaccount (Account Acount)

Public Bool Login (Account Acount)

}

The articlesystem's function is relatively simple, it is posted, the code can be as follows:

Public Class Articlesystem

{

Public void createnewarticle (article article)

}

Because when sending a post, you need to know that the current posting will use user information in the userSystem, so users must provide this access interface, we add an attribute to users in UserSystem:

Public Static Account GetCurrentLogaccount {}

This getCurrentLogaccount is the access interface provided by UserSystem as Articlesystem. ArticLesystem does not need to know the specific implementation method of getCurrentLogaccount, he only needs to know that when he needs to use the user login information, you can call this method. In the future, regardless of how the userSystem changes, even change the design of the Account table in the database, as long as the getcurrentlogaccount does not change, there will be no articlesystem. Note: Don't directly selectusersystem's Account table in ArticLeSystem.

The above interface is a concept of a broad interface. As for the language of the language level, it is almost everywhere in "design mode".

As described above, it is the application system landscape interface, below, let's see the problem of the system longitudinal interface.

转载请注明原文地址:https://www.9cbs.com/read-26566.html

New Post(0)