CN110045997B - Object initialization method, device, equipment and storage medium of basic function module - Google Patents

Object initialization method, device, equipment and storage medium of basic function module Download PDF

Info

Publication number
CN110045997B
CN110045997B CN201910299545.XA CN201910299545A CN110045997B CN 110045997 B CN110045997 B CN 110045997B CN 201910299545 A CN201910299545 A CN 201910299545A CN 110045997 B CN110045997 B CN 110045997B
Authority
CN
China
Prior art keywords
initialization
function
protocol
initialized
class
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.)
Active
Application number
CN201910299545.XA
Other languages
Chinese (zh)
Other versions
CN110045997A (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.)
Wuhan Douyu Network Technology Co Ltd
Original Assignee
Wuhan Douyu Network 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 Wuhan Douyu Network Technology Co Ltd filed Critical Wuhan Douyu Network Technology Co Ltd
Priority to CN201910299545.XA priority Critical patent/CN110045997B/en
Publication of CN110045997A publication Critical patent/CN110045997A/en
Application granted granted Critical
Publication of CN110045997B publication Critical patent/CN110045997B/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/44505Configuring for program initiating, e.g. using registry, configuration files
    • 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

Abstract

The embodiment of the invention discloses an object initialization method, device, equipment and storage medium of a basic function module. The method comprises the following steps: in a life cycle starting function of a moving window object corresponding to an application program first starting picture, respectively taking each target class as an input parameter, calling an object storage function through an object set, and storing an object to be initialized corresponding to each target class into the object set; respectively calling an object initialization function through each object to be initialized in the object set so as to initialize each object to be initialized; the target class is obtained based on a predefined universal initialization protocol, the universal initialization protocol comprises an object initialization protocol function, and the object set is a universal initialization protocol type. By the technical scheme, the initialization operation is split into the target classes, the decoupling of the initialization code and the application class code is achieved, and the code maintainability of the application program is improved.

Description

