![]() My path to JavaScript: Refactoring fizzbuzz to acc.Interesting Talk: "The Framework as an implementat.Building GoogleMock to use it with Visual Studio 2.Birthday greetings refactoring kata at Barcelona S.Interesting Talk: "Domain-Driven Design".Interesting Podcast: "Value Objects, The Heart and.Video: Required settings to use googlemock in a Vi.Interesting Talk: "Defining Object-Oriented Design".Interesting Talk: "What Killed Smalltalk Could Kil.Update: I refactored this code making it much simpler. You can have a look at the code on GitHub. The code that is common to all 2D cells is in the Cell2D abstract class, whereas the one that is common to all 3D cells is in the Cell3D abstract class. In this case, I implemented several types of cells: ConwaysCell, CellX2D, CellCross3D and CellCross2D. In this way each implementation of Cell can have a different dimension and a different number of neighbors which can be located following different stencils. It's up to the cell to know which are its neighbors. It has only a method, getNeighbors, which returns the neighbors of a cell. This two are possible thanks to the Cell interface. Open/Closed with regard to the number and location of a cell's neighborsĪnd Open/Closed with regard to the dimensions of the grid (2D, 3D, 4D, etc). In this case, I only implemented the rules of the Conway's Game of Life: ConwaysRules class, but more rules based on the number of neighbors might be added. ![]() The rules are still based on the number of neighbors which is the parameter passed to both methods. Rules is an interface with two methods, shouldStayAlive and shouldBeBorn, that you can implement the way you wish. Open/Closed with regard to the rules based on the number of neighbors. To generate the next Generation of LivingCells ( produceNextGeneration method), it first adds the surviving cells ( addSurvivors method) and then the newly born cells ( addNewCells method). This way the "state of the cell" concept we tried in some iterations of the code retreat becomes pointless and it requires less space to store the current generation. It took me several rewrites but finally I came up with this solution that respects all the previous ideas.Ī Generation has a collection of cells that are alive, LivingCells, and a set of Rules.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |