Skip to main content
Code Review

Return to Answer

added 28 characters in body
Source Link

My first instinct is that your code is a pretty "cool" way to rewrite if else statements, but I don’t think it gains you too much. If you have massive amounts of if trees and want to make them more readable, I would consider using polymorphism to your advantage or, when appropriate, strategy pattern.

If you want some help refactoring a certain if tree please feel free to post the code and we can help.

There are often, IMO, two big reasons to make a new abstractions. 1) to decrease the mental load on the maintainers of this code or 2) to increase the ability to add new features in the futureabstraction.

  1. to decrease the mental load on the maintainers of this code or

  2. to increase the ability to add new features in the future.

Both of these are, of course, related. My question is, and feel free to comment below, does your if abstraction decrease maintainer mental load through simplicity or brevity and/or does your if abstraction improve the ability to add new features in the future? If not then you need to consider why you are doing it in the first place.

My first instinct is that your code is a pretty "cool" way to rewrite if else statements, but I don’t think it gains you too much. If you have massive amounts of if trees and want to make them more readable I would consider using polymorphism to your advantage or when appropriate strategy pattern. If you want some help refactoring a certain if tree please feel free to post the code and we can help. There are often, IMO, two big reasons to make a new abstractions. 1) to decrease the mental load on the maintainers of this code or 2) to increase the ability to add new features in the future. Both of these are of course related. My question is, and feel free to comment below, does your if abstraction decrease maintainer mental load through simplicity or brevity and does your abstraction improve the ability to add new features in the future? If not then you need to consider why you are doing it in the first place.

My first instinct is that your code is a pretty "cool" way to rewrite if else statements, but I don’t think it gains you too much. If you have massive amounts of if trees and want to make them more readable, I would consider using polymorphism to your advantage or, when appropriate, strategy pattern.

If you want some help refactoring a certain if tree please feel free to post the code and we can help.

There are often, IMO, two big reasons to make a new abstraction.

  1. to decrease the mental load on the maintainers of this code or

  2. to increase the ability to add new features in the future.

Both of these are, of course, related. My question is, and feel free to comment below, does your if abstraction decrease maintainer mental load through simplicity or brevity and/or does your if abstraction improve the ability to add new features in the future? If not then you need to consider why you are doing it in the first place.

Source Link

My first instinct is that your code is a pretty "cool" way to rewrite if else statements, but I don’t think it gains you too much. If you have massive amounts of if trees and want to make them more readable I would consider using polymorphism to your advantage or when appropriate strategy pattern. If you want some help refactoring a certain if tree please feel free to post the code and we can help. There are often, IMO, two big reasons to make a new abstractions. 1) to decrease the mental load on the maintainers of this code or 2) to increase the ability to add new features in the future. Both of these are of course related. My question is, and feel free to comment below, does your if abstraction decrease maintainer mental load through simplicity or brevity and does your abstraction improve the ability to add new features in the future? If not then you need to consider why you are doing it in the first place.

lang-java

AltStyle によって変換されたページ (->オリジナル) /