In Lec 17, he presents a really complicated code to do a random walk simulation. I agree that the code is very modular, but is it worth the trouble when the simulation can be done in a much easier way with 1/3 of the number of lines?
It is better to learn about modular programming. The goal is not to make you into someone that can write snippets. If you do not practice supporting techniques, you will never develop them.
Also, as I believe he explained in the lecture, using the modular approach allowed him to use or create different implementations without having to change the specification. Doing so helps avoid issues for users and developers alike down the line.
I guess the point is (and mentioned by Grimson in the previous lec) that OOP will help if you have many objects which are closely related. For example if you use the class 'Drunk' over and over again, but for small toy examples like this random walk simulation, one really does not need an OOP. See the attached file where the same is implemented, and mind you, whatever change you need to do here to consider e.g. traveling in NE NW etc. will have same effect on the OOP code as well.
Perhaps what he shows is a good coding practice for large software development. But for scientific computing, e.g., to test a hypothesis or an idea, often you don't need so much.
As it's an introductory course, I believe he is covering subjects with a fairly broad stroke approach, and opting for best practices that students will benefit the most from in the long run. I would imagine it's a proven technique based on his years as department head and decades of lecturing.
This is what he went over in the first class about best coding practices and why self learners that a;ready know how to code generally have the worst time in the class. When you develop bad coding practices it is hard to stop using them. When you start out learning good ones and stick with them, it is much easier to scale you projects to any size or reuse any of your code. This is even true of small projects. As you develop a personal library of code, you can simply reuse your functions that you know.
Join our real-time social learning platform and learn together with your friends!