Python Forum
Approach to coding, good/bad
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Approach to coding, good/bad
#11
IT's kind of a double edged sword, because when you code like that, you get fast results on small functions and projects, but big projects you run into problems down the line. My current project, the food distribution logistics program i am working on with quite a bit of community help, i started with an idea of what needed accomplished, wrote down some goals and necessary items, then i dove right in after not touching python for about a year and a half. I had definitely forgotten more than i thought, not to mention i wasnt all that great a year and a half ago. So now i have basic input and some of the output i need, but the actual problem itself isnt solved. I thought i could figure out how to do the final step on the fly, but now i think i might have made a big mistake. I cant quite solve my final problem, and now a solution may require rewriting lots of the current program. So you should always set out at least a list of goals, but you should probably learn to work from the inside out, get the processing done first with stand invariables instead of inputs and interaction, then develop the interaction up to the UI. I really have appreciated all the community help on my project, and i am taking a couple courses to brush up my python skills before i keep charging forward.
Reply
#12
Quote:So you should always set out at least a list of goals
I think you missed the point of the overall thread.

This thread advocates having a very good and complete overall plan.
Details are often trial and error, but only for small unproven parts.
The folks of this forum are professionals and have been involved in some huge
successful projects, many for billion dollar companies, and or governments.

So even though a few of the posts say no planning here, the overall concensus is
that a planning is most important

What I am saying is that the thread agrees with you.
Reply
#13
(Apr-13-2017, 07:13 PM)Larz60+ Wrote:
Quote:So you should always set out at least a list of goals
I think you missed the point of the overall thread.

This thread advocates having a very good and complete overall plan.
oh, the days of Pearly Spencer, sorry - waterfall
Didn't it work well  Wall . 
But of course it's a folly to write "quick and dirty" - and then redoing it. I try to start writing proper code from the start - including some rudiment comments. Occasionally it turns right  Tongue

But you make - and fix - mistakes. As you go, you realize that things don't work exactly as you planned. Then someone tells you that you misunderstood the requirements - or they were wrong. Then someone changes requirements.
But the cleaner the initial code was - the easier refactoring will be (about a year ago - commit of 400 changed lines Pray in 2 days).
It is important to keep in mind have to understand that occasionally even project developer - when visiting his/her own old code - will have to spend some time to figure out what the hell were the intentions. 
So, again - the cleaner is the code from the start, the easier life will be in the long run

PS Several times in my career as QA Automation Developer I was preached by my managers that they don't care about performance, code quality - I must quickly supply solutions to the problems that the management piles on me. And they did not understand that those solutions eventually turn into problems Angry
Test everything in a Python shell (iPython, Azure Notebook, etc.)
  • Someone gave you an advice you liked? Test it - maybe the advice was actually bad.
  • Someone gave you an advice you think is bad? Test it before arguing - maybe it was good.
  • You posted a claim that something you did not test works? Be prepared to eat your hat.
Reply
#14
(Apr-19-2017, 09:55 PM)volcano63 Wrote: will have to spend some time to figure out what the hell were the intentions

Which is what comments are for (if the code is well written they are unnecessary to understand how it works).
Unless noted otherwise, code in my posts should be understood as "coding suggestions", and its use may require more neurones than the two necessary for Ctrl-C/Ctrl-V.
Your one-stop place for all your GIMP needs: gimp-forum.net
Reply
#15
(Apr-22-2017, 12:34 PM)Ofnuts Wrote: (if the code is well written they are unnecessary to understand how it works).
Depends on the complexity of the implemented algorithm. I like KISS as any other guy  Tongue but occasionally you have to implement something non-trivial....
Test everything in a Python shell (iPython, Azure Notebook, etc.)
  • Someone gave you an advice you liked? Test it - maybe the advice was actually bad.
  • Someone gave you an advice you think is bad? Test it before arguing - maybe it was good.
  • You posted a claim that something you did not test works? Be prepared to eat your hat.
Reply
#16
(Apr-23-2017, 07:16 PM)volcano63 Wrote:
(Apr-22-2017, 12:34 PM)Ofnuts Wrote: (if the code is well written they are unnecessary to understand how it works).
Depends on the complexity of the implemented algorithm. I like KISS as any other guy Tongue but occasionally you have to implement something non-trivial....

Implementing the algorithm is the intent of the code...
Unless noted otherwise, code in my posts should be understood as "coding suggestions", and its use may require more neurones than the two necessary for Ctrl-C/Ctrl-V.
Your one-stop place for all your GIMP needs: gimp-forum.net
Reply
#17
(Apr-23-2017, 09:19 PM)Ofnuts Wrote: Implementing the algorithm is the intent of the code...

No shit Naughty? Any more words of wisdom?
Test everything in a Python shell (iPython, Azure Notebook, etc.)
  • Someone gave you an advice you liked? Test it - maybe the advice was actually bad.
  • Someone gave you an advice you think is bad? Test it before arguing - maybe it was good.
  • You posted a claim that something you did not test works? Be prepared to eat your hat.
Reply
#18
Language please.  Remember we are a public forum with young members and viewers.
If it ain't broke, I just haven't gotten to it yet.
OS: Windows 10, openSuse 42.3, freeBSD 11, Raspian "Stretch"
Python 3.6.5, IDE: PyCharm 2018 Community Edition
Reply
#19
(Apr-22-2017, 12:34 PM)Ofnuts Wrote: Which is what comments are for (if the code is well written they are unnecessary to understand how it works).

Common sense is not common, and intuition is not intuitive. Always comment your code.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#20
Get into the habit of writing tests. For one, they give you safety. If you're testing manually, you have the problem of making changes and not really knowing whether you've broken anything else in doing so until you run the application. If you write tests, you can run them after making the changes and find and fix any breakages before running the application. Clearly, when developing software for use in the real world that's very important and I think it's useful to gain those skills. Python comes with a unit testing module (unittest) and Kent Beck's "Test Driven Development: By Example" is a good intro book on writing tests first (the examples in the first part are in Java, mind). Working in a test driven manner also helps you to focus on small chunks of the application at a time, rather than having to keep everything in mind at once.

I'm not a big fan of commenting code, because the only thing that tells you what the code does is the code itself (and the tests, of course!) - comments can be misleading (e.g. if they're out of date) and extra noise (I've seen lots of commented out code just left there in projects I've worked on). I much prefer code to be written in a way that makes the intent clear - by using good names and breaking things down into small pieces (like nice, small functions).
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to approach pyusb application arch m3atwad151 0 728 Nov-10-2022, 06:11 AM
Last Post: m3atwad151

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020