On Thu, Apr 15, 2010 at 11:39 PM, Derek C.
“def self.name” makes the method static, right?
Yes (in the Java sense of the word).
Is there any particular reason why it is best to do this than have the url
part in the constructor?
Then you can create objects of this class that are not based off of that
url. What if you decide you want to group courses together, under
controllers? Maybe the website isn’t updated, and you want to enter them
from the course catalogue instead of the website, or maybe you want to
them in from a second site, or maybe store them locally rather than
the web every time you run the program. This way the class gives you the
ability to create through that website, but doesn’t mandate it, or tie
class itself to this particular implementation of how to get it started.
What exactly is “modularity”?
Code that doesn’t know about, or rely on internals of other code. Thus
will not break if used differently, or in a different context. It does
rely on special knowledge of implementation, or details that may change.
When this happens it is called coupling, when your code is not coupled,
can take it and combine it together with many other pieces of code and
will operate as desired. For example, if you download the web data into
file, you can then use it to pull from the file rather than the page,
because it is modular enough to support a different source.
Think how unix commands are small with a specific function, but you can
combine them in powerful ways. These small programs are modular.
Or relative vs absolute file paths. When they are relative, you can
them anywhere, and they still work. Drag and drop that directory, give
friends, etc. If they are absolute, you must go alter that file path
time you move it. The absolute file path is coupled to the file’s
What do you gain from doing this?
On a program that will never change, or that is very small, you don’t
see the benefits. But when you have to go back later and make a change,
want to be able to only make it in the places that logically deal with
change. Everything else should still work fine.
If your file is big, and coupled, and you need to make a change, you
know, because you will have this scared feeling in your stomache that
may have just made a change that could break something completely
somewhere else that you can’t even conceive of. Or you may want to make
specific change, but then wind up going through every line of code you
in order to update all sorts of things all over the place. This