数据平台心得

在做数据平台的时候使用了vuejs框架。

开始我们几个都是新学习,在一个main.js中就加了所有的逻辑。导致了一系列问题:

  1. 代码难以阅读,前言不搭后语。
  2. 所有逻辑都挤在一起,只能通过起不同的名字来区分。
  3. 耦合性过高,大部分的方法无法复用。
  4. 臃肿,难以维护。
  5. 很难添加新的功能,最终会导致废掉。

所以,避免废掉,豪哥将代码进行了重构,我也在其中帮了一下,重构之后的代码特点如下:

  1. 不同的页面组织成不同的模块,单独的逻辑写在单独的模块里。
  2. 页面中的可以复用的模块也单独分离出来,比如图表模块、表格模块、说明模块等。
  3. 某些对时间、数据的处理方法写在filter过滤器中,使用时方便调用。(vuejs的特点)4. 某些需要共用的javascript功能写在mixin混合器中,需要时将方法混合入页面中。(vuejs的特点)
  4. 将模块用webpack打包。

总结:

这样搞以后,整个数据平台的前端代码有一个高模块化的状态,有极强的灵活性和复用性,特别方便修改。耦合度降低所带来的好处是,新写一个功能时,只需要单独再写一个模块,引入到main.js中,不必考虑会对其他模块产生的影响。并且新写功能的时候,如果新功能与之前的功能有相似的地方,在方法分类的前提下可以方便的将之前写过的方法或模块直接引用过来,只需要用prop绑定不同的数据即可,单独的逻辑写入单独的模块里,大大提高了开发效率,在重构完成之后,前端的工作量与工作时间、工作效率都大大优化。

所以以后在搞大中型项目时,从一开始就应该考虑到扩展与耦合的问题,尽量以高内聚低耦合为目标构建代码,确保之后开发的效率与重用性、复用性,降低工作量。在发现当前代码有问题之后,应该及时更正,不能拖。一旦在坏代码的基础上添加了更多的功能,重构的难度也会大大上升。应该在开发过程中经常有迭代review的过程,形成螺旋形开发。



评论

Online Loans

credit loans guaranteed approval <a href="https://creditloansguaranteedapproval.com/">cash lenders</a> credit loans guaranteed approval <a href=https://creditloansguaranteedapproval.com/>poor credit loans guaranteed approval</a>

2018-10-20 22:36

Cash Loan

legitimate payday loan companies <a href="https://creditloansguaranteedapproval.com">loan online instant</a> poor credit loans guaranteed approval <a href=https://creditloansguaranteedapproval.com>credit loans</a>

2018-10-14 2:10

Aecorrurnelp

Torsion bras de quelqu'un est comment robuste votre sang pousse contre les parois de vos arteres lorsque votre coeur essence pompe le sang. Arteres sont les tubes qui transportent prendre offre sang loin de votre coeur. Chaque temps votre determination bat, il pompe le sang tout au long vos arteres a la vacances de votre corps. https://www.cialispascherfr24.com/commander-cialis-canada/

2018-10-11 13:35

Payday Loan Online

credit loans guaranteed approval <a href="https://creditloansguaranteedapproval.com">credit loans guaranteed approval</a> bad credit loans <a href=https://creditloansguaranteedapproval.com>loan with bad credit</a>

2018-10-11 9:13

Speedy Cash

credit loans guaranteed approval <a href="https://creditloansguaranteedapproval.com">credit loans guaranteed approval</a> credit loans guaranteed approval <a href=https://creditloansguaranteedapproval.com>poor credit loans</a>

2018-10-9 7:06

Aecorrurnelp

Torsion bras de quelqu'un est comment calleux votre sang pousse contre les parois de vos arteres lorsque votre coeur essence pompe le sang. Arteres sont les tubes qui transportent prendre offre sang loin de votre coeur. Chaque temps votre coeur bat, il pompe le sang par de vos arteres a la reste de votre corps. https://www.cialispascherfr24.com/cialis-libido-femme/

2018-9-27 5:25

APypeeagephand

Poids est comment robuste votre sang pousse contre les parois de vos arteres lorsque votre coeur essence pompe le sang. Arteres sont les tubes qui transportent perseverent b gerer offre sang loin de votre coeur. Chaque culture votre determination bat, il pompe le sang tout au long vos arteres a la reste de votre corps. https://www.cialispascherfr24.com/cialis-effet-sur-le-coeur/

2018-9-2 17:36

AlbertJaf

The men's prostate is an essential part of a male's the reproductive system. It secretes fluids that aid in the transportation and activation of sperm. The prostate is located just as you're watching rectum, below the bladder and all around the urethra. When there is prostate problem, in most cases very uncomfortable and inconvenient to the patient as his urinary system is directly affected. The common prostate health problems are prostate infection, enlarged prostate and prostate cancer. Prostate infection, also called prostatitis, is among the most common prostate-related overuse injury in men younger than 55 years. Infections of the prostate gland are classified into four types - acute bacterial prostatitis, chronic bacterial prostatitis, chronic abacterial prostatitis and prosttodynia. Acute bacterial prostatitis may be the least common of all forms of prostate infection. It is due to bacteria based in the large intestines or urinary tract. Patients may feel fever, chills, body aches, back pains and urination problems. This condition is treated through the use of antibiotics or non-steroid anti-inflammatory drugs (NSAIDs) to ease the swelling. Chronic bacterial prostatitis is a condition of a particular defect in the gland along with the persistence presence of bacteria inside the urinary tract. It can be due to trauma to the urinary tract or by infections originating from other parts with the body. A patient may experience testicular pain, back pains and urination problems. Although it is uncommon, it is usually treated by removal in the prostate defect followed by the employment antibiotics and NSAIDs to deal with the inflammation. Non-bacterial prostatitis makes up about approximately 90% of prostatitis cases; however, researchers have not yet to determine the sources of these conditions. Some researchers think that chronic non-bacterial prostatitis occur as a result of unknown infectious agents while other believe that intensive exercise and high lifting may cause these infections. Maintaining a Healthy Prostate To prevent prostate diseases, a proper meals are important. These are some of the steps you can take to maintain your prostate healthy. 1. Drink sufficient water. Proper hydration is necessary for our health and wellbeing and this will also maintain the urinary track clean. 2. Some studies claim that a number of ejaculations each week will prevent prostate type of cancer. 3. Eat pork moderately. It has been shown that consuming a lot more than four meals of beef every week will raise the probability of prostate diseases and cancer. 4. Maintain an appropriate diet with cereals, vegetable and fruits to make certain sufficient intake of nutrients essential for prostate health. The most critical measure to take to make sure a healthy prostate would be to opt for regular prostate health screening. If you are forty yrs . old and above, you should go for prostate examination one or more times annually.

2018-8-19 20:33

在这里输入