且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

继承main方法

更新时间:2023-11-18 16:11:40

将主方法移到单独的类中.单独的关注事项
策略(名称说明一切)
启动器(将组件组装在一起并触发执行)

Move the main method out into a separate class. Separate concerns
Strategy (the name says it all)
Launcher (assembling components together and triggering execution)

public class Launcher
{
    public static void main(String args)
    {
       Strategy s = new UselessStrategy();
          //OR Strategy s = CreateInstance(args[0]) ;
          //OR equiv mechanism for Dependency Injection if you don't want to hardcode the derived strategy to use.
        s.execute(new SoccerRobot())
    }
}