Most active commenters
  • bluGill(3)
  • mmcnl(3)

←back to thread

873 points belter | 54 comments | | HN request time: 0.861s | source | bottom
1. ZaoLahma ◴[] No.42947654[source]
> Most programming should be done long before a single line of code is written

Nah.

I (16+ years developer) prefer to iteratively go between coding and designing. It happens way too often that when you're coding, you stumble across something that makes you go "oh f me, that would NEVER work", which forces you to approach a problem entirely differently.

Quite often you also have eureka moments with better solutions that just would not have happened unless you had code in front of you, which again makes you approach the problem entirely differently.

replies(16): >>42947849 #>>42948402 #>>42948536 #>>42948683 #>>42948786 #>>42949252 #>>42949429 #>>42949588 #>>42950167 #>>42950238 #>>42950409 #>>42953785 #>>42955243 #>>42956358 #>>42957524 #>>42964457 #
2. gaptoothclan ◴[] No.42947849[source]
ok that sounds bad, you should have the option to go back to design, but depending on what point you find that issue, depends on how much time you have wasted?
replies(1): >>42948121 #
3. ZaoLahma ◴[] No.42948121[source]
It's about defining and solving small problems all the way, and avoiding trying to solve big problems.

If you manage to restrict yourself to only solving small problems (THIS is the true challenge with software engineering, in my humble opinion), then you won't ever have wasted too much time if (when) you need to reset.

4. gmm1990 ◴[] No.42948402[source]
I assume there are people who are able to have those eureka moments before writing any code. I definitely write a lot of code before figuring out the final design but always think I should be designing more.
replies(1): >>42949244 #
5. VyseofArcadia ◴[] No.42948536[source]
Iterative work is THE way to work in large legacy codebases. The minute you wade into the code, all of your planning is moot. You don't know what's lurking below the surface. No one knows what's lurking under the surface. Except maybe Dave, because he vaguely remembers about 15 years back talking to some guy who wrote some code 30 years back about it.

Greenfield, absolutely design up front you lucky devils, but iterative is the way otherwise.

replies(6): >>42948610 #>>42949170 #>>42949340 #>>42951151 #>>42956824 #>>42962429 #
6. renewedrebecca ◴[] No.42948610[source]
Every development shop has a Dave.
7. Kichererbsen ◴[] No.42948683[source]
Most programming is actually figuring out what already exists and what (and more importantly: why) the requirements are. This is best done long before a single line of code is written.

I think the author is taking a wider view of "programming" than the actual writing of code as the end product. Some of the most important work I've done is spend the time to argue that something doesn't need to be done at all.

replies(5): >>42948930 #>>42951241 #>>42954021 #>>42955288 #>>42957541 #
8. AnimalMuppet ◴[] No.42948786[source]
Always think bigger picture than what you're immediately working on. (I don't mean that you can't ever just focus on the problem you're trying to solve for, say, hours. I mean you can't focus like that for the entire time you're in that development phase.)

Think about design and code (and functionality!) before you start coding. Think about design as well as code while you're coding. Think about design, code, and functionality while you're testing.

9. VyseofArcadia ◴[] No.42948930[source]
> what (and more importantly: why) the requirements are

Maybe in a startup? My experience as an IC in larger, more established companies is the requirements are dictated to you. Someone else has already thought carefully about the customer ask, your job is just to implement, maybe push back a little if the requirements they came up with are particularly unreasonable.

replies(1): >>42949226 #
10. bluGill ◴[] No.42949170[source]
Greenfield lasts only for at best 2 years or the first public release. After that it is legacy.

I'm am the "Dave" on my current code since I was one of the first engineers on the project and the others before me have long moved to management. There is a lot I don't know about how the code works. There are dark corners we just lifted completely from an earlier project where the guy who wrote it 30 years back is retired. This is normal.

I'm fighting desperately to keep this code in shape as I don't want to go to management to ask for $$$ (billions) to rewrite it. I regret many choices. I'm making other choices in response that I fear someone will regret in 15 more years. I'm hoping to retire before then - better talk to me now because soon the people who have talked to the person who wrote the code 30 years ago will also be a memory. (the guy who write the code 30 years ago is still alive and someone has his phone number - they talk once a year about something weird to see if why is remembered)

replies(1): >>42961838 #
11. bluGill ◴[] No.42949226{3}[source]
If you dig deep you discover they have figured out some requirements in detail, but there is a lot missing. Is this new feature that last one in that line, or will there be more options in the future? Is this new feature really going to be used - many times we have put large effort into features only to discover no customer used them (as evidenced by the critical bug that made the feature unusable outside of the test lab that nobody complained about until 4 years had passed). These things drive how you engineer the thing in the first place.
12. bluGill ◴[] No.42949244[source]
Always plan to throw one away. You will, so best to plan for it. (paraphrasing Fred Brooks)
13. davidw ◴[] No.42949252[source]
Yeah, the other stuff seems sensible or at least "Ok, I can see that", but I definitely disagree with this one.

