Java – how do you view the “anti if” movement and its goals?

I have a developer who has been using if else or if else statements for the last three years, which is a lot in my programming habits

Today, I found this link

I put an obvious example here

public void doSomthing(String target,String object){
    //validate requests
    if(target != null && target.trim().length() < 1){
        //invalid request;
    }

    //further logic

}

Now, I have seen all kinds of places, such inspections in libraries So I want to discuss the value of this sport

Please let me know what you think

Solution

This article advocates against using if to simulate polymorphism In other words, if you find yourself switching or testing whether your object belongs to a type, you are wrong – you should let the type system do it for you

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>