SingMR / HouseRent

房屋租赁管理系统,基于IDEA平台的springboot项目,基本功能实现(用户,管理员)
125 stars 35 forks source link

Refactoring Improve #9

Open santi0ne opened 1 year ago

godwinnnnn commented 10 months ago

thx for advice,even though I am not the ownner of this project . also I think this project is useful to me , I am planning to reconstruct this project by using springboot and thymeleaf ,I will also add this advice to the todo list.

For educational reasons, I have found some flaws in your project which could be solved by applying the following refactoring techniques:出于教育的原因,我在你的项目中发现了一些缺陷,可以通过应用以下重构技术来解决: Extract class 提取类 This technique will solve the "data class code smell" problem. 这种技术将解决“数据类代码气味”问题。 For the Admin class, the class was renamed to AdminInfo, and a new class called UserInfo was created to replace the attributes representing the user and password of the Admin class. 对于Admin类,该类被重命名为AdminInfo,并创建了一个名为UserInfo的新类来替换表示Admin类的用户和密码的属性。 image Para la clase House se crean las clases: HouseArchitecture, LocationInfo, y HouseDetail. 帕拉clase House se crean las clases:HouseArchitecture,LocationInfo,y HouseDetail. image image image image image In the Order class, the name was changed to OrderInfo and also the attributes hID and oID that refer to objects of type HouseInfo and UserInfo are replaced by objects of this type respectively to make its code more understandable. 在Order类中,名称更改为OrderInfo,并且引用HouseInfo和UserInfo类型对象的属性hID和oID分别替换为该类型的对象,以使其代码更易于理解。 image

Replace Data Value with Object将数据值替换为对象 Attributes of type int and String are replaced by references to the corresponding classes (HouseInfo, UserInfo, and UserOrder). int和String类型的属性被相应类(HouseInfo、UserInfo和UserOrder)的引用替换。 Before  之前 image After  后 image

Extract Method 提取方法 A new private method was created that will contain the central and most relevant part of the upload algorithm. 创建了一个新的私有方法,它将包含上传算法的核心和最相关的部分。

Before 之前 image

After 后 image image

In the HomePageController class, a private method called findBy is created.在HomePageController类中,创建了一个名为findBy的私有方法。 image

This will contain the lines of code that are repeated in the other methods.这将包含在其他方法中重复的代码行。 In the end, the other methods would just call this one and send their attributes by the parameters. 最后,其他方法只会调用这个方法,并通过参数发送它们的属性。

image