CN110045997A - Object initialization method, apparatus, equipment and the storage medium of fundamental functional modules - Google Patents

Object initialization method, apparatus, equipment and the storage medium of fundamental functional modules Download PDF

Info

Publication number
CN110045997A
CN110045997A CN201910299545.XA CN201910299545A CN110045997A CN 110045997 A CN110045997 A CN 110045997A CN 201910299545 A CN201910299545 A CN 201910299545A CN 110045997 A CN110045997 A CN 110045997A
Authority
CN
China
Prior art keywords
initialization
function
initiated
class
target 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.)
Granted
Application number
CN201910299545.XA
Other languages
Chinese (zh)
Other versions
CN110045997B (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

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

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)

Abstract

The embodiment of the invention discloses object initialization method, apparatus, equipment and the storage mediums of a kind of fundamental functional modules.This method comprises: in application program for the first time the life cycle starting function of the corresponding active window object of start picture, it is respectively input parameter with each target class, object storage function is called by object set, the corresponding object to be initiated of each target class is stored to object set;Respectively by each object reference object initialization function to be initiated in object set, to initialize each object to be initiated;Wherein, target class is based on general initialization agreement predetermined and obtains, and includes object initialization protocol function in general initialization agreement, and object set is general initialization protocol type.Initialization operation is split into each target class through the above technical solutions, realizing, has reached the decoupling of initial code and application category code, has improved the code maintainability of application program.

Description

