Ex: Make a Loan Object. Loan could be house loan, car loan ,education loan ..etc. Each loan will have different interest rate, amount ,duration ...etc. Finally a complex object created through step by step process.
Maze* MazeGame::CreateMaze (MazeFactory& factory) {Maze* maze = factory.MakeMaze(); /// product is available at start!!/* Call some methods on maze */return maze;}
2.建造者:
Maze* MazeGame::CreateMaze (MazeBuilder& builder) {builder.buildMaze(); /// We don't have access to maze/* Call some methods on builder */return builder.GetMaze();}
//just give me the default stuffHttpClient.Builder().build()
//I want to use custom cacheHttpClient.Builder().cache(MyCache()).build()
//I want custom connection timeoutHttpClient.Builder().connectTimeout(30, TimeUnit.SECONDS).build()
//I am more interested in read/write timeoutHttpClient.Builder().readTimeout(30, TimeUnit.SECONDS).writeTimeout(30, TimeUnit.SECONDS).build()