Scott の 博客 Scott の 博客
首页
  • Data Structure and Algorithm
  • Java
  • 面试
  • Drafts
  • C++
  • 前端文章

    • JavaScript
  • 学习笔记

    • 《JavaScript教程》
    • 《JavaScript高级程序设计》
    • 《Vue》
    • 《React》
    • 《TypeScript 从零实现 axios》
    • 《Git》
    • TypeScript
    • JS设计模式总结
  • HTML
  • CSS
  • 技术文档
  • GitHub技巧
  • Nodejs
  • 博客搭建
  • 学习
  • 面试
  • 心情杂货
  • 实用技巧
  • 友情链接
关于
收藏
  • 分类
  • 标签
  • 归档
GitHub (opens new window)

Scott

恋爱中
首页
  • Data Structure and Algorithm
  • Java
  • 面试
  • Drafts
  • C++
  • 前端文章

    • JavaScript
  • 学习笔记

    • 《JavaScript教程》
    • 《JavaScript高级程序设计》
    • 《Vue》
    • 《React》
    • 《TypeScript 从零实现 axios》
    • 《Git》
    • TypeScript
    • JS设计模式总结
  • HTML
  • CSS
  • 技术文档
  • GitHub技巧
  • Nodejs
  • 博客搭建
  • 学习
  • 面试
  • 心情杂货
  • 实用技巧
  • 友情链接
关于
收藏
  • 分类
  • 标签
  • 归档
GitHub (opens new window)
  • Data Structure and Algorithm

  • Java

    • Java基础知识&面试题总结
    • Java
    • Control Flow
    • Clean Coding
    • Debugging and Deployment
    • Untitled
    • Refactor towards OOSD
      • Refactoring Classes
      • Generate Constructors
      • Change Method Signature
      • Find Usage
      • Extract Field
    • Inheritance
    • Untitled
    • Exceptions
    • Generics
    • Collections
    • Lambda-Expression
    • Streams
    • Concurrency and Multi-threading
    • The Executive Framework
    • 4
    • 1
  • c++

  • 面试

  • Bilibili_Java

  • Python

  • All kinds of Drafts

  • High Integrity Information System

  • 左神算法课

  • 个人笔记
  • Java
Scott
2021-12-14
目录

Refactor towards OOSD

  1. Refactoring Classes
  2. Generate Constructors
  3. Change Method Signature
  4. Find Usage
  5. Extract Field

# Refactoring Classes

  • Click Refactoring (control + T)

  • Click Refactor this...

  • Click Move

  • Name a new class name, and change the visibility of this new class:

image-20211215160502667
  • Click Yes to create a new class:
image-20211215160631596

# Generate Constructors

  • Click Code
  • Click Generate (command + N)
  • Select Constructor
  • A constructor with three parameters will be created:
image-20211215162847512
  • The constructor looks like this: (those three signatures are fields of the class)

    image-20211215162711333

# Change Method Signature

  • Click Refactoring (control + T)
  • Click Refactor this...
  • Click Change Signature
  • Then one can add or delete signatures

# Find Usage

  • Right click the targeted class/method name
  • Click Find Usages
image-20211215163724489

# Extract Field

  • Click Refactoring (control + T)
  • Click Refactor this...
  • Click Field
  • Can choose to initialize it in a constructor and replace all occurrences
image-20211215172143552
上次更新: 2021/12/31, 15:34:56
Untitled
Inheritance

← Untitled Inheritance→

最近更新
01
day01-Java基础语法
08-31
02
1
08-29
03
路线
08-01
更多文章>
Theme by Vdoing | Copyright © 2019-2022 Evan Xu | MIT License
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式
×