It is probably seems to be a
bit late to write about Assignment 2 Part, since it had been like 2 weeks and
Part 2 was already due. Yet, Part 1 seems to be hard to start compare to Part
2, and this is the reason why I want to write about this.
Assignment 2,
overall, introduced a very interesting concept of organizing linked lists and
classes of string:
“Regular
expressions (abbreviated to regex, the pronunciation of which gives rise to
endless ame wars. . . ) are used in various programming languages and utilities
to match entire classes of strings. This assignment will give you experience
modelling a regular expression as a tree, and detecting which strings match a
given regular expression.”
--- (Assignment #2 Handout)
http://www.cdf.toronto.edu/~heap/148/W14/Assignments/A2/a2.pdf
In part 1, we simply just have “design a collection of
classes to represent the various sorts of regular expression trees. Each class
should implement or inherit an __eq__ method so that it can be compared to
other objects; and a __repr__ method so that it can be represented in a
meaningful way as a string, and so that an equivalent tree will be produced if
you cut-and-paste the representation into a Python shell. You should carefully
consider how to use inheritance to reduce the amount of duplicated code. You
should also ensure that public attributes for a tree's symbol or children can
only be set once, during initialization. After that, they should be read-only.Your
class(es) should be declared in a _le called regex design.py.” (quoted from the
handout).
I have say it was really hard to start this step, I think
maybe because it is the first time I was not give any file and just implements
functions/methods, I have to actually design the structure of this, even though
this does not seem hard at all. I also got confused with part 2, so I kept doing
part 2’s job (eg. translate input into a tree and etc.); I over-complicated
thing a bit.
I started by just trying out different things and design
the classes in different ways, yet the far I go, the far I got lost (still
confused the different parts I need to do for part 1 and part 2). So, I deleted
everything and decided to start fresh. I have a friend in UT Scarborough, who
is taking 148, too, and I ask him about how to start this, and I also went on
to Piazza and spend three hours looked through all the posts and answers about
Part one. Finally, after five hours, I finally knew what I needed to do. Ironically,
it only took me one hour the whole thing. :P And it was actually pretty simple.
:D
I think the handout did not explain everything to well.
For example, what do we suppose to return when we use __repr__(), what suppose
to be the input, and small things that are similar to these kind of questions. So,
I hope in the future, the handout could have been more clear about the steps
and explanation of the everything.
By the way, I really LOVE Piazza!!!! Every time I got
confused about something, like assignments, exercises or labs, I go on there,
and ask or look over people’s post, and it is really helpful for my studying in
this course.