basic-computer-games icon indicating copy to clipboard operation
basic-computer-games copied to clipboard

Code decomposition question

Open DiskJunky opened this issue 2 years ago • 4 comments
trafficstars

I've been looking through some of the csharp versions and some lump all the code into a single Program.cs file. While this works, and indeed, is how the originals are organized, it doesn't quite fit the "modern practices" principle for the language.

I'm a little conflicted as to which is the 'best' approach for this project. Would anyone object to having separate files for each class, etc.?

DiskJunky avatar Aug 08 '23 14:08 DiskJunky

The idea is that most of these were simple single file programs to start with, so breaking them apart, unless it's only 2 files instead of 1, seems to run counter to the original philosphy behind the books.

coding-horror avatar Aug 08 '23 17:08 coding-horror

I really disagree strongly with this point. The programs in the book were written the way they were due to the constraints of the time, not some overriding philosophy. And in many cases, they were written by amateurs and weren't even quality examples of BASIC programs.

There are so very many resources on the internet to learn the basics of programming. I just can't imagine someone coming here to learn how to write for loops and function calls. If we aren't teaching something useful--something people can actually take away and use in their own projects or at their jobs--then what's the point?

pgruderman avatar Aug 26 '23 12:08 pgruderman

You can, just keep it as minimal as possible. E.g. don't create a super complex Enterprise Edition implementation that's overengineered. Whatever feels appropriate to the size and scope of these tiny programs.. keep it simple, but certainly, keep it clean too!

coding-horror avatar Aug 26 '23 20:08 coding-horror

That was kind of what I was driving at. Standard practices of the language without decomposing the code to within an inch of its life. There's a sweet spot to be aimed for, say 3-4 classes/files, not 20-30.

As a side note, I tip my hat to @pgruderman who didn't split his infinitive in his opening sentence :)

DiskJunky avatar Aug 26 '23 21:08 DiskJunky