r/transprogrammer • • Sep 05 '22

I'm Making a Thing. Roast my Code?

I saw an Atomic Shrimp video about a singe board computer that just boots into a BASIC interpreter, and wanted to write an interpreter of my own. But I've got no clue what I'm really doing, so we get this

58 Upvotes

25 comments sorted by

View all comments

Show parent comment

3

u/anarchy_witch Sep 06 '22

useful comment i found about splitting functions:

A good goal is to make a function do exactly one thing. In realistic programming, this usually doesn't happen strictly, but it's still a good way to judge a function's length. If it's doing too much, you should definitely split it up. I try not to let my functions get past 20-30 lines unless absolutely necessary before I start looking for ways to break them up.

2

u/Jake_2903 Sep 08 '22

Throwback to the time my function had 350 lines, went through a directory file by file, subdirectory by subdirectory, checked file type, called a function to read the file line by line and then wrote the contents to a .tar archive.

Thank god it was graded by automatic testing and nobody looked at it. Somehow I got 9.7/10 for it.