Object initialization method, device, equipment and storage medium of basic function module
Technical Field
The present invention relates to computer technologies, and in particular, to an object initialization method, an object initialization apparatus, a device, and a storage medium for a basic function module.
Background
At present, in the design of an Application developed based on an Android system, initialization operations of some function modules are set to be implemented in Application type Application corresponding to the Application, so that corresponding initialization objects can be quickly accessed in the following process. Due to the design, the initialization logic in the application class is very much, so that the class corresponding to the basic function module is excessively coupled with the application class, and the code maintenance of the whole application program is not facilitated. For example, each time the relevant code of an application is modified, other services may be affected, resulting in new problems.
Disclosure of Invention
Embodiments of the present invention provide an object initialization method, apparatus, device, and storage medium for a basic function module, so as to implement optimization of an initialization logic of the basic function module, thereby reducing code coupling in an application program and improving code maintainability of the application program.
In a first aspect, an embodiment of the present invention provides an object initialization method for a basic function module, including:
in a life cycle starting function of a movable window object corresponding to an application program initial starting picture, respectively taking each target class as an input parameter, calling an object storage function through an object set, and storing an object to be initialized corresponding to each target class into the object set;
respectively calling an object initialization function through each object to be initialized in the object set so as to initialize each object to be initialized;
the target class is obtained based on a predefined universal initialization protocol, the universal initialization protocol comprises an object initialization protocol function, and the object set is a universal initialization protocol type.
In a second aspect, an embodiment of the present invention further provides an object initialization apparatus for a basic function module, where the apparatus includes:
the object storage module is used for calling an object storage function through an object set by respectively taking each object class as an input parameter in a life cycle starting function of a movable window object corresponding to an application program initial starting picture, and storing an object to be initialized corresponding to each object class into the object set;
an object initialization module, configured to call an object initialization function through each object to be initialized in the object set, respectively, so as to initialize each object to be initialized;
the target class is obtained based on a predefined universal initialization protocol, the universal initialization protocol comprises an object initialization protocol function, and the object set is a universal initialization protocol type.
In a third aspect, an embodiment of the present invention further provides an apparatus, where the apparatus includes:
one or more processors;
a storage device for storing one or more programs,
when the one or more programs are executed by the one or more processors, the one or more processors implement the object initialization method of the basic function module provided by any embodiment of the present invention.
In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the object initialization method for the basic function module provided in any embodiment of the present invention.
According to the embodiment of the invention, the object initialization operation is executed in the life cycle starting function of the movable window object corresponding to the first-time starting picture of the application program, so that the display influence of the object initialization operation on the first-time starting picture is reduced, and the display speed of the first-time starting picture is improved. The target classes are used as input parameters respectively, the object storage function is called through the object set, the object to be initialized corresponding to each target class is stored in the object set, and the target classes are obtained based on the predefined universal initialization protocol, so that all the objects to be initialized based on the same universal initialization protocol are stored in the object set, and unified initialization management is performed. The method comprises the steps of defining each target class in advance through a general initialization protocol containing an object initialization protocol function, calling the object initialization function through each object to be initialized in an object set respectively to initialize each object to be initialized, splitting initialization operation into each target class, achieving decoupling of initialization codes and application class codes, and improving code maintainability of an application program.
Drawings
FIG. 1 is a flowchart of an object initialization method for basic function modules according to a first embodiment of the present invention;
FIG. 2 is a flowchart of an object initialization method for basic function modules according to a second embodiment of the present invention;
fig. 3 is a schematic structural diagram of an object initialization apparatus for basic function modules according to a third embodiment of the present invention;
fig. 4 is a schematic structural diagram of an apparatus in the fourth embodiment of the present invention.
Detailed Description
The present invention will be described in further detail with reference to the accompanying drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the invention and are not limiting of the invention. It should be further noted that, for the convenience of description, only some of the structures related to the present invention are shown in the drawings, not all of the structures.
Example one
The object initialization method for the basic function module provided by the embodiment can be applied to initialization of the basic function module when an application program developed based on an Android system is started. The method can be executed by an object initialization device of a basic function module, the device can be realized in a software and/or hardware mode, and the device can be integrated in equipment carrying an Android system, for example, typical user terminal equipment such as a mobile phone, a tablet computer or a smart television. Referring to fig. 1, the method of the present embodiment includes:
and S110, in a life cycle starting function of a movable window object corresponding to a first starting picture of an application program, respectively taking each target class as an input parameter, calling an object storage function through an object set, and storing an object to be initialized corresponding to each target class into the object set.
The active window object refers to a corresponding object constructed when the active window activity is initialized. The lifecycle initiation function oncredit refers to a function that the system automatically calls when an object is created. The target class is a class to be initialized, and may also be a class corresponding to the basic function module, for example, a log class corresponding to the log module and a network class corresponding to the network module. Illustratively, the target class is obtained based on a predefined generic initialization protocol, which includes object initialization protocol functions. That is, the target class is predefined and is defined based on a predefined generic initialization protocol, which is a protocol specifically designed for object initialization and includes at least an object initialization protocol function therein. For example, the definition code for implementing the generic initialization protocol with an interface may be: public interface IinitDestorey { public void init (); and wherein iinit storage is the name of the generic initialization protocol, which is a public type interface protocol, and other classes have access to the protocol. init () is an object initialization protocol function within which initialization operations for objects can be subsequently implemented. The object set is predefined and used for storing each set of objects to be initialized, and the object set is a universal initialization protocol type with a global scope. An example of the defined code for the set of objects listiinitstore is as follows: private List < IinitDestorey > listIinitDestorey. The object storage function is a member function of the object set, and is used for storing the function input parameter into the object set. The object to be initialized is an instantiation object of the target class.
Specifically, when an application starts, it first starts a splash page, typically for presenting set advertising pages. The advertisement page generally needs to stay for several seconds, so the initialization operation of the object to be initialized can be completed by using the stay time of the advertisement page. Therefore, in the embodiment of the present invention, the operation of object initialization is set to be executed when the first splash page of the application program is loaded, that is, executed in the life cycle start function of the active window object spaciactive corresponding to the first startup picture of the application program. Therefore, the initialization of all basic function modules is not required to be realized while the application program is started, only the first splash screen page is started, and the starting speed of the advertisement page can be improved.
In addition, in the embodiment of the present invention, the initialization operation of each basic function module is split from the Application class started by the Application program into each target class, and then the object initialization operation of different basic function modules is implemented according to each target class, thereby implementing the decoupling of the initialization logic and the Application class. Therefore, before the object initialization operation is performed, it is necessary to define each target class in advance based on a general initialization protocol defined in advance. The definition of the target class can be directly inherited from the universal initialization protocol or indirectly inherited from the universal initialization protocol.
Illustratively, the target class is obtained based on a predefined generic initialization protocol by: the target class inherits the universal initialization protocol through the protocol inheriting key words and rewrites the object initialization protocol function to obtain the target class of the universal initialization protocol type and the object initialization function. Specifically, the target class directly inherits the universal initialization protocol IinitDestory through the protocol inheritance keywords instances, and rewrites and realizes all protocol functions including the object initialization protocol function in the universal initialization protocol, and generates all function realization including the object initialization function. It will be appreciated that the target class obtained in the manner described above has all the functions in the generic initialization protocol. Taking the definition of the network class NetModule as an example, the code implementation can be as follows:
Figure BDA0002027772200000061
therefore, the object initialization operation of the network class can be split into the network modules to be realized, and the effects of splitting the initialization operation and decoupling the codes are achieved.
In a specific implementation, in the lifecycle initiation function onCreate, initializing the object set listIinitDestory, where a specific initialization code is, for example, listIinitDestory ═ new ArrayList < IinitDestory > (), that is, a procedure of initializing the object set by calling a constructor of the listlist is implemented. Then, each time one target class is taken as an input parameter, an object storage function is called through the object set listiinitstore, and the object to be initialized corresponding to each target class is stored in the object set. Therefore, the object set listiinitstore contains information of all objects to be initialized, and then object initialization operation can be performed based on the object set, so that unified management of initialization operation of all objects to be initialized is realized.
It should be noted that, in the object storage function, an instantiation operation needs to be performed on a target class, so as to generate an object to be initialized corresponding to each target class. Taking the addition of the object to be initialized of the network class as an example, the function input parameter of the add function add () of the element of the object set may be set as the operation of instantiating the target class, that is, the add function add () of the element is called by the object set listIinitDestory, and the input parameters of the add function are the instantiation keyword new and the network class NetModule, and the code implementation example is listiinitdestrostery.
Illustratively, the object storage function realizes the function of storing the object to be initialized corresponding to each target class into the object set by the following method: respectively generating instantiation objects corresponding to the target classes by using the instantiation keywords; and respectively taking each instantiation object as an input parameter, calling an element adding function of the object set, and storing each instantiation object to the object set. Specifically, the operation of the instantiation keyword new and the element addition function add () can be encapsulated in one function, namely an object storage function, so that a developer can directly call the function, and the development efficiency is improved.
And S120, respectively calling an object initialization function through each object to be initialized in the object set so as to initialize each object to be initialized.
Specifically, when initializing an object, an object to be initialized needs to be taken out from an object set, and then an object initialization function in the object to be initialized is called by the object to be initialized to initialize the object. And traversing the object set, and executing the operation aiming at each object to be initialized, so that the initialization operation of the objects to be initialized can be completed uniformly.
According to the technical scheme of the embodiment, the object initialization operation is executed in the life cycle starting function of the movable window object corresponding to the first-time starting picture of the application program, so that the display influence of the object initialization operation on the first-time starting picture is reduced, and the display speed of the first-time starting picture is improved. The target classes are used as input parameters respectively, the object storage function is called through the object set, the object to be initialized corresponding to each target class is stored in the object set, and the target classes are obtained based on the predefined universal initialization protocol, so that all the objects to be initialized based on the same universal initialization protocol are stored in the object set, and unified initialization management is performed. The method comprises the steps of defining each target class in advance through a general initialization protocol containing an object initialization protocol function, calling the object initialization function through each object to be initialized in an object set respectively to initialize each object to be initialized, splitting initialization operation into each target class, achieving decoupling of initialization codes and application class codes, and improving code maintainability of an application program.
Exemplarily, on the basis of the above technical solution, the generic initialization protocol includes an object release protocol function; correspondingly, after the target class inherits the generic initialization protocol through the protocol inheritance key, the method further comprises the following steps: and the target class rewrites the object release protocol function to obtain an object release function.
Specifically, the object release protocol function is set in the generic initialization protocol, that is, the protocol function public void store () in the generic initialization protocol is added when the generic initialization protocol is defined. Then, when the target class inherits the generic initialization protocol through the protocol inheritance key instances, the object release protocol function in the target class needs to be rewritten and implemented to generate the object release function. The object release function needs to be called when the application exits to release the object previously generated by the object initialization function. The method has the advantages that developers can be reminded of releasing the objects in time, and therefore the problem of memory leakage is avoided.
Example two
The present embodiment further optimizes "the target class is obtained based on the predefined generic initialization protocol" on the basis of the above-described embodiments. On the basis of the method, the operation of opening up the child thread can be added. On the basis, the optimization can be further performed on the step of respectively calling the object initialization function through each object to be initialized in the object set so as to initialize each object to be initialized. Wherein explanations of the same or corresponding terms as those of the above embodiments are omitted. Referring to fig. 2, the object initialization method of the basic function module provided in this embodiment includes:
s210, the abstract initialization class inherits the universal initialization protocol through the protocol inheriting key words and overwrites each protocol function in the universal initialization protocol to obtain the abstract initialization class of the universal initialization protocol type and each protocol implementation function.
The abstract initialization class refers to an abstract class having an initialization function, that is, the abstract initialization class has an abstract type modifier abstrat. The protocol implementation function refers to a function obtained by adding a function implementation to a protocol function in the generic initialization protocol.
Specifically, in order to optimize the initialization logic in the target class, so that the functions in the target class can be compatible with different application requirements, for example, some target classes only need object initialization operation, some target classes only need object release operation, and some target classes need both initialization and release operation. When the abstract initialization class inherits the universal initialization protocol, in order to ensure the custom realization of each function in the subsequent target class, when the abstract initialization class rewrites each protocol function, the function realization is all set to be null realization, namely, each protocol realization function is null realization, and no specific function realization exists in the function.
For example, an abstract initialization class, absinitdeststore, is designed, whose definition code is exemplified by:
Figure BDA0002027772200000091
the access right of the abstract initialization class AbsinitDestore is public, so that other classes have the right to access the abstract initialization class AbsinitDestore, and the AbsinitDestore uses an abstract type modifier abstract, so that the AbsinitDestore is an abstract class. The abstract initialization class AbsinitDestore inherits the universal initialization protocol IinitDestore through the protocol inheritance keyword instances, and simultaneously needs to rewrite and realize each protocol function in the universal initialization protocol IinitDestore, such as an object initialization protocol function init () and an object release protocol function release (), so as to obtain the abstract initialization class AbsinitDestore of the universal initialization protocol type, an object initialization protocol implementation function and an object release protocol implementation function contained in the abstract initialization class AbsinitDestore, wherein the two protocol implementation functions are not provided with specific function implementation codes, namely, the two protocol implementation functions are empty implementation.
S220, the target class inherits the abstract initialization class through the class extension keywords and rewrites the object initialization realization function in each protocol realization function to obtain the target class and the object initialization function of the universal initialization protocol type.
In particular, each target class implements the definition of the target class by inheritance to the abstract initialization class and the duplication of the protocol implementation functions it requires.
For example, the target class is a view controller class MyController, which only needs to initialize the flow, i.e., only needs the object to initialize the function. The definition of the view controller class and the acquisition process of the object initialization function inside the view controller class are as follows: the view controller MyController inherits the abstract initialization class AbsinitDestory through the class extension keywords, so that the view controller MyController has the function of the abstract initialization class AbsinitDestory. Because the view controller class MyController only needs to initialize the flow, only the object initialization protocol implementation function needs to be rewritten and implemented in the view controller class MyController, and the code implementation can be exemplified as follows:
Figure BDA0002027772200000101
Figure BDA0002027772200000111
because the abstract initialization class AbsinitDestore is inherited by means of extensions, if an object release flow is not needed, the object release protocol implementation function store () is not rewritten in the view controller class MyController, so that only the object initialization function init () but not the object release function store () in the view controller class MyController is implemented.
Similarly, if only the object release function history () is needed, the abstract initialization class AbsinitDestory is inherited by the methods of extensions, then the history () is rewritten and realized, and the init () is not rewritten, so that the function that only the object release process is realized and the object initialization process is not realized. If both the object initialization process and the object release process are needed, the implementation can be performed by using the scheme of the first embodiment, or the abstract initialization class abstract decision store can be inherited by means of extensions, and then the object initialization protocol implementation function init () and the object release protocol implementation function decision () can be rewritten and implemented.
And S230, in a life cycle starting function of the movable window object corresponding to the application program initial starting picture, respectively taking each target class as an input parameter, calling an object storage function through an object set, and storing the object to be initialized corresponding to each target class into the object set. And then performs S240 or S250.
And S240, respectively calling an object initialization function through each object to be initialized in the object set so as to initialize each object to be initialized.
And S250, calling a thread starting function through the thread class to open up a sub-thread.
The thread class is a class used for thread management in an Android system. The thread start function is a function in the thread class that is used to open up a new thread.
Specifically, after the object set is obtained, in order to increase the starting speed of the application program and reduce the display influence of the initialization operation on the first-time starting screen in the main thread, all the initialization operations are implemented by being set in the sub-thread in the present embodiment, so that the initialization operation is executed in parallel with the display operation in the main thread. In specific implementation, a Thread starting function start () in the Thread class Thread is called by the Thread class Thread to open up a new sub-Thread. An object initialization operation needs to be performed in the child thread subsequently. And then performs S260 or S270.
And S260, in the sub-thread, respectively calling an object initialization function through each object to be initialized in the object set so as to initialize each object to be initialized.
Specifically, all elements in the object set listiinithistory are traversed in the child thread, that is, first, the elements in the object set listiinithistory are sequentially taken out by the listiinithistory.
S270, in the sub-thread, sequentially obtaining the objects to be initialized from the object set according to the set time delay corresponding to the objects to be initialized, and calling the object initialization function through the functions to be initialized to initialize the objects to be initialized.
Specifically, since each basic function module has an execution sequence, an initialization time (a delay time with respect to a system time when an application is started) may be set for each object to be initialized or an initialization relative time, that is, a delay time, may be set for each two objects to be initialized. Therefore, the initialization operation can be executed in sequence according to the set delay instead of executing the initialization operation in batch within a certain time, so that the initialization efficiency can be improved to a certain extent, and the starting speed of the application program is further improved.
In specific implementation, according to the set delay corresponding to each object to be initialized, the object to be initialized corresponding to the set delay is timely taken out from the object set, and an object initialization function in the object to be initialized is called through the object to be initialized, so that the initialization operation of the object to be initialized is realized.
According to the technical scheme, the abstract initialization class inherits the universal initialization protocol through the protocol inheritance key words and rewrites each protocol function in the universal initialization protocol to obtain the abstract initialization class and each protocol implementation function of the universal initialization protocol type, and the target class inherits the abstract initialization class through the class extension key words and rewrites the object initialization implementation function in each protocol implementation function to obtain the target class and the object initialization function of the universal initialization protocol type. The method can realize selective shielding of protocol functions in the universal initialization protocol, increase the flexibility and compatibility of initialization logic, reduce invalid codes to a certain extent and further improve the code maintainability of the application program. The thread starting function is called through the thread class, the sub-thread is opened up, the object initialization operation of the basic function module is achieved in the sub-thread, the problem that the starting speed is low due to a large number of initialization operations in the starting process of the application program is solved, and the starting speed of the application program is improved. By setting the initialization delay for the object to be initialized in each basic function module, the initialization efficiency can be improved, and the starting speed of the application program can be further improved.
The following is an embodiment of an object initialization apparatus for a basic function module according to an embodiment of the present invention, which belongs to the same inventive concept as the object initialization method for the basic function module according to the above embodiments, and details that are not described in detail in the embodiment of the object initialization apparatus for the basic function module may refer to the embodiment of the object initialization method for the basic function module.
EXAMPLE III
The present embodiment provides an object initialization apparatus for basic function modules, referring to fig. 3, the apparatus specifically includes:
the object storage module 310 is configured to, in a life cycle initiation function of a moving window object corresponding to a first startup picture of an application program, respectively use each object class as an input parameter, call an object storage function through an object set, and store an object to be initialized corresponding to each object class into the object set;
an object initialization module 320, configured to call an object initialization function through each object to be initialized in the object set, respectively, so as to initialize each object to be initialized;
the target class is obtained based on a predefined universal initialization protocol, the universal initialization protocol comprises an object initialization protocol function, and the object set is a universal initialization protocol type.
Optionally, on the basis of the foregoing apparatus, the apparatus further includes a first target class definition module, configured to obtain the target class based on a predefined generic initialization protocol by:
the target class inherits the universal initialization protocol through the protocol inheriting key words and rewrites the object initialization protocol function to obtain the target class of the universal initialization protocol type and the object initialization function.
Further, the universal initialization protocol comprises an object release protocol function;
correspondingly, on the basis of the above device, the device further includes an object release function obtaining module, configured to:
after the target class inherits the universal initialization protocol through the protocol inheritance key words, the target class rewrites the object release protocol function to obtain the object release function.
Optionally, on the basis of the foregoing apparatus, the apparatus further includes a second target class definition module, configured to obtain the target class based on a predefined generic initialization protocol by:
the abstract initialization class inherits the universal initialization protocol through the protocol inheritance keyword and rewrites each protocol function in the universal initialization protocol to obtain the abstract initialization class and each protocol realization function of the universal initialization protocol type, wherein the abstract initialization class is provided with an abstract type modifier, and each protocol realization function is realized in a null mode;
the target class inherits the abstract initialization class through the class extension keywords and rewrites the object initialization realization function in each protocol realization function to obtain the target class and the object initialization function of the universal initialization protocol type.
Optionally, on the basis of the above device, the device further comprises a sub-thread tunneling module and a triggering module, wherein,
the sub-thread development module is used for calling a thread starting function through the thread class and developing a sub-thread;
and the triggering module is used for triggering and executing the step of calling the object initialization function through each object to be initialized in the object set respectively so as to initialize each object to be initialized in the sub-thread.
Optionally, the object initialization module 320 is specifically configured to:
and sequentially acquiring each object to be initialized from the object set according to the set delay corresponding to each object to be initialized, and calling an object initialization function through the function to be initialized so as to initialize each object to be initialized.
Optionally, the object storage module 310 includes a function execution sub-module, configured to implement a function of storing the object to be initialized corresponding to each target class into the object set by:
respectively generating instantiation objects corresponding to the target classes by using the instantiation keywords;
and respectively taking each instantiation object as an input parameter, calling an element adding function of the object set, and storing each instantiation object to the object set.
Through the object initialization device of the basic function module in the third embodiment of the invention, the initialization operation is split into each target class, the decoupling of the initialization code and the application class code is achieved, and the code maintainability of the application program is improved.
The object initialization device of the basic function module provided by the embodiment of the invention can execute the object initialization method of the basic function module provided by any embodiment of the invention, and has the corresponding function module and beneficial effects of the execution method.
It should be noted that, in the embodiment of the object initialization apparatus for basic function modules, each included unit and module are only divided according to functional logic, but are not limited to the above division as long as the corresponding function can be realized; in addition, specific names of the functional units are only for convenience of distinguishing from each other, and are not used for limiting the protection scope of the present invention.
Example four
Referring to fig. 4, the present embodiment provides an apparatus 400 comprising: one or more processors 420; the storage device 410 is used for storing one or more programs, and when the one or more programs are executed by the one or more processors 420, the one or more processors 420 implement the method for initializing the object of the basic function module according to the embodiment of the present invention, including:
in a life cycle starting function of a movable window object corresponding to an application program initial starting picture, respectively taking each target class as an input parameter, calling an object storage function through an object set, and storing an object to be initialized corresponding to each target class into the object set;
respectively calling an object initialization function through each object to be initialized in the object set so as to initialize each object to be initialized;
the target class is obtained based on a predefined universal initialization protocol, the universal initialization protocol comprises an object initialization protocol function, and the object set is a universal initialization protocol type.
Of course, those skilled in the art will understand that the processor 420 may also implement the technical solution of the object initialization method of the basic function module provided in any embodiment of the present invention.
The apparatus 400 shown in fig. 4 is only an example and should not bring any limitations to the functionality or scope of use of the embodiments of the present invention. As shown in fig. 4, the apparatus 400 includes a processor 420, a storage device 410, an input device 430, and an output device 440; the number of the processors 420 in the device may be one or more, and one processor 420 is taken as an example in fig. 4; the processor 420, the storage device 410, the input device 430 and the output device 440 of the apparatus may be connected by a bus or other means, for example, the bus 450 in fig. 4.
The storage device 410, which is a computer-readable storage medium, may be used to store software programs, computer-executable programs, and modules, such as program instructions/modules corresponding to the object initialization method of the basic function block in the embodiments of the present invention (e.g., an object storage module and an object initialization module in an object initialization device of the basic function block).
The storage device 410 may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required for at least one function; the storage data area may store data created according to the use of the terminal, and the like. Further, the storage 410 may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other non-volatile solid state storage device. In some examples, the storage 410 may further include memory located remotely from the processor 420, which may be connected to the device over a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The input means 430 may be used to receive input numeric or character information and generate key signal inputs related to user settings and function control of the apparatus. The output device 440 may include a display device such as a display screen.
EXAMPLE five
The present embodiments provide a storage medium containing computer-executable instructions which, when executed by a computer processor, perform a method of object initialization of a base function module, the method comprising:
in a life cycle starting function of a movable window object corresponding to an application program initial starting picture, respectively taking each target class as an input parameter, calling an object storage function through an object set, and storing an object to be initialized corresponding to each target class into the object set;
respectively calling an object initialization function through each object to be initialized in the object set so as to initialize each object to be initialized;
the target class is obtained based on a predefined universal initialization protocol, the universal initialization protocol comprises an object initialization protocol function, and the object set is a universal initialization protocol type.
Of course, the storage medium provided by the embodiment of the present invention contains computer-executable instructions, and the computer-executable instructions are not limited to the above method operations, and may also perform related operations in the object initialization method of the basic function module provided by any embodiment of the present invention.
From the above description of the embodiments, it is obvious for those skilled in the art that the present invention can be implemented by software and necessary general hardware, and certainly, can also be implemented by hardware, but the former is a better embodiment in many cases. Based on such understanding, the technical solutions of the present invention may be embodied in the form of a software product, which may be stored in a computer-readable storage medium, such as a floppy disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a FLASH Memory (FLASH), a hard disk or an optical disk of a computer, and includes several instructions to enable a device (which may be a mobile phone, a personal computer, or a network device) to execute the object initialization method of the basic function module provided in the embodiments of the present invention.
It is to be noted that the foregoing is only illustrative of the preferred embodiments of the present invention and the technical principles employed. It will be understood by those skilled in the art that the present invention is not limited to the particular embodiments described herein, but is capable of various obvious changes, rearrangements and substitutions as will now become apparent to those skilled in the art without departing from the scope of the invention. Therefore, although the present invention has been described in greater detail by the above embodiments, the present invention is not limited to the above embodiments, and may include other equivalent embodiments without departing from the spirit of the present invention, and the scope of the present invention is determined by the scope of the appended claims.

Claims (9)

1. An object initialization method for a basic function module, comprising:
in a life cycle starting function of a movable window object corresponding to an application program initial starting picture, respectively taking each target class as an input parameter, calling an object storage function through an object set, and storing an object to be initialized corresponding to each target class into the object set;
respectively calling an object initialization function through each object to be initialized in the object set so as to initialize each object to be initialized;
the target class is obtained based on a predefined universal initialization protocol, the universal initialization protocol comprises an object initialization protocol function, and the object set is a universal initialization protocol type; wherein the target class is obtained based on a predefined generic initialization protocol by:
and the target class inherits the universal initialization protocol through the protocol inheritance keyword and rewrites the object initialization protocol function to obtain the target class and the object initialization function of the universal initialization protocol type.
2. The method according to claim 1, wherein the generic initialization protocol includes an object release protocol function;
correspondingly, after the target class inherits the generic initialization protocol through a protocol inheritance key, the method further comprises the following steps:
and the target class duplicates the object release protocol function to obtain an object release function.
3. The method of claim 1, wherein the target class is obtained based on a predefined generic initialization protocol by:
the abstract initialization class inherits the universal initialization protocol through a protocol inheritance keyword and rewrites each protocol function in the universal initialization protocol to obtain the abstract initialization class and each protocol realization function of the universal initialization protocol type, wherein the abstract initialization class is provided with an abstract type modifier, and each protocol realization function is realized in a null mode;
and the target class inherits the abstract initialization class through a class extension key word and rewrites an object initialization realization function in each protocol realization function to obtain the target class and the object initialization function of a general initialization protocol type.
4. The method according to claim 1, further comprising, after storing the object to be initialized corresponding to each of the target classes in the object set, the steps of:
calling a thread starting function through the thread class to open up a sub-thread;
and in the sub-thread, triggering and executing the step of calling an object initialization function through each object to be initialized in the object set respectively so as to initialize each object to be initialized.
5. The method according to any one of claims 1 to 4, wherein the step of calling an object initialization function through each object to be initialized in the object set respectively to initialize each object to be initialized comprises:
and sequentially acquiring the objects to be initialized from the object set according to the set time delay corresponding to the objects to be initialized, and calling the object initialization function through the functions to be initialized so as to initialize the objects to be initialized.
6. The method according to claim 1, wherein the object storage function implements a function of storing the object to be initialized corresponding to each target class into the object set by:
respectively generating instantiation objects corresponding to the target classes by using the instantiation keywords;
and calling an element adding function of the object set by taking each instantiation object as an input parameter, and storing each instantiation object to the object set.
7. An object initialization apparatus of a basic function module, comprising:
the object storage module is used for calling an object storage function through an object set by respectively taking each object class as an input parameter in a life cycle starting function of a movable window object corresponding to an application program initial starting picture, and storing an object to be initialized corresponding to each object class into the object set;
an object initialization module, configured to call an object initialization function through each object to be initialized in the object set, respectively, so as to initialize each object to be initialized;
the target class is obtained based on a predefined universal initialization protocol, the universal initialization protocol comprises an object initialization protocol function, and the object set is a universal initialization protocol type;
the apparatus further includes a first target class definition module for obtaining a target class based on a predefined generic initialization protocol by:
and the target class inherits the universal initialization protocol through the protocol inheritance keyword and overwrites the object initialization protocol function to obtain the target class and the object initialization function of the universal initialization protocol type.
8. A computer device, the device comprising:
one or more processors;
a storage device to store one or more programs,
when executed by the one or more processors, cause the one or more processors to implement the object initialization method of the basic function module as claimed in any one of claims 1 to 6.
9. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the object initialization method of the basic function module according to any one of claims 1 to 6.
CN201910299545.XA 2019-04-15 2019-04-15 Object initialization method, device, equipment and storage medium of basic function module Active CN110045997B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910299545.XA CN110045997B (en) 2019-04-15 2019-04-15 Object initialization method, device, equipment and storage medium of basic function module

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910299545.XA CN110045997B (en) 2019-04-15 2019-04-15 Object initialization method, device, equipment and storage medium of basic function module

Publications (2)

Publication Number Publication Date
CN110045997A CN110045997A (en) 2019-07-23
CN110045997B true CN110045997B (en) 2022-07-05

Family

ID=67277050

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910299545.XA Active CN110045997B (en) 2019-04-15 2019-04-15 Object initialization method, device, equipment and storage medium of basic function module

Country Status (1)

Country Link
CN (1) CN110045997B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110928548B (en) * 2019-11-14 2023-08-22 腾讯音乐娱乐科技(深圳)有限公司 Data processing method and device
CN110750315B (en) * 2019-12-23 2020-06-02 武汉斗鱼鱼乐网络科技有限公司 Class loading method, device, equipment and storage medium in Android system

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1820266A (en) * 2003-08-21 2006-08-16 微软公司 System and methods for interfacing application programs with item-based storage platform
US8089649B2 (en) * 2005-09-30 2012-01-03 Brother Kogyo Kabushiki Kaisha Multi function peripheral
CN106415495A (en) * 2014-05-30 2017-02-15 苹果公司 Programming system and language for application development
CN108279940A (en) * 2016-12-30 2018-07-13 华为软件技术有限公司 A kind of module loading method and apparatus in web container
CN109032815A (en) * 2018-07-18 2018-12-18 武汉斗鱼网络科技有限公司 Information interacting method, device, equipment and storage medium between functional module
CN109144520A (en) * 2018-09-03 2019-01-04 武汉斗鱼网络科技有限公司 Information interaction method, device, equipment and storage medium among different objects in Android
CN109582394A (en) * 2018-12-07 2019-04-05 武汉斗鱼鱼乐网络科技有限公司 A kind of application program launching method, device and storage medium

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1820266A (en) * 2003-08-21 2006-08-16 微软公司 System and methods for interfacing application programs with item-based storage platform
US8089649B2 (en) * 2005-09-30 2012-01-03 Brother Kogyo Kabushiki Kaisha Multi function peripheral
CN106415495A (en) * 2014-05-30 2017-02-15 苹果公司 Programming system and language for application development
CN108279940A (en) * 2016-12-30 2018-07-13 华为软件技术有限公司 A kind of module loading method and apparatus in web container
CN109032815A (en) * 2018-07-18 2018-12-18 武汉斗鱼网络科技有限公司 Information interacting method, device, equipment and storage medium between functional module
CN109144520A (en) * 2018-09-03 2019-01-04 武汉斗鱼网络科技有限公司 Information interaction method, device, equipment and storage medium among different objects in Android
CN109582394A (en) * 2018-12-07 2019-04-05 武汉斗鱼鱼乐网络科技有限公司 A kind of application program launching method, device and storage medium

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
Android Module Architecture;axway;《https://docs.axway.com/bundle/Titanium_SDK_allOS_en/page/android_module_architecture.html》;20170927;全文 *
Android组件化方案实践与思考;HZWei7;《https://www.jianshu.com/p/2309cd90ef2c#comments》;20181021;全文 *
App 组件化/模块化之路——Android 框架组件(Android Architecture Components)使用指南;hylinux1024;《https://www.cnblogs.com/angrycode/p/7287242.html》;20170804;全文 *

Also Published As

Publication number Publication date
CN110045997A (en) 2019-07-23

Similar Documents

Publication Publication Date Title
CN111176802B (en) Task processing method and device, electronic equipment and storage medium
CN111026396B (en) Page rendering method and device, electronic equipment and storage medium
CN103345405B (en) Application program starting method and device and client
CN110750315B (en) Class loading method, device, equipment and storage medium in Android system
US10977101B2 (en) Interoperability between programs associated with different addressing modes
CN110045997B (en) Object initialization method, device, equipment and storage medium of basic function module
CN113641338B (en) Method and device for dynamically generating view component
CN110945475A (en) System and method for providing patchable ROM firmware
CN113190282A (en) Android operating environment construction method and device
CN107402792B (en) Integration method, device, equipment and storage medium of application software installation package
CN116107669B (en) Operator registration method, device and equipment of deep learning framework and storage medium
US11010144B2 (en) System and method for runtime adaptable applications
WO2021097683A1 (en) Android system starting method and apparatus, device, and storage medium
WO2023124657A1 (en) Micro-application running method and apparatus, device, storage medium, and program product
CN109947488B (en) Object initialization method, device, equipment and storage medium of universal function module
CN108153564B (en) Interface management method, device and system and computer readable storage medium
CN116107590A (en) Implementation method and system for compatible micro-service and monomer architecture in software product development and deployment
CN113805954A (en) Screen saver display method, electronic device, and computer storage medium
CN114911541A (en) Configuration information processing method and device, electronic equipment and storage medium
CN114741121A (en) Method and device for loading module and electronic equipment
CN114385174A (en) Compiling method, device, equipment and storage medium of functional module
CN113050962A (en) Mobile service upgrading method, device and terminal
CN111124386A (en) Unity-based animation event processing method, device, equipment and storage medium
CN116700694B (en) Applet engine
CN110647405A (en) System message processing method, electronic device, and computer-readable storage medium

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