Quantcast

Got Homework?

Connect with other students for help. It's a free community.

  • across
    MIT Grad Student
    Online now
  • laura*
    Helped 1,000 students
    Online now
  • Hero
    College Math Guru
    Online now

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

alsamixer Group Title

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?

  • 2 months ago
  • 2 months ago

  • This Question is Open
  1. e.mccormick Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    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.

    • 2 months ago
  2. seandisanti Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    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.

    • 2 months ago
  3. alsamixer Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    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.

    • 2 months ago
    1 Attachment
  4. alsamixer Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    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.

    • 2 months ago
  5. seandisanti Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    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.

    • 2 months ago
  6. e.mccormick Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    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.

    • 2 months ago
    • Attachments:

See more questions >>>

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.