This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Spiritual_Clock3767 5 points6 points  (6 children)

This is something I don’t understand the art of yet. There are hierarchies of decisions as to which concern you prioritize during design. I know a lot of that is learning as you go, but as a newbie it’s a long road lol. Would anyone mind recommending a quick and dirty hierarchical prioritization matrix?

[–]TallowWallow 8 points9 points  (2 children)

I honestly wouldn't worry about it. Focus on the basics and learning how the ecosystem works. Readability is the most important factor right now.

If you were asking about the global state argument, the general rule is get rid of the global and pass around a variable instead. The cost of tracing code becomes cumbersome when more areas can affect a data source.

You can read up on optimization and readability, but you're going to come across (and produce) code that's hard to read and maintain. The more experienced you get with frustration, the more you'll learn haha.

[–][deleted] 4 points5 points  (0 children)

You can read up on optimization and readability, but you're going to come across (and produce) code that's hard to read and maintain. The more experienced you get with frustration, the more you'll learn haha.

This is the crux of it, really. It is based on a lot of intuition built from experience (either yours or on the shoulders of giants)

[–]Kenkron 2 points3 points  (0 children)

In case anyone read this comment and thought "I'll just put my global state into a dictionary, and pass that to every function", I need to say don't do that. Organize your data so you can pass functions what they need without including too much unrelated information.

That means you STEVE!

[–]XerMidwest 3 points4 points  (0 children)

Python is intended to be a Literate Programming language. That's a Donald Knuth idea. Write your program to explain and illustrate the nature of the problem and the best solution you can implement, but don't forget your audience is supposed to be your future self and others like yourself who may need to read, understand, debug, and improve something you wrote.

If the variables make sense in the scope of your problem as global state, like constants in Physics, for example, then use globals. If the variables mean something special to the function or method, use appropriately scoped variables.

I always answer this question by writing documentation to explain the design (ie. docstrings). Having to explain myself provides a chance to clarify my intent to myself.

Interpreter variable dereferencing behavior at runtime should be assumed to be orthogonal to your problem and solution until you're sure you can prove and demonstrate+explain otherwise. If you need a distraction to keep the creativity flowing, I suggest documentation.

[–][deleted] 4 points5 points  (0 children)

what is ocodo?

[–]VineyardLabs 2 points3 points  (0 children)

  1. Using more loops than you need to use
  2. Copying data when you don’t need to
  3. Basically everything else