You should spend time thinking about stuff beforehand, sure, but getting your hands dirty is also going to reveal things.

replies(1): >>42949302 #
14. pinoy420 ◴[] No.42949302[source]
Very surprised at this attitude.

Or am I. The typical engineering savant omniscient to all future past and present engineering roadblocks fixed by “Just”(TM) thinking about it beforehand. I expect this from bay area mid level not someone with credentials.

Strange because I agree with so much more of the article

replies(1): >>42949827 #
15. braggerxyz ◴[] No.42949340[source]
Today's greenfield is tomorrow's legacy. So this statement still holds true ;)
16. mamcx ◴[] No.42949429[source]
What I think is a better way to say this is that you need a `design` phase before actually writing the first `real` implementation code.

Something I do a lot, and even more with the LLMS, is that I make `scratch` projects where I sketch code over and over (and maybe make mockups in Keynote or similar, make some notes, etc), then write from scratch again in the real codebase.

17. nerdralph ◴[] No.42949588[source]
I agree coding should start early. The design might look good, but might not be easy to implement, so you need to change the design.

The statement sounds like something out of a book on the waterfall method of software development.

18. davidw ◴[] No.42949827{3}[source]
TBH, I think it's more of a 'manager' attitude. A lot of actual "hacker" type people are very much in the "rough consensus and working code" category where you see what works by doing it.
19. knighthack ◴[] No.42950167[source]
'Programming as theory-building' is an approach that has grown on me in the past few years.

Your first draft may be qualitatively an MVP, but it's still just a theory of a final product you want, which requires a lot of iterative building before you get to that.

As such, there's no way to not shift between code and design, especially when business requirements are involved and which themselves may change over time.

replies(2): >>42957544 #>>42964997 #
20. recroad ◴[] No.42950238[source]
Developer for 20+ years. I can't even design anything without coding something.
replies(4): >>42950563 #>>42952446 #>>42957299 #>>42960930 #
21. jrochkind1 ◴[] No.42950409[source]
The OP didn't say what it is they're talking about that should be done before writing any code.

He might have meant design, and I'm not sure about that.

But the other thing i think of is: Understanding the problem.

It's hard to do too much of that before you start coding, and easy to do too little.

It overlaps with design to some extent, because once you understand the problem better, some designs will naturally seem inappropriate or better -- without having to spend time allocated to "designing" necessarily, just when you design you're going to come up with things that work a lot better the better you understand the problem you are trying to solve.

How the stakeholders see it, and what's really going on, and why it's a problem, and what would make an acceptable solution, and what the next steps down the road might be.

replies(1): >>42951384 #
22. jillesvangurp ◴[] No.42950563[source]
Exactly. I did a Ph.D. on software engineering and architecture before embarking on a career practicing what I preach. One thing that I realized early is that designs always lag implementations. They are aspirational at best. And people largely stopped using design tools completely when agile became a thing. Some still do. But you'll look in vain for UML diagrams on most software you ever heard off.

I now have a few decades of experience doing technical work, running startups, teams, doing consultancy, etc. Coding is my way of getting hands on. It's quicker for me to just prototype something quickly in code than it is to do whatever on a whiteboard. I always run out of space on whiteboards and they don't have multi level undo, auto completion, etc. They really suck actually. I avoid using them.

Of course, I sometimes chin stroke extensively before coding; or I restart what I'm doing several times. But once I have an idea of what I'm doing in my head, I stub out a solution and start iteratively refining. And if I'm stuck with the chin stroking, the best way to break through that is to just start coding. Usually, I then discover things I hadn't thought about and realize I don't need to over complicate things quite as much. This progressive insight is something you can only gain through doing the work. The finished code is also the finished design; they co-evolve and don't exist as separate artifacts.

The engineering fallacy is believing that they are separate and that developers are just being lazy by not having designs. Here's a counter argument to that: we don't build bridges, rockets, expensive machines, etc. Our designs compile to executable code. Physical things have extensive post design project phases where stuff gets built/constructed/assembled. Changing the design at that stage is really expensive. For software, this phase is pretty much 100% automated in software. And continuous deployment means having working stuff from pretty much as soon as your builds start passing. Of course refactoring your design/code still is important. You risk making it hard to evolve your software otherwise.

The process of designing a bridge is actually more similar to developing software than the process of constructing one. The difference is that when you are done with the bridge design, you still have to build it. But it's a lengthy/risky process with progressive insights about constraints, physics, legislation, requirements, etc. Like software, it's hard to plan the design. And actually modern day architects use a lot of software tools to try out their designs before they hand them over.

Just some simple insights here. There is no blue print for the blue print for either bridges or software. Not a thing, generally.

23. devmor ◴[] No.42951151[source]
As someone who's spent 12 years working on legacy codebases, I strongly disagree with this.

Iterative work in a large legacy codebase is how you end up making your large legacy codebase larger and even less understood.

Your planning should "wade into the code" from the start. I have always gotten better results by charting out flow diagrams and whiteboarding process changes than just "diving in and changing stuff".

Frankly, I'd say it's the opposite for greenfield development. Doing iterative work to build out a new product and make changes as you discover needs you didn't account for makes a lot more sense that flailing around making holes in something you don't fully understand that is tied to active business needs.

replies(1): >>42951819 #
24. ◴[] No.42951241[source]
25. x3n0ph3n3 ◴[] No.42951384[source]
Then the author should have said "Most software development should be done long before a single line of code is written"

Programming is specifically about the authorship of code.

replies(1): >>42966071 #
26. 9rx ◴[] No.42951819{3}[source]
> I have always gotten better results by charting out flow diagrams and whiteboarding process changes than just "diving in and changing stuff".

In terms of a broad population, I am not sure there is a meaningful difference, though. You can iterate on your ideas on the whiteboard or you can iterate on your ideas in code, but the intent is the same. Either way you are going to throw it all away once you have settled on what should be the final iteration anyhow.

It just comes down to where you are most comfortable expressing your ideas. Some like the visuals of a diagram, others are more comfortable thinking in code, some prefer to write it out in plain English, and I'm sure others carry out the process in other ways. But at the end of the day it is all the same.

replies(2): >>42952443 #>>42952932 #
27. mjlawson ◴[] No.42952443{4}[source]
> Either way you are going to throw it all away once you have settled on what should be the final iteration anyhow.

I think this needs to be highlighted, because while I completely agree, I think it's often implicit, taken for granted, and neglected. Far, far too often I've seen code bases bloat because this never takes place. The sentiment at a lot of places seems to be, if the tests pass, ship it. Arguably, it may even be the right decision.

28. declan_roberts ◴[] No.42952446[source]
It's like giving an estimate for a bathroom remodel for a house you've never seen. You gotta get in there first.
replies(1): >>42961646 #
29. devmor ◴[] No.42952932{4}[source]
I have never really thought about it that way, but you're right.

Ultimately what matters is the final changeset. How you get there doesn't really matter.

30. dkarl ◴[] No.42953785[source]
> I (16+ years developer) prefer to iteratively go between coding and designing

I have an extra ten years on you and couldn't agree more.

There are two jokes:

- A few months of programming can save weeks of design.

- A few months of design can save weeks of programming.

Inexperience is thinking that only one of these jokes is grounded in truth.

Recognizing which kind of situation you're in is an imperfect art, and incremental work that interleaves design with implementation is a hedge against being wrong.

replies(2): >>42957294 #>>42957560 #
31. polishdude20 ◴[] No.42954021[source]
This makes me think it would be really cool to tie code sections to slack conversations or emails. There's always commit messages yes, but most product decisions on why something was done lives in slack at least where I've worked.

Even an AI tool that takes a slack thread and summarizes how that thread informed the code would be cool to try.

replies(1): >>42954422 #
32. dhosek ◴[] No.42954422{3}[source]
I always fight to get this stuff into JIRA (or whatever equivalent tool we’re using), and then make sure that all commits have the JIRA ID in them.
replies(1): >>42956468 #
33. mmcnl ◴[] No.42955243[source]
Yeah, validate your assumptions. Nothing ever works the first time. Quick iterations to get feedback is the way.
34. mmcnl ◴[] No.42955288[source]
And how do you figure out what the requirements are? In my 10+ professional years, I have never gotten requirements by asking for them. Almost always I had to show my interpretation of what I think the requirements are, and use the feedback I got to define the actual requirements. The quickest way to get there is by iterating.
replies(1): >>42957490 #
35. standardUser ◴[] No.42956358[source]
Absolutely, though sometimes it's more about reading code or 'playing' with code than writing/committing code. I try to always be hoping around my codebase during meetings.
36. Izkata ◴[] No.42956468{4}[source]
Works great until you're not using it anymore. We're on our third system, all the cases from the first one and most from the second one are long since gone. Meanwhile the commit messages survive it all, even across cvs -> svn and svn -> git migrations.
37. johnnyanmac ◴[] No.42956824[source]
>Everyone has a plan until they get punched in their face (by landmines in legacy code)

