Is the Composite Pattern SOLID? -


Remove the leaf component in aggregate that extract and apply the GetChild methods that it is never using ( Violation of

Composite

Your Links And the real smell in the pattern shown in most books is that there is a composite in the form of a composite method I think is probably possible because the pattern is very old and many I think that only composite should have any methods related to compositing.

I once changed a game into a computer game The pieces of the game were kept on the Earth's map, which were divided into hexos. 99% of all hexagon's representation of the same place. Unfortunately, there were several places in some hexagons, for example, in some U There were some islands inside I used the overall pattern to represent these places, but as it was not shown on your link it was something (in Java):

  the public interface Location {Set & lt; Army & gt; GetArmies (); } Public Classroom Single Location Location {Public Set & lt; Army & gt; GetArmies () {Return troops; } Private set & lt; Army & gt; Armies = New Hashet & lt; Army & gt; (); } Public category applies to overall location Location {Public set & lt; Army & gt; GetArmies () {Set & lt; Army & gt; Armies = New Hashet & lt; Army & gt; (); (Space subdivision: sub-location) {armies.addAll (subdivision gatearmima); } Return troops; } Public Zero Add Execution {location location} {subLocations.add (location); } Private set & lt; Location & gt; Sub-location = new hashset & lt; Location & gt; (); }  

Note that there are composite methods only in composite , and do not reveal the fact that it has children for most customers (this example In, the customer wants a list of forces from only one place - the fact is that they are in many sub-places) is irrelevant.

Keep in mind that the design patterns are not exactly right, which you should implement at all, think of them as recipes when you follow a recipe during cooking, you definitely It can perfectly follow it. However, by cooking some, their own turns are thrown on the recipe. Others will not be able to see it too because they are experts and can throw anything together in the spirit of the recipe, without thinking about it. The same goes for the design pattern, they are scandalous dishes.

You can also take away those solid principles too far. If you read Robert Martin's articles, then he says that without any idea, implementing principles across the board would get more complex code. The software is built through a series of trade dislikes and balancing - sometimes you leave the pure concrete as this cleaner produces less complex code. If you wanted to make your code completely timed, flexible, decaplated, you would invent a new programming language: -)


Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -