CN111611024A - iOS component optimization method, system and terminal - Google Patents

iOS component optimization method, system and terminal Download PDF

Info

Publication number
CN111611024A
CN111611024A CN202010385672.4A CN202010385672A CN111611024A CN 111611024 A CN111611024 A CN 111611024A CN 202010385672 A CN202010385672 A CN 202010385672A CN 111611024 A CN111611024 A CN 111611024A
Authority
CN
China
Prior art keywords
target class
cache
target
name
module
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202010385672.4A
Other languages
Chinese (zh)
Other versions
CN111611024B (en
Inventor
张文浩
尹星
王文波
刘彬
蔡榕
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shanghai Wanjian Information Technology Co ltd
Original Assignee
Shanghai Wanjian Information Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shanghai Wanjian Information Technology Co ltd filed Critical Shanghai Wanjian Information Technology Co ltd
Priority to CN202010385672.4A priority Critical patent/CN111611024B/en
Publication of CN111611024A publication Critical patent/CN111611024A/en
Application granted granted Critical
Publication of CN111611024B publication Critical patent/CN111611024B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44521Dynamic linking or loading; Link editing at or after load time, e.g. Java class loading
    • G06F9/44526Plug-ins; Add-ons
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2455Query execution
    • G06F16/24552Database cache management

Abstract

The invention provides an iOS (internet operating system) componentization optimization method, a system and a terminal.A user-defined URL (uniform resource locator) verification and routing rule are realized by setting a closure of a configuration class when a Mediator is accessed, and a cache maximum value of the configuration class is set to control a Target class object cache dynamic management logic; when the Target class is created, the essential condition check is realized by following the created protocol and realizing the method stated in the protocol. The iOS componentization optimization method, the system and the terminal can customize functions of URL check logic, routing rules, essential condition check logic and the like of the terminal under the condition of not modifying a Mediator source code; according to the iOS componentization optimization method, the iOS componentization optimization system and the iOS componentization optimization terminal, the media can dynamically clear the cache according to the set cache upper limit, and performance problems are effectively avoided.

Description

iOS component optimization method, system and terminal
Technical Field
The invention relates to the technical field of computer development, in particular to an iOS (internet operating system) componentization optimization method, system and terminal.
Background
In the development process of the application program, with the increase of functions, business logic inevitably becomes more and more complex. In order to avoid the mutual influence among all services, a componentization mode is generally adopted for development, a complex system is split into a plurality of components, and the component boundary and responsibility are separated, so that the independent upgrade and maintenance are facilitated.
The existing Target-Action componentization scheme adopts a Mediator mode, namely all service components realize the communication and interaction among the components by depending on a Mediator:
1. each module creates a Target class of the module according to the format of the Target _ Name;
2. defining an Action method of the Target according to the format of the Action _ Name;
3. by scheme:// [ target ]/[ action ]? The format of [ params ] assembles the URL;
4. the media ware analyzes Target and Action in the URL, searches whether a corresponding Target object exists in the cache or not, if so, the Target object is directly used, and if not, the Target object is generated through Runtime;
5. the Mediator sends an Action message to the Tartget object.
In the above componentization scheme, the Mediator does not verify the URL, and the URL is parsed using a fixed rule, so that a personalized routing rule cannot be realized; the Target cache has no limitation and corresponding cleaning scheme, and performance problems are easy to occur.
Disclosure of Invention
Aiming at the defects in the prior art, the invention provides an iOS (internet operating system) componentization optimization method, a system and a terminal.
The invention is realized by the following technical scheme.
According to an aspect of the present invention, there is provided an iOS componentization optimization method, comprising:
s1, each module creates its own Target class according to the naming format of Target _ Name;
s2, defining and realizing own Action method in the Target class according to the naming format of the Action _ Name;
s3, by scheme:// [ target ]/[ action ]? Assembling the URL in the format of a params, wherein the params represents a parameter set required when the Target class object executes an Action method;
s4, the media parses the URL according to the format in S3 to obtain the Target name, the Action method name and the params parameter set; the process of analyzing the URL comprises the following steps:
creating a global configuration class (MediatorConfiguration) for a Mediator, wherein an object of the configuration class exists as an attribute of the Mediator, declaring a closure as the attribute for the configuration class, realizing self-defined URL (uniform resource locator) verification logic and routing rules, declaring an attribute of a numerical type for the configuration class, and setting a maximum cache value of a Target class object cache dictionary; meanwhile, a statement of a protocol (mediatorperformcirclprotocol) is created in the configuration class, a protocol method is declared, the method returns true or false values, and the essential condition check logic is realized;
s5, the pointer inquires whether there is a corresponding Target class object in the cache dictionary according to the Target class name:
if yes, directly obtaining;
if not, creating a Target class object through a Runtime program according to the Target class name, and adding the Target class object into a cache dictionary;
s6, the Mediator sends the command of executing Action method to the Targeted object and transmits the params parameter set.
Preferably, in S4, the configuration class uses a singleton-pattern design.
Preferably, in S4, for the URL parsing process, it is checked whether the configuration class object implements the declared closure before parsing:
if the operation is realized, executing the closure program and returning a Target class name and an Action method name;
if not, executing a default analysis program to obtain the Target class name and the Action method name.
Preferably, in S5, the caching logic of the Target class object adopts a dynamic management logic, which includes:
if the cache is not hit, creating a Target class object through a Runtime program according to the Target class name, adding the Target class object into the cache dictionary, and meanwhile, adding the current time as the latest access time of the Target class object into the cache dictionary and adding the current access times n into the cache dictionary;
if the cache is hit, acquiring the Target class object, and meanwhile, updating the current time serving as the latest access time of the Target class object into the cache dictionary and updating the current access times n +1 into the cache dictionary;
-checking, when adding the cache, whether the cache number of the current cache dictionary is greater than or equal to the maximum cache value of the configuration class object:
if so, traversing the current cache dictionary, inquiring the cache object with the longest recent access time and the least access times, and moving the cache object out of the cache;
if not, the cache is not cleaned.
Preferably, in S6, the execution process of the Action method includes:
before execution, it is checked whether the Target class object acquired in S5 complies with the created protocol and whether the method stated in the protocol is implemented:
if yes, sending a command for executing the protocol method to the Target class object, judging whether to continue executing the Action method according to a return value executed by the method, executing if the return value is true, and not executing if the return value is false;
if not, directly executing the Action method.
According to another aspect of the present invention, there is provided an iOS componentization optimization system comprising:
the system comprises a Target class creating module, a Target class creating module and a Target class setting module, wherein the Target class creating module is used for creating a Target class of each module according to the naming format of a Target _ Name;
the Action method creating module is used for defining and realizing an Action method according to the naming format of the Action _ Name in the Target class;
a URL assembly module that defines scheme:// [ target ]/[ action ]? [ params ] format, by scheme:// [ target ]/[ action ]? Assembling the URL in the format of a params, wherein the params represents a parameter set required when the Target class object executes an Action method;
the device comprises a media introduction module, a URL assembly module and a parameter collection module, wherein the media introduction module is used for resolving a URL by a media according to a format defined in the URL assembly module and acquiring a Target class name, an Action method name and a params parameter set; in the process of analyzing the URL, a global configuration class (MediatorConfiguration) is created for a Mediator, an object of the configuration class exists as an attribute of the Mediator, a closure is declared for the configuration class as the attribute, custom URL check logic and routing rules are realized, a value type attribute is declared for the configuration class, and the maximum cache value of a Target class object cache dictionary is set; meanwhile, a statement of a protocol (mediatorperformcirclprotocol) is created in the configuration class, a protocol method is declared, the method returns true or false values, and the essential condition check logic is realized;
the device comprises a Target class object creating module, a cache dictionary and a storage module, wherein the Target class object creating module is used for querying whether a corresponding Target class object exists in the cache dictionary by a Mediator according to a Target class name: if yes, directly obtaining; if not, creating a Target class object through a Runtime program according to the Target class name, and adding the Target class object into a cache dictionary;
and the Action method execution module is used for sending a command for executing the Action method to the Targeted object by the media, and transmitting a params parameter set.
Preferably, the Mediator introduces a module in which:
the configuration class is designed by using a singleton mode; and/or
Aiming at the URL analysis process, before analysis, whether the configuration class object realizes the declared closure is checked: if the operation is realized, executing the closure program and returning a Target class name and an Action method name; if not, executing a default analysis program to obtain the Target class name and the Action method name.
Preferably, in the Mediator import module, the cache logic of the Target class object adopts a dynamic management logic.
Preferably, in the Action method execution module, the Action method checks before execution whether the Target class object acquired in the Mediator import module follows the created protocol and whether a method stated in the protocol is implemented: if yes, sending a command for executing the protocol method to the Target class object, judging whether to continue executing the Action method according to a return value executed by the method, executing if the return value is true, and not executing if the return value is false; if not, directly executing the Action method.
According to a third aspect of the present invention, there is provided a terminal comprising a memory, a processor and a computer program stored on the memory and operable on the processor, the processor being operable when executing the computer program to perform any of the methods described above.
According to a fourth aspect of the present invention, there is provided another terminal comprising a memory, a processor and a system stored on the memory and operable by the processor.
Preferably, the system is operable to perform any of the methods described above.
Compared with the prior art, the invention has the following beneficial effects:
1. according to the iOS componentization optimization method, the iOS componentization optimization system and the iOS componentization optimization terminal, when a Mediator is accessed, user-defined URL (uniform resource locator) verification and routing rules are realized by setting a configuration class closure, and a cache maximum value of the configuration class is set to control Target class object cache dynamic management logic; when a Target class is created, the verification of the essential condition is realized by following the created protocol and realizing the method stated in the protocol; therefore, the invention can customize the functions of URL check logic, routing rule, essential condition check logic and the like without modifying the source code of the Mediator.
2. According to the iOS componentization optimization method, the iOS componentization optimization system and the iOS componentization optimization terminal, the media can dynamically clear the cache according to the set cache upper limit, and performance problems are effectively avoided.
Drawings
Other features, objects and advantages of the invention will become more apparent upon reading of the detailed description of non-limiting embodiments with reference to the following drawings:
fig. 1 is a flowchart of an iOS componentization optimization method according to an embodiment of the present invention.
Fig. 2 is a block diagram of an iOS componentization optimization system according to an embodiment of the present invention.
Detailed Description
The following examples illustrate the invention in detail: the embodiment is implemented on the premise of the technical scheme of the invention, and a detailed implementation mode and a specific operation process are given. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the inventive concept, which falls within the scope of the present invention.
An embodiment of the present invention provides an iOS componentization optimization method, as shown in fig. 1, including the following steps:
step S1, each module creates its own Target class according to the naming format of Target _ Name;
step S1 implements the following functions: the Mediator creates a Target class object according to the incoming Target name and a fixed naming rule;
step S2, defining and realizing own Action method according to the naming format of the Action _ Name in Target;
step S2 implements the following functions: the Mediator acquires an Action method name according to the incoming Action name and a fixed naming rule, and sends a command for executing the method to the Target object acquired in the step S1;
in step S3, scheme:// [ target ]/[ action ]? The format of [ params ] assembles the URL; wherein params represents a parameter set required by the Target class object when executing the Action method;
step S3 implements the following functions: when the operator sends a command of an execution method to the Target object, a parameter set is introduced, and when the Action method is executed, required parameters are obtained by analyzing the parameter set;
step S4, the media ware analyzes the URL according to the format in step S3, and obtains the Target class name, the Action method name and the params parameter set;
step S5, the media inquires whether there is a corresponding Target class object in the cache dictionary according to the Target class name, if there is, it directly obtains it, if not, it creates the Target class object through Runtime program according to the Target class name, and adds it into the cache dictionary;
step S6, the Mediator sends a command to execute the Action method to the target class object, and introduces a params parameter set.
Wherein:
the URL resolution process (M01) in step S4, including:
creating a global configuration class (MediatorConfiguration) for the Mediator, wherein the object of the configuration class exists as the attribute of the Mediator, declaring a closure as the attribute for the configuration class, and the attribute is used for realizing the customized URL check logic and routing rule (see M02), and declaring a value type attribute for the configuration class, and is used for setting the maximum cache value of the Target class object cache dictionary (used for M03). And creates a declaration of a protocol (mediatorperformcirclprotocol) in the configuration class and declares a protocol method, which returns true or false for implementing the essential condition checking logic (see M04).
The accessor realizes the self-defined URL check logic and the routing rule by encoding the closure of the configuration class.
As a preferred embodiment, the configuration classes created in M01 are designed using a singleton schema.
As a preferred embodiment, M02 is specifically:
for the URL parsing process in step S4, check before parsing whether the configuration class object in M01 implements the closure declared in M01, if implemented, execute the closure program and return the Target class name and the Action method name, and if not implemented, execute a default parsing program to obtain the Target class name and the Action method name.
As a preferred embodiment, in step S5, adding a dynamic management logic (M03) of the cache to the cache logic of the Target class object, includes:
if the cache is missed, creating a Target class object by a Runtime program according to the Target class name, adding the Target class object into the cache dictionary, adding the current time as the latest access time of the Target class object into the cache dictionary, and adding the current access times (such as 1) into the cache dictionary;
if the cache is hit, acquiring the Target class object, and updating the current time into the cache dictionary as the latest access time of the Target class object, and updating the current access times +1 (such as 1+1) into the cache dictionary;
when adding the cache, checking whether the cache number of the current cache dictionary is greater than or equal to the maximum cache value of the configuration class objects in M01, if so, traversing the current cache dictionary, inquiring the cache object with the longest latest access time and the fewest access times, and moving the cache object out of the cache; if not, the cache is not cleaned.
In a preferred embodiment, in step S6, the execution process of the Action method (M04) includes:
aiming at the Action method execution process of S06, before executing, checking whether the Target class object acquired in S05 follows the protocol stated in M01 and whether the method stated in the protocol is realized, if so, sending a command for executing the protocol method to the Target class object, judging whether to continue executing the Action method according to the return value of the method execution, if return to true, executing, and if return to false, not executing; if not, directly executing the Action method.
The iOS componentization optimization method provided by the embodiment of the present invention is further described in detail below with reference to a specific application example.
In an iOS App, the following componentization scheme needs to be completed:
1. development of a module A (Module A) is realized;
2. the module A respectively provides a method B (ActionB), a method C (ActionC) and a method D (ActionD) for acquiring the page 1, the page 2 and the page 3;
3. the method of calling module A must be logged in;
4. is there a scheme:// startapp/module a/[ action ]? URL format access module A of [ params ];
5. the maximum value of the Target class object cache is 10;
in combination with the iOS componentization optimization method provided by the embodiment of the present invention, the componentization method comprises the following implementation steps:
1. introduce Mediator and the configuration class (MediatorConfiguration) created in M01;
2. creating a Target class (Target _ ModuleA) belonging to a module A, and declaring a realization method B (Action _ ActionB), a method C (Action _ ActionC) and a method D (Action _ ActionD);
3. the Target class (Target _ module a) follows the protocol (mediatorperformcirclprotocol) declared in M01, and implements the method declared in the protocol (specifically, whether the user logs in, logs in and returns to the future, and does not log in and returns to the false) here, in order to implement requirement 3 (i.e., the requirement condition is verified, and the working process is shown in M04);
4. when App starts, acquiring a singleton object of a configuration class (MediatorConfiguration), and setting the implementation of the closure attribute (namely, analyzing the implementation of the URL agreed in the requirement 4, and returning the Target class name and the Action method name obtained by analysis), wherein the requirement 4 is realized (namely, a self-defined routing rule, and the working process is shown in M02);
5. when App starts, acquiring a singleton object of a configuration class (MediatorConfiguration), setting the maximum cache attribute of the singleton object to be 10, and realizing requirement 5 (see M03 in the working process);
6. thus, the above requirements can be realized, and the module A can be accessed through the Mediator according to the URL format agreed by the requirements.
Based on the iOS componentization optimization method provided by the embodiment of the present invention, the embodiment of the present invention also provides an iOS componentization optimization system, as shown in fig. 2, including:
the system comprises a Target class creating module, a Target class creating module and a Target class setting module, wherein the Target class creating module is used for each module to create own Target class according to the naming format of Target _ Name;
the Action method creating module is used for defining and realizing an Action method according to the naming format of the Action _ Name in the Target class;
a URL assembly module that defines scheme:// [ target ]/[ action ]? [ params ] format, by scheme:// [ target ]/[ action ]? Assembling the URL in the format of a params, wherein the params represents a parameter set required when the Target class object executes an Action method;
the device comprises a media introduction module, a URL assembly module and a parameter collection module, wherein the media introduction module is used for analyzing a URL by the media according to a format defined in the URL assembly module and acquiring a Target class name, an Action method name and a params parameter set; in the process of analyzing the URL, a global configuration class (MediatorConfiguration) is created for a Mediator, an object of the configuration class exists as an attribute of the Mediator, a closure is declared for the configuration class as an attribute, the attribute is used for realizing self-defined URL check logic and routing rules, a value type attribute is declared for the configuration class, and the maximum cache value of a Target class object cache dictionary is set; meanwhile, a statement of a protocol (mediatorperformcirclprotocol) is created in the configuration class, a protocol method is declared, the method returns true or false values, and the essential condition check logic is realized;
the device comprises a Target class object creating module, wherein the Target class object creating module is used for querying whether a corresponding Target class object exists in a cache dictionary by a media player according to a Target class name: if yes, directly obtaining; if not, creating a Target class object through a Runtime program according to the Target class name, and adding the Target class object into a cache dictionary;
and the Action method execution module is used for sending a command for executing the Action method to the Targeted object by the media, and transmitting a params parameter set.
Further, the iOS componentization optimization system may be configured to perform the iOS componentization optimization method.
As a preferred embodiment, the Mediator introduces into the module:
the configuration class is designed by using a singleton mode; and/or
Aiming at the URL analysis process, before analysis, whether the configuration class object realizes the declared closure is checked: if the operation is realized, executing the closure program and returning a Target class name and an Action method name; if not, executing a default analysis program to obtain the Target class name and the Action method name.
In the media import module, the cache logic of the Target class object adopts dynamic management logic as a preferred embodiment.
As a preferred embodiment, in the Action method execution module, before execution, the Action method checks whether a Target class object acquired in the Mediator introduction module follows a created protocol, and whether a method declared in the protocol is implemented: if yes, sending a command for executing the protocol method to the Target class object, judging whether to continue executing the Action method according to a return value executed by the method, executing if the return value is true, and not executing if the return value is false; if not, directly executing the Action method.
Based on the iOS componentization optimization method provided by the embodiment of the present invention, the embodiment of the present invention also provides a terminal, which includes a memory, a processor, and a computer program stored on the memory and capable of running on the processor, and the processor can be used to execute any of the iOS componentization optimization methods described above when executing the computer program.
Optionally, a memory for storing a program; a Memory, which may include a volatile Memory (abbreviated RAM), such as a Random-Access Memory (RAM), a static Random-Access Memory (SRAM), a Double Data Rate Synchronous Dynamic Random Access Memory (DDR SDRAM), and the like; the memory may also comprise a non-volatile memory, such as a flash memory. The memory 62 is used to store computer programs (e.g., applications, functional modules, etc. that implement the above-described methods), computer instructions, etc., which may be stored in one or more memories in a partitioned manner. And the computer programs, computer instructions, data, etc. described above may be invoked by a processor.
The computer programs, computer instructions, etc. described above may be stored in one or more memories in a partitioned manner. And the computer programs, computer instructions, data, etc. described above may be invoked by a processor.
A processor for executing the computer program stored in the memory to implement the steps of the method according to the above embodiments. Reference may be made in particular to the description relating to the preceding method embodiment.
The processor and the memory may be separate structures or may be an integrated structure integrated together. When the processor and the memory are separate structures, the memory, the processor may be coupled by a bus.
Based on the iOS componentization optimization method provided by the embodiment of the present invention, the embodiment of the present invention also provides another terminal, which comprises a memory, a processor, and an iOS componentization optimization system that is stored on the memory and can run any one of the above through the processor.
Further, the iOS componentization optimization system can be used to perform the iOS componentization optimization method.
When the iOS componentization optimization method, system, and terminal provided in the above embodiments of the present invention access the Mediator, the custom URL check and routing rule is realized by setting the closure of the configuration class (see M02 in the execution process), and the cache maximum value of the configuration class is set to control the Target class object cache dynamic management logic (see M03 in the execution process); when the media is accessed, the user-defined URL check and routing rule is realized by setting the closure of the configuration class (the execution process is shown as M02), and the cache maximum value of the configuration class is set to control the Target class object cache dynamic management logic (the execution process is shown as M03); therefore, the invention can customize the functions of URL check logic, routing rule, essential condition check logic and the like without modifying the source code of the Mediator.
According to the iOS componentization optimization method, the iOS componentization optimization system and the iOS componentization optimization terminal, the media can dynamically clear the cache according to the set cache upper limit, and performance problems are effectively avoided.
It should be noted that, the steps in the method provided by the present invention can be implemented by using corresponding modules, devices, units, and the like in the system, and those skilled in the art can implement the step flow of the method by referring to the technical scheme of the system, that is, the embodiment in the system can be understood as a preferred example of the implementation method, and details are not described herein.
Those skilled in the art will appreciate that, in addition to implementing the system and its various devices provided by the present invention in purely computer readable program code means, the method steps can be fully programmed to implement the same functions by implementing the system and its various devices in the form of logic gates, switches, application specific integrated circuits, programmable logic controllers, embedded microcontrollers and the like. Therefore, the system and various devices thereof provided by the present invention can be regarded as a hardware component, and the devices included in the system and various devices thereof for realizing various functions can also be regarded as structures in the hardware component; means for performing the functions may also be regarded as structures within both software modules and hardware components for performing the methods.
The foregoing description of specific embodiments of the present invention has been presented. It is to be understood that the present invention is not limited to the specific embodiments described above, and that various changes and modifications may be made by one skilled in the art within the scope of the appended claims without departing from the spirit of the invention.

Claims (10)

1. An iOS componentization optimization method, comprising:
s1, each module creates its own Target class according to the naming format of Target _ Name;
s2, defining and realizing own Action method in the Target class according to the naming format of the Action _ Name;
s3, by scheme:// [ target ]/[ action ]? Assembling the URL in the format of a params, wherein the params represents a parameter set required when the Target class object executes an Action method;
s4, the media parses the URL according to the format in S3 to obtain the Target name, the Action method name and the params parameter set; the process of analyzing the URL comprises the following steps:
creating a global configuration class for a Mediator, wherein an object of the configuration class exists as an attribute of the Mediator, declaring a closure as the attribute for the configuration class, realizing a custom URL check logic and a routing rule, declaring an attribute of a numerical type for the configuration class, and setting a maximum cache value of a Target class object cache dictionary; meanwhile, a protocol statement is created in the configuration class, a protocol method is declared, and the method returns a true or false value to realize the essential condition check logic;
s5, the pointer inquires whether there is a corresponding Target class object in the cache dictionary according to the Target class name:
if yes, directly obtaining;
if not, creating a Target class object through a Runtime program according to the Target class name, and adding the Target class object into a cache dictionary;
s6, the Mediator sends the command of executing Action method to the Targeted object and transmits the params parameter set.
2. The iOS componentization optimization method of claim 1, wherein in the S4, the configuration class uses a singleton-pattern design.
3. The iOS componentization optimization method of claim 1, wherein in S4, for the URL parsing process, it is checked whether the configuration class object implements a declared closure before parsing:
if the operation is realized, executing the closure program and returning a Target class name and an Action method name;
if not, executing a default analysis program to obtain the Target class name and the Action method name.
4. The iOS componentization optimization method according to claim 1, wherein in S5, the caching logic of the Target class object employs a dynamic management logic, including:
if the cache is not hit, creating a Target class object through a Runtime program according to the Target class name, adding the Target class object into the cache dictionary, and meanwhile, adding the current time as the latest access time of the Target class object into the cache dictionary and adding the current access times n into the cache dictionary;
if the cache is hit, acquiring the Target class object, and meanwhile, updating the current time serving as the latest access time of the Target class object into the cache dictionary and updating the current access times n +1 into the cache dictionary;
-checking, when adding the cache, whether the cache number of the current cache dictionary is greater than or equal to the maximum cache value of the configuration class object:
if so, traversing the current cache dictionary, inquiring the cache object with the longest recent access time and the least access times, and moving the cache object out of the cache;
if not, the cache is not cleaned.
5. The iOS componentized optimization method according to claim 1, wherein in S6, the execution process of the Action method includes:
before execution, it is checked whether the Target class object acquired in S5 complies with the created protocol and whether the method stated in the protocol is implemented:
if yes, sending a command for executing the protocol method to the Target class object, judging whether to continue executing the Action method according to a return value executed by the method, executing if the return value is true, and not executing if the return value is false;
if not, directly executing the Action method.
6. An iOS componentized optimization system, comprising:
the system comprises a Target class creating module, a Target class creating module and a Target class setting module, wherein the Target class creating module is used for creating a Target class of each module according to the naming format of a Target _ Name;
the Action method creating module is used for defining and realizing an Action method according to the naming format of the Action _ Name in the Target class;
a URL assembly module that defines scheme:// [ target ]/[ action ]? [ params ] format, by scheme:// [ target ]/[ action ]? Assembling the URL in the format of a params, wherein the params represents a parameter set required when the Target class object executes an Action method;
the device comprises a media introduction module, a URL assembly module and a parameter collection module, wherein the media introduction module is used for resolving a URL by a media according to a format defined in the URL assembly module and acquiring a Target class name, an Action method name and a params parameter set; in the process of analyzing the URL, a global configuration class (MediatorConfiguration) is created for a Mediator, an object of the configuration class exists as an attribute of the Mediator, a closure is declared for the configuration class as the attribute, custom URL check logic and routing rules are realized, a value type attribute is declared for the configuration class, and the maximum cache value of a Target class object cache dictionary is set; meanwhile, a statement of a protocol (mediatorperformcirclprotocol) is created in the configuration class, a protocol method is declared, the method returns true or false values, and the essential condition check logic is realized;
the device comprises a Target class object creating module, a cache dictionary and a storage module, wherein the Target class object creating module is used for querying whether a corresponding Target class object exists in the cache dictionary by a Mediator according to a Target class name: if yes, directly obtaining; if not, creating a Target class object through a Runtime program according to the Target class name, and adding the Target class object into a cache dictionary;
and the Action method execution module is used for sending a command for executing the Action method to the Targeted object by the media, and transmitting a params parameter set.
7. The iOS componentized optimization system of claim 1, wherein the Mediator lead-in module is configured to:
the configuration class is designed by using a singleton mode; and/or
Aiming at the URL analysis process, before analysis, whether the configuration class object realizes the declared closure is checked: if the operation is realized, executing the closure program and returning a Target class name and an Action method name; if not, executing a default analysis program to obtain the Target class name and the Action method name.
8. The iOS componentized optimization system of claim 1, wherein in the Mediator lead-in module, a caching logic of Target class objects employs a dynamic management logic.
9. The iOS componentized optimization system according to claim 1, wherein in the Action method execution module, the Action method checks before execution whether the Target class object acquired in the Mediator lead-in module follows the created protocol and implements a method declared in the protocol: if yes, sending a command for executing the protocol method to the Target class object, judging whether to continue executing the Action method according to a return value executed by the method, executing if the return value is true, and not executing if the return value is false; if not, directly executing the Action method.
10. A terminal comprising a memory, a processor and a computer program stored on the memory and operable on the processor, wherein the computer program, when executed by the processor, is operable to perform the method of any of claims 1 to 5.
CN202010385672.4A 2020-05-09 2020-05-09 iOS component optimization method, system and terminal Active CN111611024B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010385672.4A CN111611024B (en) 2020-05-09 2020-05-09 iOS component optimization method, system and terminal

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010385672.4A CN111611024B (en) 2020-05-09 2020-05-09 iOS component optimization method, system and terminal

Publications (2)

Publication Number Publication Date
CN111611024A true CN111611024A (en) 2020-09-01
CN111611024B CN111611024B (en) 2022-10-11

Family

ID=72200093

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010385672.4A Active CN111611024B (en) 2020-05-09 2020-05-09 iOS component optimization method, system and terminal

Country Status (1)

Country Link
CN (1) CN111611024B (en)

Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6012067A (en) * 1998-03-02 2000-01-04 Sarkar; Shyam Sundar Method and apparatus for storing and manipulating objects in a plurality of relational data managers on the web
CN1630853A (en) * 2001-10-30 2005-06-22 皇家飞利浦电子股份有限公司 Method for constructing distributed software components
US20060155830A1 (en) * 2004-11-12 2006-07-13 International Business Machines Corporation Configuration mediator for a multi-component software solution environment
EP1898553A1 (en) * 2006-08-31 2008-03-12 Nokia Siemens Networks Gmbh & Co. Kg Generic network configuration management with XML
US9432484B1 (en) * 2013-12-19 2016-08-30 Emc Corporation CIM-based data storage management system having a restful front-end
CN107707614A (en) * 2017-08-16 2018-02-16 深圳市丰巢科技有限公司 App route implementation methods, equipment and the storage medium of agreement are jumped based on system
CN108255495A (en) * 2018-01-31 2018-07-06 中国银行股份有限公司 A kind of modularization method and system based on Mediator
WO2018170504A1 (en) * 2017-03-17 2018-09-20 Labyrinth Research Llc Unified control of privacy-impacting devices
CN109643277A (en) * 2016-09-26 2019-04-16 英特尔公司 The device and method merged for intermediary's transmitting and shared memory page
CN109669786A (en) * 2018-09-26 2019-04-23 深圳壹账通智能科技有限公司 Interface call method, unit and computer readable storage medium

Patent Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6012067A (en) * 1998-03-02 2000-01-04 Sarkar; Shyam Sundar Method and apparatus for storing and manipulating objects in a plurality of relational data managers on the web
CN1630853A (en) * 2001-10-30 2005-06-22 皇家飞利浦电子股份有限公司 Method for constructing distributed software components
US20060155830A1 (en) * 2004-11-12 2006-07-13 International Business Machines Corporation Configuration mediator for a multi-component software solution environment
EP1898553A1 (en) * 2006-08-31 2008-03-12 Nokia Siemens Networks Gmbh & Co. Kg Generic network configuration management with XML
US9432484B1 (en) * 2013-12-19 2016-08-30 Emc Corporation CIM-based data storage management system having a restful front-end
CN109643277A (en) * 2016-09-26 2019-04-16 英特尔公司 The device and method merged for intermediary's transmitting and shared memory page
WO2018170504A1 (en) * 2017-03-17 2018-09-20 Labyrinth Research Llc Unified control of privacy-impacting devices
CN107707614A (en) * 2017-08-16 2018-02-16 深圳市丰巢科技有限公司 App route implementation methods, equipment and the storage medium of agreement are jumped based on system
CN108255495A (en) * 2018-01-31 2018-07-06 中国银行股份有限公司 A kind of modularization method and system based on Mediator
CN109669786A (en) * 2018-09-26 2019-04-23 深圳壹账通智能科技有限公司 Interface call method, unit and computer readable storage medium

Non-Patent Citations (5)

* Cited by examiner, † Cited by third party
Title
J. TODD ET AL: "Building mediators from components", 《PROCEEDINGS OF THE INTERNATIONAL SYMPOSIUM ON DISTRIBUTED OBJECTS AND APPLICATIONS》 *
周波等: "设计模式在水文信息推送APP架构设计中的应用", 《长江工程职业技术学院学报》 *
张琦等: "Mediator模型的SystemC代码自动生成", 《计算机工程与科学》 *
王子敬等: "基于Mediator模式的参数控制法", 《江南大学学报(自然科学版)》 *
道道明明白白: "《简书:IOS设计模式-中介者模式》", 8 November 2018 *

Also Published As

Publication number Publication date
CN111611024B (en) 2022-10-11

Similar Documents

Publication Publication Date Title
US11176160B2 (en) SQL interceptor for use with third party data analytics packages
EP1872215B1 (en) Implementing data-compatibility-based version scheme
US6286035B1 (en) Validating and parsing engine for system configuration and support command messages
CN109597618B (en) Program development method, program development device, computer device, and storage medium
CN111800459A (en) Asynchronous processing method, device and system for download task and storage medium
CN111309785A (en) Spring framework-based database access method and device, computer equipment and medium
CN112154420A (en) Automatic intelligent cloud service testing tool
CN104754062A (en) Internet based information popularization method, server and user terminal
CN112015752A (en) Method and device for dynamically querying data, electronic equipment and storage medium
EP1704475B1 (en) System and method for dynamically optimized message processing
CN111240772A (en) Data processing method and device based on block chain and storage medium
CN111159301A (en) Data creating method, device, equipment and storage medium based on intelligent contract
CN102609494B (en) Method for processing data of machine account and device
CN107491700B (en) Data access method and equipment
CN112115041B (en) Dynamic point embedding method and device for application program, storage medium and computer equipment
CN105468776A (en) Method, device and system for operating database
CN111611024B (en) iOS component optimization method, system and terminal
CN106383869A (en) User behavior information acquisition method and device
CN115374083A (en) Data source switching method and device, electronic equipment and storage medium
CN112860235B (en) Method, device, equipment and storage medium for processing text
CN112650502A (en) Batch processing task processing method and device, computer equipment and storage medium
CN113377563A (en) Webpage monitoring method and computing device
CN112612474A (en) Product transplanting method and device, storage medium and electronic equipment
CN110780864A (en) Control method and device for class method replacement, storage medium and electronic equipment
CN114328161A (en) Java interface test method and device, storage medium and electronic equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant