Live data from Hacker News

Ask HN: How’d you go from a noodler to writing large well structured programs?

news.ycombinator.com

11–20 of 77 posts

Re: Ask HN: How’d you go from a noodler to writing large well structured programs?

#11
I keep writing small programs and each time, I'm finding more efficient ways to write it or learning new things. As I develop new web apps, its like my mind has evolved to say, "I can do this more efficiently and with less code."

Definitely have come along way from the first web app I wrote. Can't say it was not without a lot of writing echo 'test'; to see exactly where the error was, though of course, most frameworks tell you exactly where the error is now, but it helps with testing and debugging.

I do a lot more brainstorming in the beginning, designing of the web app, and then actual coding. It's really just practice. Learning how to keep your code organized and understandable for yourself. Write as if someone is looking over your code and isn't as smart as you :P

Re: Ask HN: How’d you go from a noodler to writing large well structured programs?

#12
SICP

I read it in my late teens, and it's what made things finally click re: structuring programs. (This was back in the 90s, when it was far more difficult to inspect other well-structured software that wasn't also low-level C code.)

https://en.wikipedia.org/wiki/Structure_and_Interpretation_o...

Re: Ask HN: How’d you go from a noodler to writing large well structured programs?

#13
Familiarity with design patterns in general can help with structuring systems.

Look at structural and behavioral patterns on https://en.m.wikipedia.org/wiki/Software_design_pattern

Facade, strategy , adapter, etc.

Also think about "levelization" John lakos explains that clearly.

Re: Ask HN: How’d you go from a noodler to writing large well structured programs?

#14
I've found that Matlab is good at prototyping but poor in structuring into large applications with complex physical structure. I'm sure things have changed over the years but the sort of folder oriented loading of modules from the working directory baked habits into people that are hard to break I imagine. Give Large Scale C++ Software Design by Lakos a read to learn about the issues involved in ramping up tall dependency chains. A lot of the book is naturally C++ oriented and thus focuses on impact to compile and link time, but the dependency concepts live on in other languages. Find a CASE tool that works for you https://en.wikipedia.org/wiki/Computer-aided_software_engine.... Visualizing codebases with auto generated diagrams from something like CppDepend or any of its cousins can enlighten a lot. But getting masterful at these subjects is really what Software Architecture is all about. There was a fella by the name of Juval Lowy peddling some architecture training/certification wizardry. Read up on Martin Fowler too, he has good subject matter in this area.

EDIT: But for your immediate Matlab concerns I remember some StackOverflow questions about structuring large matlab applications. I just learned from one that Matlab has this notion of packages I was previously unaware of: https://stackoverflow.com/questions/2748302/what-is-the-clos... https://stackoverflow.com/questions/27861304/managing-bigger... https://stackoverflow.com/questions/2326609/how-to-visualize...

you may search StackOverflow for "matlab packaging" "matlab organization" "matlab structure" etc to get likewise hits.

Re: Ask HN: How’d you go from a noodler to writing large well structured programs?

#15

Lots of mistakes, and working with smart people who were kind enough to point out the deficiencies in my early and crude approaches, reading many articles and blog posts on every sort of programming topic, and finally and most directly important was reading through codebases at places I worked or open-source projects in my early years and learning from what other people were doing more correctly.

Working with smart people who were kind enough to point out the deficiencies in my early and crude approaches

This point cannot be underemphasized.

There's no end of stuff you can read online about better practices, these days. But those experience I had working with people who, without so much taking "pity" on me, took me seriously, despite my obvious naivete in certain areas - I'm not sure whether I would have gotten anywhere at all without them.

Re: Ask HN: How’d you go from a noodler to writing large well structured programs?

#16
post #4

https://bramcohen.livejournal.com/4563.html ... the founder of bittorent. Ill add a personal note. Being a good professional programmer is also about understanding the context of your program. You will not always have the time to optimize for performance. You will not always have the time to refactor functionality to make it more modular for further variety. Sometimes you will need to skip test becuase deadline says…

That post is more about the architecture of the BitTorrent network than the original BitTorrent client.

As somebody has a built on top of the original BT codebase, it is not a well structured large program, and there is a reason nobody uses it for anything anymore.

Re: Ask HN: How’d you go from a noodler to writing large well structured programs?

#17
I suggest reading the book "Clean Code". I've worked with traders/business analysts who do some coding but it isn't their full time job and their code quality isn't great.

After having them read the book and then following up with code reviews from a senior developer they improved their code significantly in just a few months.

"Refactoring" is also a good book, but a lot of time it is too advanced for people who copy and paste code all over and don't use functions, etc.

Re: Ask HN: How’d you go from a noodler to writing large well structured programs?

#18
IMO poor structure of a codebase is a sign that there is a culture problem. You acknowledge that there is an issue but have dedicated no resources to solve it. The way to fix sloppiness is to break your bad habits for new code, and then fix the issues with the old code over time.

My recommendation would be to begin adding tests to your code, keep files sizes manageable (under 120 lines), keep functions under 7 lines. In general just be a professional instead of running around trying to fight fires all the time. Luckily 15k lines of code is a pretty small project so you aren't completely screwed.

Re: Ask HN: How’d you go from a noodler to writing large well structured programs?

#19
post #5

Look at some good open source projects, and look at the overall project/module structure as well as the OO graph. Re: high-level project layout: - where are their build files? - how are the source packages broken up? - where are the tests stored? Trace back from the entry point to the code and look at how things are encapsulated, where code gets re-used. Diagramming out with something like UML is cumbersome but can b…

A good place to start would this repo that outlines some popular folder structure conventions: https://github.com/kriasoft/Folder-Structure-Conventions

Re: Ask HN: How’d you go from a noodler to writing large well structured programs?

#20

I suggest you hire a software developer, preferably a senior one if you can afford it. The difference between a bunch of impressive algorithms written by specialists in the field stitched together by brittle connections, and a bunch of impressive algorithms that are part of a well structured, tested and maintainable suite is huge. Reading a book or two is not going to solve the problem in the long term, which I assum…

To add to this: what you have now is likely a 20% product - something on the level of a proof of concept.

All of that connecting tissue that makes things robust can take quite a bit of work, and it's really hard to see whether it's robust or not for a while.

Post reply on HN