Object initialization method, apparatus, equipment and the storage medium of fundamental functional modules
Technical field
The present embodiments relate to computer technology more particularly to a kind of object initialization method of fundamental functional modules, Device, equipment and storage medium.
Background technique
Currently, in the application programming based on android system exploitation, it can be by the initialization operation of some functional modules Setting is realized in the corresponding application class Application of the application program, can quickly be accessed accordingly initially so as to subsequent Change object, above-mentioned functional module can be described as fundamental functional modules.Such design meeting is so that non-using the initialization logic in class Chang Duo causes the corresponding class of fundamental functional modules and application class coupling excessively high, is unfavorable for the code maintenance of entire application program. Such as be likely to impact other business when modifying the correlative code of application program every time, it is asked so as to cause some new Topic occurs.
Summary of the invention
The embodiment of the present invention provides object initialization method, apparatus, equipment and the storage medium of a kind of fundamental functional modules, With the optimization of optimized integration functional module initialization logic, to reduce the code coupling in application program, improves and apply journey The code maintainability of sequence.
In a first aspect, the embodiment of the invention provides a kind of object initialization methods of fundamental functional modules, comprising:
In application program for the first time the life cycle starting function of the corresponding active window object of start picture, respectively with each Target class is input parameter, calls object storage function by object set, and each target class is corresponding to be initiated Object is stored to the object set;
Respectively by each object reference object initialization function to be initiated in the object set, with initialization Each object to be initiated;
Wherein, target class is based on general initialization agreement predetermined and obtains, and wraps in the general initialization agreement Protocol function containing object initialization, the object set are general initialization protocol type.
Second aspect, the embodiment of the invention also provides a kind of object initialization device of fundamental functional modules, the devices Include:
Object storage module, for application program for the first time the corresponding active window object of start picture life cycle rise In beginning function, it is respectively input parameter with each target class, object storage function is called by object set, by each target The corresponding object to be initiated of class is stored to the object set;
Object initialization module, for passing through each object reference object to be initiated in the object set respectively Initialization function, to initialize each object to be initiated;
Wherein, target class is based on general initialization agreement predetermined and obtains, and wraps in the general initialization agreement Protocol function containing object initialization, the object set are general initialization protocol type.
The third aspect, the embodiment of the invention also provides a kind of equipment, which includes:
One or more processors;
Storage device, for storing one or more programs,
When one or more of programs are executed by one or more of processors, so that one or more of processing Device realizes the object initialization method of fundamental functional modules provided by any embodiment of the invention.
Fourth aspect, the embodiment of the invention also provides a kind of computer readable storage mediums, are stored thereon with computer Program, the computer program realize the object of fundamental functional modules provided by any embodiment of the invention when being executed by processor Initial method.
The embodiment of the present invention by application program for the first time the corresponding active window object of start picture life cycle rise Object initialization operation is executed in beginning function, reducing object initialization operation influences the display of start picture for the first time, improves The display speed of start picture for the first time.By calling object to deposit by object set respectively with each target class to input parameter Function is stored up, the corresponding object to be initiated of each target class is stored to object set, and target class is based on predetermined lead to Obtained with initializtion protocol, realize by all objects to be initiated based on the same general initialization agreement store to In object set, to carry out unified initialization management.By the inclusion of the general initialization agreement of object initialization protocol function Each target class is pre-defined, and respectively by each object reference object initialization function to be initiated in object set, To initialize each object to be initiated, realizes and split initialization operation into each target class, reached initial code With the decoupling of application category code, the code maintainability of application program is improved.
Detailed description of the invention
Fig. 1 is the flow chart of the object initialization method of one of the embodiment of the present invention one fundamental functional modules;
Fig. 2 is the flow chart of the object initialization method of one of the embodiment of the present invention two fundamental functional modules;
Fig. 3 is the structural schematic diagram of the object initialization device of one of the embodiment of the present invention three fundamental functional modules;
Fig. 4 is the structural schematic diagram of one of the embodiment of the present invention four equipment.
Specific embodiment
The present invention is described in further detail with reference to the accompanying drawings and examples.It is understood that this place is retouched The specific embodiment stated is used only for explaining the present invention rather than limiting the invention.It also should be noted that in order to just Only the parts related to the present invention are shown in description, attached drawing rather than entire infrastructure.
Embodiment one
The object initialization method of fundamental functional modules provided in this embodiment is applicable to develop based on android system Application program launching when fundamental functional modules initialization.This method can be by the object initialization device of fundamental functional modules It executes, which can be realized by the mode of software and/or hardware, which, which can integrate, is carrying android system In equipment, such as typically subscriber terminal equipment, such as mobile phone, tablet computer or smart television etc..Referring to Fig. 1, this implementation Example method include:
S110, in application program for the first time the life cycle starting function of the corresponding active window object of start picture, point It is not input parameter with each target class, object storage function is called by object set, each target class is corresponding to initial Change object to store to object set.
Wherein, active window object refers to the corresponding object that an active window activity is constructed in initialization.It is raw Life period starting function OnCreat refers to object function that system is called automatically in creation.Target class refers to needs just The class of beginningization object is also possible to the corresponding class of fundamental functional modules, such as can be the corresponding log class of log module and net Corresponding network class of network module etc..Illustratively, target class is based on general initialization agreement predetermined and obtains, general first It include object initialization protocol function in beginningization agreement.That is target class is predetermined, and it is based on fixed in advance The general initialization agreement of justice defines, which is to realize object initialization and specially design one Agreement, it is interior to include at least object initialization protocol function.For example, realizing the definition code of general initialization agreement with interface It can be with are as follows: public interface IinitDestory { public void init ();, wherein IinitDestory is just For the title of general initialization agreement, which is the interface protocol of a publicly-owned public type, other classes Has the permission for accessing the agreement.Init () is object initialization protocol function, subsequent in the protocol function to can be used for realizing pair The initialization operation of elephant.Object set be it is predetermined, for storing the set of each object to be initiated, the object set For the general initialization protocol type with global scope.The definition code example of object set listIinitDestory is such as Under: private List<IinitDestory>listIinitDestory.Object storage function is member's letter of object set Number, is used to store function input parameters into object set, the input parameter of object storage function in the embodiment of the present invention It just is object to be initiated.Here object to be initiated is the instance object of target class.
Specifically, in application program launching, a splashette page can be started first, commonly used in showing the wide of setting Accuse the page.The advertisement page is usually the time for needing to stop several seconds, therefore it is next to can use this section of advertisement page residence time Complete the initialization operation of object to be initiated.So the operation setting of object initialization is being applied in the embodiment of the present invention It is executed when first splashette page load of program starting, that is, in the application program corresponding activity of start picture for the first time It is executed in the life cycle starting function of window object SplachActivity.This way it is not necessary in the same of starting application program The initialization of all fundamental functional modules of Shi Shixian, and it is only first splashette page of starting, it can be improved opening for advertisement page Dynamic speed.
In addition, by the initialization operation of each fundamental functional modules from the application of application program launching in the embodiment of the present invention It splits in Application class into each target class, it is subsequent that different fundamental functional modules are realized according to each target class Object initialization operation, to realize the decoupling of initialization logic and application class.So operating it executing object initialization Before, it needs to pre-define each target class based on general initialization agreement predetermined.The definition of target class can be directly General initialization agreement is inherited, indirect succession general initialization agreement is also possible to.
Illustratively, target class is based on general initialization agreement predetermined in the following way and obtains: target class General initialization agreement is inherited by protocol inheritance keyword, and makes carbon copies object initialization protocol function, obtains general initialization The target class and object initialization function of protocol type.Specifically, target class directly passes through protocol inheritance keyword Implements inherits general initialization agreement IinitDestory, and makes carbon copies and realize to include object in general initialization agreement All protocol functions including initializtion protocol function are generated and are realized comprising all functions including object initialization function.It can With understanding, with all functions in general initialization agreement in the target class that obtains through the above way.With network class For the definition of NetModule, code is realized can be with are as follows:
Thus the object initialization of network class can be operated to split into network module and realized, reach initialization behaviour Make the effect split and code decouples.
When it is implemented, in life cycle starting function onCreate, to object set listIinitDestory into Row initialization operation, specific initial code example be listIinitDestory=new ArrayList < IinitDestory > () realizes the process of initialization by the constructed fuction of invocation list List to object set. Later, just pass through object set listIinitDestory every time with a target class to input parameter and object is called to store letter Number, the corresponding object to be initiated of each target class is stored to object set.Object set listIinitDestory in this way In just contain the information of all objects to be initiated, it is subsequent to carry out object initialization operation based on the object set, Realize the unified management of the initialization operation to all objects to be initiated.
It should be noted that needing to carry out instantiation operation to target class in object storage function, to generate each mesh Mark the corresponding object to be initiated of class.By taking the addition of the object to be initiated of network class as an example, the element of object set can be added Add the function input parameters of function add () to be set as the operation of instantiation target class, that is, passes through object set ListIinitDestory calls the element in it to add function add (), and the input parameter of add function is that instantiation is crucial Word new and network class NetModule, code implementation example are listIinitDestory.add (new NetModule ())。
Illustratively, object storage function is realized in the following way deposits the corresponding object to be initiated of each target class It stores up to the function of object set: being utilized respectively instantiation keyword and generate the corresponding instance object of each target class;Respectively with each Instance object is input parameter, calls the element of object set to add function, each instance object is stored to object set It closes.Specifically, the operation of examples detailed above keyword new and element addition function add () can be encapsulated in a function, I.e. in object storage function, to facilitate developer directly to carry out function call, development efficiency is improved.
S120, respectively by each object reference object initialization function to be initiated in object set, it is each to initialize Object to be initiated.
Specifically, it when carrying out object initialization, needs first to take out object to be initiated from object set, then pass through Object initialization function of the object reference to be initiated in it realizes the initialization of the object to be initiated.Traverse object collection It closes, and is performed both by aforesaid operations for each object to be initiated, can uniformly complete the initialization behaviour of object to be initiated Make.
The technical solution of the present embodiment passes through the life in the application program corresponding active window object of start picture for the first time Object initialization operation is executed in period starting function, reduces object initialization operation to the display shadow of start picture for the first time It rings, improves the display speed of start picture for the first time.By being called by object set respectively with each target class to input parameter Object storage function stores the corresponding object to be initiated of each target class to object set, and target class is based on determining in advance Justice general initialization agreement and obtain, realize all objects to be initiated based on the same general initialization agreement are equal It stores into object set, to carry out unified initialization management.By the inclusion of the general initial of object initialization protocol function Change agreement to pre-define each target class, and passes through each object reference object initialization to be initiated in object set respectively Function realizes to initialize each object to be initiated and splits initialization operation into each target class, reached initialization The decoupling of code and application category code, improves the code maintainability of application program.
Illustratively, based on the above technical solution, protocol function is discharged comprising object in general initialization agreement; Correspondingly, after target class inherits general initialization agreement by protocol inheritance keyword, further includes: target class makes carbon copies object Protocol function is discharged, object is obtained and discharges function.
Specifically, object is set in general initialization agreement and discharges protocol function, i.e., in general initialization protocol definition When, increase the protocol function public void destory () in it.So, pass through protocol inheritance keyword in target class When implements inherits general initialization agreement, need to make carbon copies and realize object therein release protocol function just to generate pair As discharging function.The object discharges function when application program exits, and needs to be called, to pass through object initialization before release The object that function generates.The advantages of this arrangement are as follows the release that developer can be reminded to carry out object in time operates, thus The problem of evading memory overflow.
Embodiment two
The present embodiment on the basis of the above embodiments, to " target class be based on general initialization agreement predetermined and Obtain " it is advanced optimized.On this basis, the operation for opening up sub thread can also be increased.On the basis of the above, may be used also With further to " respectively by each object reference object initialization function to be initiated in object set, with initialize respectively to Initialization object " optimizes.Wherein details are not described herein for the explanation of term identical or corresponding with the various embodiments described above.Referring to The object initialization method of Fig. 2, fundamental functional modules provided in this embodiment includes:
S210, abstract initialization class inherit general initialization agreement by protocol inheritance keyword, and make carbon copies general initial Change each protocol function in agreement, the abstract initialization class of acquisition general initialization protocol type and each protocol realization function.
Wherein, it is abstracted initialization class and refers to the abstract class with function of initializing, i.e., abstract initialization class has abstract class Type modifier abstract.Protocol realization function, which refers to, to be realized the protocol function addition function in general initialization agreement and obtains The function obtained.
Specifically, for initialization logic in optimization aim class, the function in target class is enabled to be compatible with different answer Only object initialization is needed to operate with demand, such as the target class having, some target class only need object release operation, and have Target class needs to initialize and discharge simultaneously to be operated, in the present embodiment when defining target class based on general initialization agreement, Devise an abstract initialization class first to inherit general initialization agreement, then this is abstract initial by each target Similar integral again Change class.Wherein, in abstract initialization Similar integral general initialization agreement, in order to ensure in succeeding target class each function from Definition is realized, when abstract initialization class makes carbon copies each protocol function, function realization is all set to empty real and is showed, i.e., each agreement Realize that function is that empty real is existing, there is no specific functions to realize inside function.
For example, design one abstract initialization class AbsinitDestory, definition code example are as follows:
The access authority of above-mentioned abstract initialization class AbsinitDestory is public permission public, in this way other classes Has the permission of the abstract initialization class AbsinitDestory of access, and AbsinitDestory class has used abstract type modification Abstract is accorded with, such AbsinitDestory class is exactly an abstract class.Abstract initialization class AbsinitDestory passes through Protocol inheritance keyword implements inherits general initialization agreement IinitDestory, while needing to make carbon copies and realize general Each protocol function in initializtion protocol IinitDestory, such as object initialization protocol function init () and object release association It discusses function destory (), obtain the abstract initialization class AbsinitDestory of general initialization protocol type and its interior includes Object initialization protocol realization function and object discharge protocol realization function, not set tool in two protocol realization functions The function of body realizes code, and as empty real is existing.
S220, target class extend keyword by class and inherit abstract initialization class, and make carbon copies in each protocol realization function Object initialization realizes function, obtains the target class and object initialization function of general initialization protocol type.
Specifically, the manifolding that each target class passes through the succession to abstract initialization class and the protocol realization function needed for it To realize the definition of target class.
Such as target class is a view controller class MyController, only needs initialization process, i.e., only needs pair As initialization function.So acquisition process of the object initialization function of the definition and its inside of view controller class are as follows: view Controller class MyController extends keyword extends by class and inherits abstract initialization class AbsinitDestory, this Sample view controller class MyController just has the function of abstract class AbsinitDestory.Due to view controller Class MyController only needs initialization process, therefore only needs to make carbon copies and realize in view controller class MyController Object initialization protocol realization function, code realization can be illustrated as follows:
Mode by then passing through extends inherits abstract initialization class AbsinitDestory, if you do not need to object Process is discharged, does not make carbon copies object release protocol realization function destory () in view controller class MyController at this time , just realized in view controller class MyController in this way and only have object initialization function init () without right As discharging function destory ().
Similarly, it if object is only needed to discharge function destory (), and is inherited by way of extends Abstract initialization class AbsinitDestory, then makes carbon copies and realizes destory () therein, without making carbon copies init (), It thereby realizes only object and discharges process without the function of object initialization process.If both having needed object initialization stream Journey needs object to discharge process again, then the scheme of embodiment one can be used to realize, or can also pass through extends's Mode is abstracted initialization class AbsinitDestory to inherit, and then makes carbon copies and realizes object initialization protocol realization letter therein Number init () and object release protocol realization function destory ().
S230, in application program for the first time the life cycle starting function of the corresponding active window object of start picture, point It is not input parameter with each target class, object storage function is called by object set, each target class is corresponding to initial Change object to store to object set.Then execute S240 or S250.
S240, respectively by each object reference object initialization function to be initiated in object set, it is each to initialize Object to be initiated.
S250, thread run function is called by thread class, opens up sub thread.
Wherein, thread class is in android system for carrying out the class of thread management.Thread run function is in thread class Function for the journey that opens new routes.
Specifically, after obtaining object set, in order to improve the starting speed of application program and reduce initialization operation On the display of start picture influences for the first time in main thread, all initialization operations are arranged in sub thread in the present embodiment It realizes, so that initialization operation and the display operation in main thread execute parallel.When it is implemented, passing through thread class Thread Thread run function start () therein, i.e. Thread.start () are called, to open up new sub thread.Subsequent needs are at this Object initialization operation is executed in sub thread.S260 or S270 is executed later.
S260, in sub thread, respectively by each object reference object initialization function to be initiated in object set, To initialize each object to be initiated.
Specifically, all elements in sub thread in traverse object set listIinitDestory, that is, first pass through ListIinitDestory.get (i) method successively takes out the element in object set listIinitDestory, and (wherein i is time Go through index), the object initialization function of the element is then called, particular by listIinitDestory.get (i) .init () Lai Shixian's, it thus may be implemented the unified call of the object initialization function of all target class, and by initialization Actual functional capability, which is distributed to inside each fundamental functional modules, to be executed and is handled.
S270, in sub thread, according to the corresponding setting delay of each object to be initiated, successively obtained from object set Each object to be initiated, and by function call object initialization function to be initiated, to initialize each object to be initiated.
It specifically, since each fundamental functional modules have the sequencing of execution, therefore can be each object to be initiated Initialization time (delay of system time when relative to application program launching) is set or is arranged for every two object to be initiated Relative time is initialized, i.e. setting delay.Initialization operation can be sequentially executed according to setting delay in this way, rather than Initialization operation is executed in certain time in large quantity, therefore initialization efficiency can be improved to a certain extent, further increases and answers With the starting speed of program.
When it is implemented, being delayed according to the corresponding setting of each object to be initiated, in time taken out from object set The corresponding object to be initiated of setting delay, and by the object reference object initialization function therein to be initiated, with reality The now initialization operation of the object to be initiated.
The technical solution of the present embodiment inherits general initialization association by protocol inheritance keyword by abstract initialization class View, and makes carbon copies each protocol function in general initialization agreement, obtain general initialization protocol type abstract initialization class and Each protocol realization function and target class extend keyword by class and inherit abstract initialization class, and make carbon copies each protocol realization function In object initialization realize function, obtain general initialization protocol type target class and object initialization function.It can be real The selectively masking of protocol function, increases the flexibility and compatibility of initialization logic, also can in existing general initialization agreement Invalid code is reduced to a certain extent, further increases the code maintainability of application program.Thread is called to open by thread class Dynamic function, opens up sub thread, with the object initialization operation of the optimized integration functional module in sub thread, solves application program The slow-footed problem of starting caused by a large amount of initialization operations, improves the starting speed of application program in start-up course.Pass through For the object to be initiated setting initialization delay in each fundamental functional modules, initialization efficiency can be improved, thus into one Step improves the starting speed of application program.
The embodiment of the object initialization device of fundamental functional modules provided in an embodiment of the present invention below, the device with The object initialization method of the fundamental functional modules of the various embodiments described above belongs to the same inventive concept, in fundamental functional modules The detail content of not detailed description in the embodiment of object initialization device, can be with reference at the beginning of the object of above-mentioned fundamental functional modules The embodiment of beginning method.
Embodiment three
The present embodiment provides a kind of object initialization devices of fundamental functional modules, and referring to Fig. 3, which is specifically included:
Object storage module 310, for the Life Cycle in the application program corresponding active window object of start picture for the first time In phase starting function, it is respectively input parameter with each target class, object storage function is called by object set, by each target The corresponding object to be initiated of class is stored to object set;
Object initialization module 320, it is initial for passing through each object reference object to be initiated in object set respectively Change function, to initialize each object to be initiated;
Wherein, target class is based on general initialization agreement predetermined and obtains, and includes pair in general initialization agreement As initializtion protocol function, object set is general initialization protocol type.
Optionally, on the basis of above-mentioned apparatus, which further includes first object class definition module, for by as follows Mode is based on general initialization agreement predetermined and obtains target class:
Target class inherits general initialization agreement by protocol inheritance keyword, and makes carbon copies object initialization protocol function, Obtain the target class and object initialization function of general initialization protocol type.
Further, protocol function is discharged comprising object in general initialization agreement;
Correspondingly, on the basis of above-mentioned apparatus, which further includes that object release function obtains module, is used for:
After target class inherits general initialization agreement by protocol inheritance keyword, target class makes carbon copies object release association Function is discussed, object is obtained and discharges function.
Optionally, on the basis of above-mentioned apparatus, which further includes the second target class definition module, for by as follows Mode is based on general initialization agreement predetermined and obtains target class:
Abstract initialization class inherits general initialization agreement by protocol inheritance keyword, and makes carbon copies general initialization agreement In each protocol function, obtain general initialization protocol type abstract initialization class and each protocol realization function, wherein it is abstract Initializing class has abstract type modifier, and each protocol realization function is that empty real is existing;
Target class extends keyword by class and inherits abstract initialization class, and at the beginning of making carbon copies the object in each protocol realization function Beginningization realizes function, obtains the target class and object initialization function of general initialization protocol type.
Optionally, on the basis of above-mentioned apparatus, which further includes that sub thread opens up module and trigger module, wherein
Sub thread opens up module, for calling thread run function by thread class, opens up sub thread;
Trigger module, in sub thread, triggering to be executed respectively through each object tune to be initiated in object set With object initialization function, the step of to initialize each object to be initiated.
Optionally, object initialization module 320 is specifically used for:
According to the corresponding setting delay of each object to be initiated, each object to be initiated is successively obtained from object set, And by function call object initialization function to be initiated, to initialize each object to be initiated.
Optionally, object storage module 310 includes function implementation sub-module, for being realized in the following way by each mesh The corresponding object to be initiated of mark class is stored to the function of object set:
It is utilized respectively instantiation keyword and generates the corresponding instance object of each target class;
It is respectively input parameter with each instance object, calls the element of object set to add function, by each instantiation Object is stored to object set.
The object initialization device of three a kind of fundamental functional modules through the embodiment of the present invention realizes and grasps initialization It splits into each target class, has reached the decoupling of initial code and application category code, improved the code of application program It is maintainable.
The executable present invention of the object initialization device of fundamental functional modules provided by the embodiment of the present invention is any to be implemented The object initialization method of fundamental functional modules provided by example, has the corresponding functional module of execution method and beneficial effect.
It is worth noting that, included is each in the embodiment of the object initialization device of above-mentioned fundamental functional modules Unit and module are only divided according to the functional logic, but are not limited to the above division, as long as can be realized corresponding Function;In addition, the specific name of each functional unit is also only for convenience of distinguishing each other, it is not intended to restrict the invention Protection scope.
Example IV
Referring to fig. 4, a kind of equipment 400 is present embodiments provided comprising: one or more processors 420;Storage device 410, for storing one or more programs, when one or more programs are executed by one or more processors 420, so that one Or multiple processors 420 realize the object initialization method of fundamental functional modules provided by the embodiment of the present invention, comprising:
In application program for the first time the life cycle starting function of the corresponding active window object of start picture, respectively with each Target class is input parameter, object storage function is called by object set, by the corresponding object to be initiated of each target class It stores to object set;
Respectively by each object reference object initialization function to be initiated in object set, to initialize respectively to initial Change object;
Wherein, target class is based on general initialization agreement predetermined and obtains, and includes pair in general initialization agreement As initializtion protocol function, object set is general initialization protocol type.
Certainly, it will be understood by those skilled in the art that processor 420 can also realize that any embodiment of that present invention is provided Fundamental functional modules object initialization method technical solution.
The equipment 400 that Fig. 4 is shown is only an example, should not function to the embodiment of the present invention and use scope bring Any restrictions.As shown in figure 4, the equipment 400 includes processor 420, storage device 410, input unit 430 and output device 440;The quantity of processor 420 can be one or more in equipment, in Fig. 4 by taking a processor 420 as an example;Place in equipment Reason device 420, storage device 410, input unit 430 can be connected with output device 440 by bus or other modes, in Fig. 4 For being connected by bus 450.
Storage device 410 is used as a kind of computer readable storage medium, and it is executable to can be used for storing software program, computer Program and module, such as the corresponding program instruction/mould of the object initialization method of the fundamental functional modules in the embodiment of the present invention Block (for example, object storage module and object initialization module in the object initialization device of fundamental functional modules).
Storage device 410 can mainly include storing program area and storage data area, wherein storing program area can store operation Application program needed for system, at least one function;Storage data area, which can be stored, uses created data etc. according to terminal. In addition, storage device 410 may include high-speed random access memory, it can also include nonvolatile memory, for example, at least One disk memory, flush memory device or other non-volatile solid state memory parts.In some instances, storage device 410 It can further comprise the memory remotely located relative to processor 420, these remote memories can be by being connected to the network extremely Equipment.The example of above-mentioned network includes but is not limited to internet, intranet, local area network, mobile radio communication and combinations thereof.
Input unit 430 can be used for receiving the number or character information of input, and generate with the user setting of equipment with And the related key signals input of function control.Output device 440 may include that display screen etc. shows equipment.
Embodiment five
The present embodiment provides a kind of storage mediums comprising computer executable instructions, and computer executable instructions are by counting For executing a kind of object initialization method of fundamental functional modules when calculation machine processor executes, this method comprises:
In application program for the first time the life cycle starting function of the corresponding active window object of start picture, respectively with each Target class is input parameter, object storage function is called by object set, by the corresponding object to be initiated of each target class It stores to object set;
Respectively by each object reference object initialization function to be initiated in object set, to initialize respectively to initial Change object;
Wherein, target class is based on general initialization agreement predetermined and obtains, and includes pair in general initialization agreement As initializtion protocol function, object set is general initialization protocol type.
Certainly, a kind of storage medium comprising computer executable instructions, computer provided by the embodiment of the present invention Executable instruction is not limited to method operation as above, and fundamental functional modules provided by any embodiment of the invention can also be performed Object initialization method in relevant operation.
By the description above with respect to embodiment, it is apparent to those skilled in the art that, the present invention It can be realized by software and required common hardware, naturally it is also possible to which by hardware realization, but in many cases, the former is more Good embodiment.Based on this understanding, technical solution of the present invention substantially in other words contributes to the prior art Part can be embodied in the form of software products, which can store in computer readable storage medium In, floppy disk, read-only memory (Read-Only Memory, ROM), random access memory (Random such as computer Access Memory, RAM), flash memory (FLASH), hard disk or CD etc., including some instructions are used so that equipment (can be with It is mobile phone, personal computer or the network equipment etc.) execute pair of fundamental functional modules provided by each embodiment of the present invention As initial method.
Note that the above is only a better embodiment of the present invention and the applied technical principle.It will be appreciated by those skilled in the art that The invention is not limited to the specific embodiments described herein, be able to carry out for a person skilled in the art it is various it is apparent variation, It readjusts and substitutes without departing from protection scope of the present invention.Therefore, although being carried out by above embodiments to the present invention It is described in further detail, but the present invention is not limited to the above embodiments only, without departing from the inventive concept, also It may include more other equivalent embodiments, and the scope of the invention is determined by the scope of the appended claims.

Claims (10)

1. a kind of object initialization method of fundamental functional modules characterized by comprising
In application program for the first time the life cycle starting function of the corresponding active window object of start picture, respectively with each target Class is input parameter, calls object storage function by object set, by the corresponding object to be initiated of each target class It stores to the object set;
Respectively by each object reference object initialization function to be initiated in the object set, to initialize each institute State object to be initiated;
Wherein, target class is based on general initialization agreement predetermined and obtains, and includes pair in the general initialization agreement As initializtion protocol function, the object set is general initialization protocol type.
2. the method according to claim 1, wherein the target class be based in the following way it is predetermined General initialization agreement and obtain:
The target class inherits the general initialization agreement by protocol inheritance keyword, and makes carbon copies the object initialization association Discuss function, the target class of acquisition general initialization protocol type and the object initialization function.
3. according to the method described in claim 2, it is characterized in that, discharging agreement comprising object in the general initialization agreement Function;
Correspondingly, after the target class inherits the general initialization agreement by protocol inheritance keyword, further includes:
The target class makes carbon copies the object and discharges protocol function, obtains object and discharges function.
4. the method according to claim 1, wherein the target class be based in the following way it is predetermined General initialization agreement and obtain:
Abstract initialization class inherits the general initialization agreement by protocol inheritance keyword, and makes carbon copies the general initialization Each protocol function in agreement, the abstract initialization class of acquisition general initialization protocol type and each protocol realization function, Wherein, the abstract initialization class has abstract type modifier, and each protocol realization function is that empty real is existing;
The target class extends keyword by class and inherits the abstract initialization class, and makes carbon copies in each protocol realization function Object initialization realize function, obtain general initialization protocol type the target class and the object initialization function.
5. the method according to claim 1, wherein by the corresponding object to be initiated of each target class It stores to the object set, further includes:
Thread run function is called by thread class, opens up sub thread;
In the sub thread, triggering executes described respectively by each object reference to be initiated in the object set Object initialization function, the step of to initialize each object to be initiated.
6. method according to claim 1-5, which is characterized in that pass through each institute in the object set respectively Object reference object initialization function to be initiated is stated, includes: to initialize each object to be initiated
According to the corresponding setting delay of each object to be initiated, successively obtained from the object set each described to initial Change object, and by object initialization function described in the function call to be initiated, it is each described to be initiated right to initialize As.
7. the method according to claim 1, wherein realize in the following way will be every for the object storage function The corresponding object to be initiated of a target class is stored to the function of the object set:
It is utilized respectively instantiation keyword and generates the corresponding instance object of each target class;
It is respectively input parameter with each instance object, calls the element of the object set to add function, by each institute Instance object is stated to store to the object set.
8. a kind of object initialization device of fundamental functional modules characterized by comprising
Object storage module, for application program for the first time the corresponding active window object of start picture life cycle originate letter In number, it is respectively input parameter with each target class, object storage function is called by object set, by each class pair The object to be initiated answered is stored to the object set;
Object initialization module, it is initial for passing through each object reference object to be initiated in the object set respectively Change function, to initialize each object to be initiated;
Wherein, target class is based on general initialization agreement predetermined and obtains, and includes pair in the general initialization agreement As initializtion protocol function, the object set is general initialization protocol type.
9. a kind of equipment, which is characterized in that the equipment includes:
One or more processors;
Storage device, for storing one or more programs,
When one or more of programs are executed by one or more of processors, so that one or more of processors are real The now object initialization method of the fundamental functional modules as described in any in claim 1-7.
10. a kind of computer readable storage medium, is stored thereon with computer program, which is characterized in that the computer program The object initialization method of the fundamental functional modules as described in any in claim 1-7 is realized when being executed by processor.
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 true CN110045997A (en) 2019-07-23
CN110045997B 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)

