java - Secret Handshake Anti-Pattern -
I have just come across a pattern that I have seen before, and wanted to get feedback on it. The code in question includes an interface like this:
Public Interface MyCrazyAnalyzer {Public Zero SetOptes (Analyzer Option Option); Public zero set text (string text); Public Zero Starter (); Public int getOccurances (string query); } and the expected use is as follows:
MyCrazyAnalyzer crazy = AnalyzerFactory.getAnalyzer (); Crazy.setOptions (true); Crazy.initialize (); Maps & lt; String, integer & gt; Result = New Hashmap & lt; String, integer & gt; (); (String items: items) {crazy.setText (item); result. Input (item, crazy.gate octaire); } There are reasons for some of these Settext (...) and getOccurances (...) are there because you can do many queries after doing the same expensive analysis on the data , But it can be re-applied for a result class.
Why do I feel that it is very bad: Implementation is collecting the state in such a way that is not clearly indicated by the interface. I have seen anything like this, which includes an interface, which is necessary to call a "ready receipt" call, then "getResult" Now, I can think of the well-coded codes which are these features Employs some of them. The Hadop Mapper interface job is configurable and discontinuing, but I see a big difference because it is a framework that uses the user code that implements the user interface, is made up of a service that can perform several implementations. . I think there is nothing relevant to incorporate the "closed" method that should be named, because there is no other appropriate way to do it. In some cases, like JDBC, this is the result of a leakage abstraction, but I am thinking that in two pieces of code, it is clearly clear that the programmer will clean it by adding an interface to the spaghetti code class as soon as possible. Will take
My questions are:
- Do all agree that this is a poorly designed interface?
- Is this an anti-pattern?
- Is this the kind of start up in an interface?
- Is it just wrong for me because I have a priority for functional style and stability?
If it is quite common to be eligible for a name, then I suggest a "secret handshake" anti-pattern for an interface that you can use in a particular order Forces more ways to call when the interface is not naturally static (such as archive).
Yes, this is an anti-pattern.
I passed the option - factory, and result , r analysis text () method was prepared .
Comments
Post a Comment