cost utilization patterns Bending Java project
During today's presentation on the Software craftsmanship and design patterns that moved in the Lublin JUG died a number of questions regarding:
- the cost of using the code patterns
- time pressures
- complications
is a general and often repetitive set of questions, because I think it is worth to dispel some doubts and misunderstandings.
Some developers see the use of the standard as unnecessary complication, which introduces additional overhead to produce the code.
Generally when it comes to the level of complexity of the patterns should reduce the accidental complexity and increase the readability of the complexity of proper . If we have the opposite situation is a pattern was used improperly or unnecessarily.
As a temporary surcharge to watch the strange belief that the interface and adding a few lines of code needed to share the code to more boxes (classes) was somehow a very long time;) Sam thought process and should not be significantly longer. Or know what pattern to use or do not know. It's not like that thought about this for hours.
It is worth noting that the catalog of design patterns General Purpose is quite rich.
Yes, some of them are quite sophisticated in terms of conceptual design or in terms of code. For example, the Visitor, Component, Tree, Bridge, Proxy, Builder, Flyweight, Memento shall carry a surcharge, but these are tools who choose to special missions. Are you sure you do not belong to the daily range of techniques. However
Strategy, Status, decorator, Template Method, Command, a slight "mental shortcuts" resulting directly in the Object Oriented paradigm . There is really nothing extraordinary about them.
Personally, I treat them as part of the "atomic building blocks", which should build the solution. They are almost beings of the same weight class as Ify, loops or method. Skilled mastery of light patterns that makes them expand our set of basic "building blocks of thought." We build them first mental models, and later naturally appear in the code.
manipulating light patterns on the level of basic blocks do not have time during the development of production overhead. However, complexity is greatly reduced, but only for those readers of code that have the same resource as the creator of association - that is, they operate the same vocabulary of the industry.
//=====================================
posiłkowania need to patterns of "light" caliber due to the poor power of expression languages \u200b\u200bderived from C + +, such as eg Java. For example, the lack domknięć can compensate for the strategies. Really is not anything terrible and laborious development of the interface with one method and several of its implementation. Number code "business" is not increased (ew reduction), while there are only additional "packaging" for him as a graceful and elegant classes.
If someone so much is not chump willing to write code that can should be a troubadour;)
heavy caliber patterns may also sometimes be useful to emulate missing elements of syntax, such as:
- double dispatch pattern emulated by Visitor
- lazy evaluation model emulated by Proxy.
Tuesday, March 23, 2010
Tuesday, March 9, 2010
Pursuit Remote Starter Indoor
Wojtek Gomoła Today's presentation of Lambda Expressions (C # and "emulation" in Java) for Lublin JUG reminded me of a few interesting toys that I found some time ago and forgot to write about them.
interesting feature of dynamic languages \u200b\u200bis a function:
- the ability to create structures similar to natural language
- the ability to extend the standard often used classes (usually a collection of containers) with a convenient method
- call a total tentatively "technical DSL
example, is causing such a joy to behold simplification:
kolekcja.wyrzucZNullemWPolu (" name "). sort ({e1.age> e2.age}). wytnijPierwszych (10);
As for me there is something to be excited because this is just the icing syntax and static languages \u200b\u200bwith strong type checking is only a question of creating some of the good old procedural interface strategy Utils comparation:
MyAlmightyUtils28.wyrzucZNullemWPolu (collection , "name")
and proper sequence of requests.
/ * Of course we all know that Utilsy are bad and the ugly, but what to do * /
Well, but no longer as beautiful as in the earlier example of a sexy-scripting-language.
Fortunately, there are a few interesting toys implemented in Java. Thanks for generykach cwanym tricks and use proper names they give us something more than a bit of structure known from the dynamic, weakly otypowanych languages.
op4j - a brilliant collection, which makes the tedious code becomes more readable and concise at the same time keep typing.
very basic example:
String [] emailArray = Op.on (userEmails). ToArrayOf (Types.STRING). ForEach (). Exec (FnString.toLowerCase ()). Get ();
lambda - similar toy from the stables of google. You can also look on google collections.
Mockito - our home production. Who else has not used, it should try. It is worth visiting if only to code because it is such a master documentation. The whole manual with examples is in the main JavaDocu "klaski! The formula for followed by other authors libraries - because it certainly is not for developers of commercial products;)
//==================
waiting for Java 1.7
Well, certainly on the certificates will be new arcyistotne questions designed to checking if the culprit is able to distinguish: the internal closure of the class and from the code niekompilującego P
Subscribe to:
Comments (Atom)