63 ms·
This, to me, is one of the biggest problems facing our industry. In first year undergraduate in engineering we learn how to design a state machine. We learn to
by userbinator 9y ago
This, to me, is one of the biggest problems facing our industry. In first year undergraduate in engineering we learn how to design a state machine. We learn to design one before we learned OOP and circuits and assembly.
I think one of the causes is that a lot of CS is taught top-down and not bottom-up, so things like flowcharts, state diagrams, and other similar visual aids are completely skipped in preference to more abstract thinking. I wonder if at least some of this aversion is directly related to the "gotophobia" that started with Dijkstra's famous paper.
It may seem difficult and tedious, but this is how you engineer something rather than merely 'develop' it.
As someone who learned the "old school" way of planning out your code --- yes, even drawing flowcharts and state diagrams --- before writing a single line of it, I can assuredly say that it should be a natural and completely pleasant process; what's "difficult and tedious" is trying to debug and coerce something you (or someone else) wrote without planning into working correctly.
Over the years coworkers have been puzzled at why I spend "so much time" flowcharting and just thinking before writing even a single line of code --- only to try adopting the same method once they realise how much time it saves in total, since all the cases have already been accounted for and the only thing left to do is test out any of the few remaining and often trivial bugs introduced during the design->code process.
- digi_owl 9y agoIt also takes all the "fun" out of programming, as so many seems to approach it like some grand display of mental prowess. Never mind the whole "agile" thing...
- reitanqild 9y agoYou can look at this both ways actually: For some people (like me) thinking through problems with pen and paper is a tool. For others I guess it is annoying: look at him, now he's doing this wannabe software architect stuff again. Same might go the other way: here he goes again, trying to prove his programming super skills by jumping into it without even the smalles amount of planning.
- Swizec 9y agoFWIW I like to jump in and start coding, but what’s happening behind the scenes is that I “see” the algorithm or architecture in my mind. It’s not exactly a foowchart or a state machine, but it does have a sort of plastic manipulatable shape.
- reitanqild 9y agoAs someone who does both (flowcharts etc and exploratory coding) I think I experience something similar. For me it is not very visual when I code. It is more a gut feeling: this goes here, that goes there. This is good, bad, weird but works etc. This is nice for me but I know I have to work on how to explain it to others. Bad example but I guess this is somewhat closer to what I want to be able to explain: "it currently works but it is a bad idea because it means you'll have to remember to patch seemingly unrelated functions x, y and z whenever you update this. Also, in this case it is even worse as in the worst case you won't see the errors until the quarterly reporting run and that code is well known for having bad test coverage." Edit: as usual I'm curious as to why parent was downvoted?
- throwaway613834 9y agoFWIW I don't think other people who jump in and begin coding are doing so blindly either. i.e. they do the same thing you do.
- Swizec 9y agoEveryone was presenting it as a dichotomy in this thread \_(ツ)_/¯ Seemed relevant to point out that at least for me it’s not.
- closeparen 9y agoExcept at the highest level of abstraction, my Lucidchart diagrams and Google docs never survive their first encounter with the compiler. There always turns out to be some fatal flaw that's obvious in an editor but totally escaped me in the word processor. My (limited) experience has been teaching me the opposite: dive in as quickly as I can and write some code to explore the problem space, then go think harder about a design after getting my feet wet.
- reitanqild 9y agoPeople are very different it seems. I enjoy both diagramming and early exploratory coding. I have real problems when one of my (really smart) colleagues wants to discuss some code we have neither written nor diagrammed yet. For her however that seems to be the natural way of doing it and when we started working together I had to point out that just didn't work for me. It seems to me that knowing and being aware and accepting of the different learning styles can solve a number of problems in teams.
- enraged_camel 9y ago>>There always turns out to be some fatal flaw that's obvious in an editor but totally escaped me in the word processor. This problem goes away once you gain some experience - both in writing specs and in programming. Think of it this way: do engineers build bridges without design documents and diagrams? No. So why are you writing software without them? If you aren't familiar with the problem domain, fine, do it the agile way. But once you gain experience there is no excuse to not thinking problems through in advance before trying to solve them.
- closeparen 9y agoIt's faster and more pleasant to write working code than to write prose descriptions of hypothetical code. Documents are cheaper to create and easier to change than bridges. Code is just another kind of document. I've a sneaking suspicion that bridge building would look more like software if we could drive over AutoCAD models. (Or that software would look more like bridge building if we were still compiling by hand). EDIT: I should add that I certainly do write and communicate documents about "what business problem does this even solve" and "what does it do" and "what are the major components and what are they responsible for" and "did you consider X alternative design" but planning down to the level of function signatures has usually turned out to be a waste of time.
- criddell 9y agoDo you keep your documents up to date? I will occasionally sit down and diagram how I want everything to work usually in a simplified UML diagram, an FSM diagram, or a sequence diagram. It certainly makes initial development faster. But then the changes start and now I either discard the diagrams or accept that I have two things to maintain. Generally I take the former path because divergence from the plan is almost inevitable on anything that's alive.
- andrewflnr 9y agoYou do realize how bizarre it is to blame lack of rigor in CS on the author of "On The Cruelty Of Really Teaching Computer Science", right? http://www.cs.utexas.edu/users/EWD/ewd10xx/EWD1036.PDF http://www.cs.utexas.edu/users/EWD/ewd10xx/EWD1036.PDF
- throwme211345 9y agopseudocode and application logic is absolutely necessary. Visualization is cumbersome and unnecessary except in large codebases.
- nwmcsween 9y agoI usually hack out something fast to understand the issues (there will always be issues) and reiterate by modifying old code to the new func/api which allows me to find corner cases.