Hw6 interpreter iterator GoF

295 views

Published on

GoF Patterns: Interpreter, Iterator

Published in: Education, Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
295
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
1
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Hw6 interpreter iterator GoF

  1. 1. UTAH STATE UNIVERSITY COMPUTER SCIENCE CS-7350 Reading Assignment GoF Patterns: Interpreter, Iterator Jorge Edison Lascano Spring 2012 01-27-2012INTERPRETER, ITERATORGoFPATTERNSInterpreter, its main intent is interpreting well-structured sentences based on grammars, lookingfor sequence of actions that make sense syntactically. One constraint is that it only serves forsimple grammars, then the question is How to measure the complexity of the grammar?. Otherdifficulty is the representation of the tree structure (solved in certain way by composite). TheInterpret method represents the main behavior, but it needs help to traverse the structure.Concluding, this pattern by itself does not solve all the proposed problems by GoF.The consideration of a complex grammar is still present. It is said that it is helpful for regularexpressions, but not for parsers. So, the complexity could be measured by the level of(de)composition, or the complexity in the grammatical structure of the sentences.Iterator, also known as cursor, it´s intent is to allow access to elements sequentially withoutexposing their representation. The main use is mentioned as data structure traverse, but, thisfeature is already implemented by almost every modern language, namely:Java, C#, Smalltalk intheir Collections. Now, the question is: Is it really necessary to implement an iterator? And theanswer is YES, if we need to implement a different way (than traditional data structures) totraverse the elements and also if we need to implement multiple traversal ways at the same time.As this is a behavior pattern, the main concern should be oriented to decide the place where thetraversal algorithm should be implemented. Maybe using a Bridge between the ConcreteIteratorand the ConcreteAggregate could solve this problem.

×