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?
MIT 6.00 Intro Computer Science (OCW)
Stacey Warren - Expert brainly.com
Hey! We 've verified this expert answer for you, click below to unlock the details :)
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga.
Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus.
Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
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.
Not the answer you are looking for? Search for more explanations.
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.