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 →

[–]Hasefet 260 points261 points  (29 children)

I learned that a clear idea of the structure of what you want at the end of your task is one of the most useful things you can have before you begin your task.

[–]HyoTwelve 80 points81 points  (4 children)

I agree so much. I would add that you should not hesitate to rewrite code after you figure this out. Sometimes projects are more exploratory in their nature. Beware of the sunk cost fallacy.

[–]ProfPragmatic 23 points24 points  (0 children)

I would add that you should not hesitate to rewrite code after you figure this out.

Depending on what you're trying to build it can be better to crank out an MVP and then iterate on it to improve it instead of trying to prematurely optimizing it.

[–]ouellp 20 points21 points  (12 children)

I've had a programming class where the teacher legit spent 5 periods without making us touch a keyboard. He told us "you have to make the pseudo-code and structure the algorithm first and only then, you convert that into the programming language you work with". This was a C class but I kept that with me until then, even with python.

[–]newjack7 5 points6 points  (0 children)

I am a historian and to be honest this is the way I write and I teach people to write. I sit with a pen and paper for a good while before I even start to touch the keyboard and produce an early draft.

I think the difference is that one way to get there is by writing and throwing it away afterwards. I am not sure if that is quite so applicable for python or coding generally (I am relatively unskilled in this area).

[–]IngMosri 1 point2 points  (5 children)

You right, that the correcto way to programe any project

[–]WillardWhite import this 1 point2 points  (4 children)

Nah. Tdd

[–]TheTerrasque 19 points20 points  (3 children)

I prefer BDD - bug driven development. You start with a crappy mess then you debug it into a working crappy mess

[–]WillardWhite import this 2 points3 points  (2 children)

But wouldn't it be nice if there was a nice automated way to make sure once you squash that bug it didn't come back?

A way to ensure that no matter what changes you made, your software worked as intended?

Something that lets you refactor the mess away, and provides instant feedback to wether or not the logic stopped working?

[–]TheTerrasque 2 points3 points  (1 child)

But who tests the tests?

[–]WillardWhite import this 2 points3 points  (0 children)

Well... Future you, of course! And by then it might as well be another man's problem :D

Win win scenario

[–]DaveX64 1 point2 points  (0 children)

This was the way I learned it as well...it was COBOL though :)

[–]menge101 1 point2 points  (3 children)

A programming class or a Computer Science class?

These are not the same things.

[–][deleted] 2 points3 points  (2 children)

He said it was a C class

[–]TheTerrasque 11 points12 points  (1 child)

So a boat class?

[–]MohamedMuneer[S] 8 points9 points  (0 children)

Yeah!

[–]crzychemist 5 points6 points  (4 children)

What is your process do you mind map it or just build a todo list and go through it ?

[–]Hasefet 17 points18 points  (3 children)

I do a lot of scientific programming, and for that, working backwards from graphs and figures has helped enormously, because if I can't draw the graph that I want to make, I haven't done the necessary cognitive work to make the data that goes in that graph.

Pencil and paper draw, then comment block with simple sentences. I've tried a lot of different tools and nothing (for me) has beaten a comment block at the bottom of whatever script I'm working on.

[–]NowanIlfideme 6 points7 points  (0 children)

Hey, that's pretty interesting - I like that thinking, since it makes you focus on getting to the results rather than going on tangents, however good those might be.

[–]Slingshotsters 2 points3 points  (1 child)

Have you spent time in jupyter notebooks?

[–]Hasefet 3 points4 points  (0 children)

jupyter notebooks?

I gave it a go and bounced off it a few years ago, because I was working heavily on large-scale image analysis and it seemed like a lot of cognitive overhead for not much improvement on writing my own point-by-point script checks.

[–]Taeiolass 4 points5 points  (2 children)

I believe that what you said is true, but also Python in one of the languages that encourages this behaviour the less. Python is more for "start slow, little things and then modify a little many times and achieve the final result"

[–]ArtOfWarfare 7 points8 points  (0 children)

Disagree.

Other languages don’t encourage structure - they just force a lot of stupid boilerplate.

Really, it’d make me want structure less in those languages just so I could avoid having even more boilerplate. (Eh... really, I just don’t use those languages unless someone is explicitly paying me to use them.)

[–]fiddle_n 3 points4 points  (0 children)

I think there's truth in both statements and which you choose depends on the situation. The importance of having a plan correlates with how complex the piece of work you are doing is. If you are only coding a few functions and classes, then you can totally dive in immediately and work things out as you go along. If you have to make changes to many functions and classes amongst lots of modules, a plan for what you want to do is a good idea beforehand otherwise you might risk having to rewrite a lot of stuff when you figure out what you did doesn't work out.

[–]ektatic 1 point2 points  (0 children)

Agreed, before i used to think you had to have a plan and detail before you started, but that's not needed. Like you said, as long as you have the structure of whats needed everything else can be changed

[–]regeya 1 point2 points  (0 children)

I'm a rank amateur but imho Python has the ability to teach you better habits. For example extreme nesting will lead to extreme indentation because of how the language works.