unless you have the old maintainer on call (I rarely did due to them leaving the company years ago) you definitely need to move slowly. rely on test suites if you are blessed with them. Submit small changes that pass tests.

BTW, nice and timely username.

38. spartanatreyu ◴[] No.42957294[source]
I like to say:

- One hour of planning saves ten hours or programming...

- and one hour of research saves ten hours of planning.

You can also invert it:

- Ten hours of programming saves one hour of planning...

- and ten hours of planning saves one hour of research.

replies(1): >>42960736 #
39. kstrauser ◴[] No.42957299[source]
I've compared it to finding the integral of a function. Unless it's trivial or closely resembles something I've done before, how am I going to have the faintest idea what it's going to be like until I start?

Sometimes the exploration is the design process.

40. spiderxxxx ◴[] No.42957490{3}[source]
You don't ask for the requirements. You ask what they're trying to do, or what problem they're trying to solve. Sometimes I have to ask "where is this data going" or "what do you expect the end result of this to be".
replies(1): >>42994618 #
41. stevage ◴[] No.42957524[source]
This kind of thing is incredibly context dependent.

But it basically sounds like waterfall development, which is a reasonable approach in certain contexts.

But this thinking doesn't really make sense for any of the projects I work on.

42. stevage ◴[] No.42957541[source]
> Most programming is actually figuring out what already exists and what (and more importantly: why) the requirements are. This is best done long before a single line of code is written.

Calling requirements gathering "programming" is just misusing a term for no good reason. By all means, include it in "software development" but it clearly isn't "programming".

43. nradclif ◴[] No.42957544[source]
> Programming as theory-building

Sounds similar to https://en.m.wikipedia.org/wiki/Curry–Howard_correspondence.

44. jfengel ◴[] No.42957560[source]
The difference between DRY and YAGNI is experience. Both are predicting the future, and you can only do that by having watched code evolve.
replies(1): >>42962887 #
45. baud147258 ◴[] No.42960736{3}[source]
> - Ten hours of programming saves one hour of planning...

If the planning is done with 5 or more people in a meeting, there still might be some time savings...

46. dsego ◴[] No.42960930[source]
You could try writing an RFC or a tech spec sometimes with different approaches, proposed solutions, pros/cons. It's basically coding and designing the system in your mind and anticipating issues and challenges. It's a good exercise to do this before writing a line of code. The more you do it, the easier it gets, the mind starts to think about different approaches and pitfalls, you get into a focused state where the brain organizes the logical flow and then you can write a rough outline without caring about making the compiler happy or what the exact syntax is. Sometimes it also helps to translate this high level outline into pseudocde in a comment and then fill in the blanks with actual code.
47. mexicocitinluez ◴[] No.42961646{3}[source]
I'd go one further and say it's an estimate for a bathroom remodel in a house you've never seen that turned out to actually be a garage remodel instead.
48. arkh ◴[] No.42961838{3}[source]
> I'm making other choices in response that I fear someone will regret in 15 more years.

Junior dev made to maintain some code base: "wtf, all this old code suck. People were really bad at their job".

Same dev 5 years later: "wellll, this looks bad but there must be a reason.". Usually the reason is someone sold a new feature without asking the implementers or even checking what the impacts could be. So it has to be ready yesterday and you'll never get approval to refactor or clean-up anything, until it breaks.

49. scotty79 ◴[] No.42962429[source]
> Greenfield, absolutely design up front you lucky devils, but iterative is the way otherwise.

That only works for greenfield projects where you have extensive experience with everything that is going to be used on that project. For all others you still learn as you go and all plans and designs need to be revalidated and updated multiple times.

50. bena ◴[] No.42962887{3}[source]
What's that saying? "Once is a mistake, twice is a coincidence, three times is a pattern".

Having to write something once, just write it.

Having to write something twice with small differences, think about it.

Having to write something three times? Consider refactoring.

51. eyelidlessness ◴[] No.42964457[source]
Agree. Although I increasingly spend this iteration time on types/interfaces/documenting proposal of same. The actual implementation below that is often trivial once the boundaries are settled.
52. beryilma ◴[] No.42964997[source]
Relevant HN discussion: https://news.ycombinator.com/item?id=42592543
53. jrochkind1 ◴[] No.42966071{3}[source]
Right, by your interpretation what they suggested is logically impossible (one can't possibly write any code, let alone most, before one writes a single line of code), so I understand you think they should have written differently, but its clear they meant something else, I would assume they meant programming as a synonym for software development, right.
54. mmcnl ◴[] No.42994618{4}[source]
Not disagreeing here but whatever question you ask, you will only get the final answer _after_ you have implemented it, almost always after several iterations.