霜天部落 | 关注LAMP高性能、高并发架构的设计与研究

如何使用 phpStorm 重构你的代码

Refactoring code is an essential aspect of building and maintaining software. In this tutorial I will show you how to use PhpStorm’s refactoring functionality to make it as easy as possible.

When refactoring code by hand, whether you’re working with legacy code, or creating new code, it’s easy to make mistakes, such as forgetting one place where the code was used, when renaming a method. That’s why I love to make use of PhpStorm’s refactoring functionality on a regular basis.

If this is your first time hearing about the term, Martin Fowler describes refactoring as:

Refactoring is a controlled technique for improving the design of an existing code base. Its essence is applying a series of small behavior-preserving transformations, each of which “too small to be worth doing“. However the cumulative effect of each of these transformations is quite significant. By doing them in small steps you reduce the risk of introducing errors. You also avoid having the system broken while you are carrying out the restructuring – which allows you to gradually refactor a system over an extended period of time.

Refactoring covers a range of different techniques, including moving, extracting, copying, deleting, and renaming. These cover all the types of changes which you are likely to make to your code on an ongoing basis.

Gladly, PhpStorm’s refactoring functionality, which is included as part of the core package, has support for all of these. In this tutorial, I’m going to step through a couple of them; specifically:

  • Extracting code to a new method
  • Renaming a function
  • Changing a function’s signature

Read more ›

PHP中的self-static-parent关键字

php官方手册介绍:
http://php.net/manual/zh/language.oop5.late-static-bindings.php

不存在继承的时候

不存在继承的意思就是,就书写一个单独的类来使用的时候。self和static在范围解析操作符 (::) 的使用上,并无区别。

  • 在静态函数中,self和static可以调用静态属性和静态函数(没有实例化类,因此不能调用非静态的属性和函数)。
  • 在非静态函数中,self和static可以调用静态属性和静态函数以及非静态函数

此时,self和static的表现是一样的,可以替换为该类名::的方式调用。
Read more ›

SOAP Vs. REST: Difference between Web API Services

The earlier tutorials have given a lot of details on 2 key types of web service designs. One is SOAP protocol (Simple Object Access Protocol) and the other being REST for Representational State Transfer.

Each technique has its own advantages and disadvantages. Hence, it’s always good to understand in which situations each design should be used. This tutorial will go into some of the key differences between these techniques as well as what challenges you might encounter while using them. Read more ›

58到家MySQL军规升级版

58到家MySQL军规升级版

一、基础规范

● 表存储引擎必须使用InnoDB

● 表字符集默认使用utf8,必要时候使用utf8mb4

解读:
(1)通用,无乱码风险,汉字3字节,英文1字节

(2)utf8mb4是utf8的超集,有存储4字节例如表情符号时,使用它

● 禁止使用存储过程,视图,触发器,Event

解读:

(1)对数据库性能影响较大,互联网业务,能让站点层和服务层干的事情,不要交到数据库层

(2)调试,排错,迁移都比较困难,扩展性较差

● 禁止在数据库中存储大文件,例如照片,可以将大文件存储在对象存储系统,数据库中存储路径

● 禁止在线上环境做数据库压力测试

● 测试,开发,线上数据库环境必须隔离 Read more ›

1分钟了解比特币,PM都懂了

理解本文不需要任何技术背景。
一句话,比特币BTC(BitCoin)是,基于区块链的,能抵抗通货膨胀的,电子货币。这里有三个关键词:电子货币,抵抗通胀,基于区块链。

一、比特币有没有价值?

很早以前,没有货币,物品换物品。我手里有牛,我需要盐,但买盐的人不需要牛,他需要布,于是我想办法用牛先换取布,再换取我想要的盐,整个过程效率很低。人很聪明,于是发明了一种等价物,大家都认可其价值,用来提高交易的效率。这个等价物就是货币。货币需要具备方便,稀少,易分割,易衡量等特性。历史上曾经用来作为货币的等价物有:贝壳,铜币,金银,钞票。
首先,比特币的本质是货币。

Read more ›

刚开始学编程?这几款小工具能让你事半功倍

科技行业里,可供人们使用的工具成百上千,你要怎么知道用哪一种上手最合适呢?
拿最近刚进入编程这行的人来说吧,大量的工具信息堆砌过来其实毫无益处,反而会无从下手。我发现在自己的开发过程中,很多安装的扩展工具不仅没有真正起到助益作用,反而常常妨碍了正常的开发工作。
我不是专家,不过随着时间的推移,我还是编制了一份工具清单,这些工具已经证明对我非常有用。如果你刚刚开始学习怎么编程的话,这个清单能给你提供一些指导。如果你是个经验丰富的开发人员,也希望你能从中学到一些新的东西。
我将把这篇文章分为Chrome扩展程序和VS代码扩展扩展程序两部分。我知道还有其他的浏览器和文本编辑器,但是我想你当然只能在你能找到的工具里选择,所以还是别因为个人喜好而引起一场宗教般的争论。

Read more ›