当前位置:网站首页>Think about the huge changes caused by variables
Think about the huge changes caused by variables
2022-07-02 19:34:00 【Charmaine Xia】
Variables are too common in computer programming , There are two kinds of 5+6 The code writing method of reflects the difference between not using variables and using variables .
- Writing a :
public static void main(String[] args) {
System.out.println(5+6);
}
- Write two :
public static void main(String[]args){
int a = 5;
int b = 6;
System.out.println(a+b);
}
Change one : Finite to infinite
Writing method 1 shows the addition of two fixed numbers , Writing method 2 shows the addition of two variables , From finite to infinite, there are two aspects :
- aspect 1: From adding two fixed numbers to adding any two numbers
- aspect 2: Add from two numbers to any number
Change 2 : Encapsulation of algorithms
As soon as the writing method is shown, what is printed is 5+6 Result , Writing method 2 shows that what is printed is a+b Result . Writing method 2 has an algorithm encapsulated idea in it , Addition is included in the algorithm , Because addition is also an accurate and complete description of the solution .
Change three : Multiplexing of addition
Writing method 2 makes addition into a template , This template can be reused wherever addition is required .
Writing 2 introduces two simple variables a and b There have been so many changes , If you have other ideas about writing method 2, please post them in the comments .
边栏推荐
- 《代碼整潔之道》讀書筆記
- 4274. 后缀表达式-二叉表达式树
- 函数高阶-柯里化实现
- Yunna | why use the fixed asset management system and how to enable it
- Introduction of Ethernet PHY layer chip lan8720a
- PHP非对称加密方法私钥及公钥加密解密的方法
- Usage of ieda refactor
- Qpropertyanimation use and toast case list in QT
- MySQL高级(进阶)SQL语句
- AcWing 903. 昂贵的聘礼 题解(最短路—建图、dijkstra)
猜你喜欢
codeforces每日5题(均1700)-第四天
云呐|为什么要用固定资产管理系统,怎么启用固定资产管理系统
Refactoring: improving the design of existing code (Part 1)
AcWing 1126. 最小花费 题解(最短路—dijkstra)
Use cheat engine to modify money, life and stars in Kingdom rush
潇洒郎:彻底解决Markdown图片问题——无需上传图片——无需网络——转发给他人图片无缺失
Tutorial (5.0) 09 Restful API * fortiedr * Fortinet network security expert NSE 5
Reading notes of "the way to clean structure" (Part 2)
Develop fixed asset management system, what voice is used to develop fixed asset management system
Data dimensionality reduction factor analysis
随机推荐
AcWing 903. 昂贵的聘礼 题解(最短路—建图、dijkstra)
以太网PHY层芯片LAN8720A简介
PHP parser badminton reservation applet development requires online system
数字滚动带动画
AcWing 1125. Cattle travel problem solution (shortest path, diameter)
MySQL高级(进阶)SQL语句
Yunna | why use the fixed asset management system and how to enable it
"Patient's family, please come here" reading notes
Which video recording software is better for the computer
使用 Cheat Engine 修改 Kingdom Rush 中的金钱、生命、星
Gmapping code analysis [easy to understand]
字典
Introduction of Ethernet PHY layer chip lan8720a
函数高阶-柯里化实现
《重构:改善既有代码的设计》读书笔记(上)
Typescript 之 快速入门
Function high order curry realization
多态的理解以及作用
思考变量引起的巨大变化
Py之interpret:interpret的简介、安装、案例应用之详细攻略