Cited By (2)

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

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
AXWAY: "Android Module Architecture", 《HTTPS://DOCS.AXWAY.COM/BUNDLE/TITANIUM_SDK_ALLOS_EN/PAGE/ANDROID_MODULE_ARCHITECTURE.HTML》 *
HYLINUX1024: "App 组件化/模块化之路——Android 框架组件(Android Architecture Components)使用指南", 《HTTPS://WWW.CNBLOGS.COM/ANGRYCODE/P/7287242.HTML》 *
HZWEI7: "Android组件化方案实践与思考", 《HTTPS://WWW.JIANSHU.COM/P/2309CD90EF2C#COMMENTS》 *

Cited By (3)

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

Also Published As

Publication number Publication date
CN110045997B (en) 2022-07-05

Similar Documents

Publication Publication Date Title
US20080209535A1 (en) Configuration of mandatory access control security policies
FR2816730A1 (en) Method of securing deterministic real time execution of multitask applications by calculating function of acquired parameter and comparing to set threshold value
CN110045997A (en) Object initialization method, apparatus, equipment and the storage medium of fundamental functional modules
CN112698888A (en) Application modularization, component calling and component initialization method and device
CN104199691A (en) Method and device for automatically starting APK in turn-on process based on Android platform
CN106874086A (en) A kind of processing method of application program self-starting, device and mobile terminal
CN114168271A (en) Task scheduling method, electronic device and storage medium
CN106843977A (en) A kind of processing method of application program self-starting, device and mobile terminal
CN110457132A (en) A kind of creation method of functional object, device and terminal device
CN104331275B (en) A kind of Java card and its method using patch installing
CN112148351B (en) Cross-version compatibility method and system for application software
CN109062650A (en) Barrage message distributing method, device, equipment and storage medium
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
CN112529711A (en) Transaction processing method and device based on block chain virtual machine multiplexing
CN108810645B (en) Bullet screen message distribution method, device, equipment and storage medium
CN108089895B (en) Activity registration method and device in plug-in, electronic equipment and storage medium
CN113722102B (en) Memory allocation method and device
CN115222031A (en) Model parameter calling method, device, equipment and readable storage medium
CN113806055A (en) Lightweight task scheduling method, system, device and storage medium
CN109684009B (en) Protocol-based countdown synchronization method, device, storage medium and equipment
CN109819330B (en) Live broadcast room jumping method, device, equipment and storage medium
CN109144639B (en) Bullet screen message distribution method, device, equipment and storage medium
CN106874088A (en) A kind of processing method of application program self-starting, device and mobile terminal
CN114168203A (en) Dual-system running state control method and device 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