CS373 Fall 2021: Week 10
What did you do this past week?
Monday and Tuesday were spent finishing Phase 2 of the IDB project. The rest of the week was spent catching up on other assignments, which I managed to get done by Friday. The weekend gave me a bit of a break, but I’ll need to get started on future projects.
What’s in your way?
Same as always, a lot of work.
What will you do next week?
Next week I’ll need to finish a few assignments as well as a project, so it should be lighter in comparison.
If you read it, what did you think of the Dependency Inversion Principle?
The dependency inversion principle is a good way of eliminating dependencies. Many times, high level code depends on lower level code, and when the low-level code can vary based on the environment or application, this makes high level code non-reusable. If high level code instead makes use of abstractions, and low-level code implements those abstractions, then there is no longer any dependency between the implementations of high and low level code. The paper uses object-oriented design as its example, but this is a much more widespread pattern; for example, portable applications and libraries hide low level details and allow the same functionality to exist on different platforms.
What was your experience of =, *, ** and regular expressions?
Call-by-name is a useful feature when you have long parameter lists with lots of optional arguments. However, I don’t really like it — it makes code hard to modify, and as someone who loves refactoring, this just makes things more annoying. Destructuring with the * and ** operators can be pretty convenient. I find that it’s very nice when I need to embed a list, like
[cxx, *flags, '-omain'] or something similar, and I imagine the same could be done with dictionaries. I don’t really see a use case for it in functions though beyond handling and passing multiple arguments. These constructs introduce non-intuitive semantics to make certain things more convenient, which isn’t really worth it in my opinion, but could be useful to the experienced Python programmer, and probably rarely cause confusion outside of quizzes.
Regular expressions, on the other hand, are immensely useful and widespread. I’ve used regular expressions a little bit — they are really useful when searching and replacing strings. I’m still not familiar with all the special characters and rules though (and there appear to be competing standards that make certain things possible or not, as well as escape characters always being a pain), so I still look up rules every time I need to use a more complicated regex.
What made you happy this week?
I bought groceries and did a bit of cooking over the weekend; I do enjoy it a lot, and it gives me a lot of leftovers to finish over the following week, which saves me money and time.
What’s your pick-of-the-week or tip-of-the-week?
Speaking of regex, I really love https://rubular.com/ for writing regular expressions. You just give your regex, and the string to match against, and it spits out what gets matched. It’s useful when I need to test out a regex to make sure I didn’t mess up and that it is matching correctly.