CN104461508A - A method to solve the function name duplication in multiple JS files - Google Patents
A method to solve the function name duplication in multiple JS files Download PDFInfo
- Publication number
- CN104461508A CN104461508A CN201410637851.7A CN201410637851A CN104461508A CN 104461508 A CN104461508 A CN 104461508A CN 201410637851 A CN201410637851 A CN 201410637851A CN 104461508 A CN104461508 A CN 104461508A
- Authority
- CN
- China
- Prior art keywords
- namespace
- function
- name
- files
- functions
- 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.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 16
- 238000005538 encapsulation Methods 0.000 claims abstract description 5
Landscapes
- Stored Programmes (AREA)
Abstract
本发明涉及软件开发技术领域,具体涉及一种解决多个JS文件中函数名重名的方法。本发明利用JS函数的作用域编写JS自定义函数并进行封装处理;所述的自定义函数封装包括定义命名空间的名称,注册命名空间,使用命名空间;所述的定义命名空间是根据所开发的模块给相应的JS命名空间指定一个名称;所述的注册命名空间是将指命名空间与函数定义进行绑定;所述的使用命名空间指的是在相应的函数体内来编写自己的业务方法,或者利用原型的模式来创建业务方法。本发明解决了软件模块化开发中的函数容易重名问题;可以用于软件开发中。
The present invention relates to the technical field of software development, and in particular to a method for solving the problem of duplicate function names in multiple JS files. The present invention uses the scope of JS functions to write JS custom functions and perform encapsulation processing; the custom function encapsulation includes defining the name of a namespace, registering a namespace, and using a namespace; the definition of a namespace is to assign a name to a corresponding JS namespace according to a developed module; the registration of a namespace is to bind a namespace to a function definition; the use of a namespace refers to writing one's own business method in a corresponding function body, or using a prototype mode to create a business method. The present invention solves the problem of easy duplicate function names in software modular development; it can be used in software development.
Description
技术领域technical field
本发明涉及软件开发技术领域,具体涉及一种解决多个JS文件中函数名重名的方法。The invention relates to the technical field of software development, in particular to a method for solving duplicate function names in multiple JS files.
背景技术Background technique
目前的软件开发由项团队协作完成,每项目成员所负责不同的模块开发,由于界面的开发都要用到JS技术,而JS只有函数作用域,就有可能出现函数名重名的现象,有时候因为一些重名问题导致的错误让人莫名其妙,难以调试解决,严重影响了开发效率。The current software development is completed by the project team. Each project member is responsible for the development of different modules. Since the development of the interface must use JS technology, and JS only has the scope of functions, there may be a phenomenon of duplicate function names. Sometimes the errors caused by some duplicate name problems are inexplicable and difficult to debug and solve, which seriously affects the development efficiency.
发明内容Contents of the invention
本发明解决的技术问题在于提供一种解决多个JS文件中函数名重名的方法;有效解决软件开发过程中的函数名重名的现象。The technical problem to be solved by the present invention is to provide a method for solving duplicate function names in multiple JS files; effectively solving the phenomenon of duplicate function names in the software development process.
本发明解决上述问题的方案是:The scheme that the present invention solves the above problems is:
利用JS函数的作用域编写JS自定义函数并进行封装处理;Use the scope of JS functions to write JS custom functions and encapsulate them;
所述的自定义函数封装包括定义命名空间的名称,注册命名空间,使用命名空间;所述的定义命名空间是根据所开发的模块给相应的JS命名空间指定一个名称;所述的注册命名空间是将指命名空间与函数定义进行绑定;所述的使用命名空间指的是在相应的函数体内来编写自己的业务方法,或者利用原型的模式来创建业务方法。The self-defined function encapsulation includes defining the name of the namespace, registering the namespace, and using the namespace; the defining namespace is to assign a name to the corresponding JS namespace according to the developed module; the registering the namespace It refers to binding the namespace with the function definition; the use of the namespace refers to writing your own business method in the corresponding function body, or using the prototype mode to create the business method.
本发明通过引入命名空间来解决多个JS文件中函数名重名的问题;利用JS函数的作用域,把自定义的函数写到一个函数体内,这样函数内的变量、对象、函数就像在一个命名空间内一样和外部隔离。由于使用模块名称来命名JS命名空间有效地解决函数重名的问题,由于模块名称不会重名,所以开发人员无需担心JS函数的重名问题,不仅增强了代码的重用性同时又提高了开发的效率。The present invention solves the problem of duplicate function names in multiple JS files by introducing namespaces; utilizes the scope of JS functions to write self-defined functions into a function body, so that the variables, objects, and functions in the function are like The inside of a namespace is as isolated as the outside. Using the module name to name the JS namespace effectively solves the problem of function duplication. Since the module name will not be duplicated, developers do not need to worry about the duplication of JS functions, which not only enhances code reusability but also improves development. s efficiency.
附图说明Description of drawings
下面结合附图对本发明进一步说明:Below in conjunction with accompanying drawing, the present invention is further described:
图1为本发明的业务流程图Fig. 1 is a business flow chart of the present invention
具体实施方式Detailed ways
如图1所示,下面具体以开发某模块com.test.system为例,讲述该方法的具体操作。As shown in Figure 1, the specific operation of this method will be described below by taking the development of a certain module com.test.system as an example.
在编辑工作计划的操作中主要有以下操作:In the operation of editing the work plan, there are mainly the following operations:
1、定义命名空间:根据所开发的模块com.test.system来给JS命名空间取名为:com.test.system。1. Define the namespace: Name the JS namespace according to the developed module com.test.system: com.test.system.
2、注册命名空间:把命名空间与函数定义进行注册绑定。2. Register the namespace: register and bind the namespace with the function definition.
3、使用命名空间:在相应的函数体内来编写自己的业务方法,或者利用原型的模式来创建业务方法。3. Use namespaces: write your own business methods in the corresponding function body, or use the prototype mode to create business methods.
Claims (1)
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201410637851.7A CN104461508A (en) | 2014-11-12 | 2014-11-12 | A method to solve the function name duplication in multiple JS files |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201410637851.7A CN104461508A (en) | 2014-11-12 | 2014-11-12 | A method to solve the function name duplication in multiple JS files |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| CN104461508A true CN104461508A (en) | 2015-03-25 |
Family
ID=52907620
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN201410637851.7A Pending CN104461508A (en) | 2014-11-12 | 2014-11-12 | A method to solve the function name duplication in multiple JS files |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN104461508A (en) |
Cited By (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN107357593A (en) * | 2017-08-24 | 2017-11-17 | 武汉斗鱼网络科技有限公司 | Source code file construction method, device, electric terminal and readable storage medium storing program for executing |
| CN108427580A (en) * | 2018-01-08 | 2018-08-21 | 平安科技(深圳)有限公司 | Configure detection method, storage medium and the smart machine repeated to name |
| CN108874556A (en) * | 2018-05-23 | 2018-11-23 | 北京五八信息技术有限公司 | A kind of data interactive method, device, storage medium and mobile terminal |
| CN112130723A (en) * | 2018-05-25 | 2020-12-25 | 第四范式(北京)技术有限公司 | Method and system for performing feature processing on data |
Citations (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20070067418A1 (en) * | 2005-09-01 | 2007-03-22 | Microsoft Corporation | Object oriented web application framework |
| CN101599015A (en) * | 2009-07-07 | 2009-12-09 | 阿里巴巴集团控股有限公司 | A kind of method and system of analyzing component |
| CN103605516A (en) * | 2013-11-12 | 2014-02-26 | 国家电网公司 | Flexible Web display frame model architecture designing method |
| CN103729287A (en) * | 2012-10-16 | 2014-04-16 | 百度在线网络技术(北京)有限公司 | Testing method and device for front end java script module |
-
2014
- 2014-11-12 CN CN201410637851.7A patent/CN104461508A/en active Pending
Patent Citations (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20070067418A1 (en) * | 2005-09-01 | 2007-03-22 | Microsoft Corporation | Object oriented web application framework |
| CN101599015A (en) * | 2009-07-07 | 2009-12-09 | 阿里巴巴集团控股有限公司 | A kind of method and system of analyzing component |
| CN103729287A (en) * | 2012-10-16 | 2014-04-16 | 百度在线网络技术(北京)有限公司 | Testing method and device for front end java script module |
| CN103605516A (en) * | 2013-11-12 | 2014-02-26 | 国家电网公司 | Flexible Web display frame model architecture designing method |
Non-Patent Citations (3)
| Title |
|---|
| DAIWEI15: "javaScript 命名空间", 《HTTP://BLOG.CSDN.NET/DAIWEI15/ARTICLE/DETAILS/7660033》 * |
| LISSNET: "js namespace", 《HTTP://WENKU.BAIDU.COM/LINK?URL=Y3AXFII0IZYXJMRWQTLBBJMKYUTMGLWBEW4-C_RC3RKSLHOD_JUXCBZKATRDGAC97UMUW8P1YBIJCJC4I5IQSSS6PXYJKYQODFFHIKYVVK3》 * |
| 大约: "JS命名空间", 《HTTP://WWW.CNBLOGS.COM/YTJJYY/ARCHIVE/2012/04/17/2453337.HTML》 * |
Cited By (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN107357593A (en) * | 2017-08-24 | 2017-11-17 | 武汉斗鱼网络科技有限公司 | Source code file construction method, device, electric terminal and readable storage medium storing program for executing |
| CN108427580A (en) * | 2018-01-08 | 2018-08-21 | 平安科技(深圳)有限公司 | Configure detection method, storage medium and the smart machine repeated to name |
| CN108427580B (en) * | 2018-01-08 | 2020-01-10 | 平安科技(深圳)有限公司 | Configuration pair naming repetition detection method, storage medium and intelligent device |
| CN108874556A (en) * | 2018-05-23 | 2018-11-23 | 北京五八信息技术有限公司 | A kind of data interactive method, device, storage medium and mobile terminal |
| CN112130723A (en) * | 2018-05-25 | 2020-12-25 | 第四范式(北京)技术有限公司 | Method and system for performing feature processing on data |
| CN112130723B (en) * | 2018-05-25 | 2023-04-18 | 第四范式(北京)技术有限公司 | Method and system for performing feature processing on data |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| Tone et al. | Handling negative data in slacks-based measure data envelopment analysis models | |
| MY198787A (en) | Application development method, tool, and device, and storage medium | |
| CN103440156B (en) | Linux software package manufacturing method capable of being used under various systems | |
| JP2019532364A5 (en) | ||
| CN104461508A (en) | A method to solve the function name duplication in multiple JS files | |
| CN108038095A (en) | A kind of document automatic creation method | |
| CN105335155A (en) | Method for realizing different IoT (Internet of Things) applications by only needing to configure cloud-end script | |
| JP2010541078A5 (en) | ||
| CN102968349B (en) | Remote sensing image data file completeness method of calibration and system | |
| IN2014DE02046A (en) | ||
| MX2017005872A (en) | Multi-search and multi-task in search. | |
| SG10201702888XA (en) | Platform for the integration of operational bim, operational intelligence, and user journeys for the simplified and unified management of smart cities | |
| JP2011028648A5 (en) | Object code generation system | |
| JP2016539444A5 (en) | ||
| NO20181598A1 (en) | Parallel multiscale reservoir simulation | |
| JP2015530677A5 (en) | ||
| CN104239613A (en) | Engine collaborative design integrated application system | |
| JP2008186120A5 (en) | ||
| CN104102526A (en) | Collaborative interface for co-simulation of PSCAD (power system computer aided design) with third-party simulation software or hardware | |
| CN108182236A (en) | Web page drop-down list implementation method for uniformly configuring data sources | |
| EP2829974A3 (en) | Memory dump method, information processing apparatus and program | |
| Valiyev et al. | Design of the modern domain specific programming languages | |
| CN105894897A (en) | Transparent calligraphy depicting and copying calibration card | |
| CN104123166A (en) | Generation method for ipa installation package in non-Xcode environment | |
| CN103246518A (en) | Configuration method and device based on service component architecture |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| C06 | Publication | ||
| PB01 | Publication | ||
| SE01 | Entry into force of request for substantive examination | ||
| WD01 | Invention patent application deemed withdrawn after publication | ||
| WD01 | Invention patent application deemed withdrawn after publication |
Application publication date: 20150325 |