- Factory Method
- Builder
- Abstract Factory
Factory method pattern is usually applied in combination with Template method pattern:
- AbstractCardinalMoveGenerator class.
- AbstractJumpMoveGenerator class.
Abstract Factory pattern examples:
- MoveFactory is the interface and MoveFactoryBlack and MoveFactoryWhite are two different implementations.
Builder pattern has been implemented with different participant classes
- Builder: ChessBuilder class declares the interface.
- Concrete Builders
- ASCIIOutput, the result is retried with method xXX
- FENCoder, the result is retried with method XX
- ChessBuilderParts
- ChessBuilderBoard
- ChessBuilderGame
- Director: Board.constructBoardRepresentation() is the director method
- Facade
- Proxy
Facade pattern is implemented by GameImp class.
Proxy pattern is implemented by ChessPositionReader as access control interface to underlying implementation classes. Game and ChessPosition implements this interface, Game forwards all requests to ChessPosition class for actual implementation. MoveGenaratorWithCacheProxy implements a cache proxy. Another example is MoveGeneratorWithCacheProxy.
- Template method
- Command
- Strategy
- Visitor
- Iterator
Template method pattern is applied in different situations by abstract classes: AbstractPawnMoveGenerator
By convention, those classes with template methods are abstract classes and named with the prefix Abstract.
Command pattern in combination with Visitor pattern can be found at chess.moves package.
Interfaces Move/MoveKing/MoveCastling define DO and UNDO operations.
Classes in package net.chesstango.board.moves.imp implement these interfaces.
Strategy pattern is implemented at net.chesstango.board.movesgenerators.pseudo.strategies package. MoveGenerator interface declares the interface, all the classes in this package implements the interface (with the exception of PeonPasanteMoveGenerator).
Iterators can be found at net.chesstango.board.iterators package.