Loop-switch sequence: Difference between revisions

Content deleted Content added
Refactored example slightly.
m Task 70: Update syntaxhighlight tags - remove use of deprecated <source> tags
Line 8:
 
An event-driven solution would implement a [[Observer pattern|listener interface]]:
<sourcesyntaxhighlight lang="java">
String key = null;
String value = null;
Line 34:
}
}
</syntaxhighlight>
</source>
 
But without the listener, it becomes an example of the antipattern:
<sourcesyntaxhighlight lang="java">
// parse a key, a value, then three parameters
String key = null;
Line 56:
}
}
</syntaxhighlight>
</source>
 
And here is the refactored solution:
<sourcesyntaxhighlight lang="java">
// parse a key and value
String key = stream.parse();
Line 69:
params.add(stream.parse());
}
</syntaxhighlight>
</source>
 
==References==