r/AskComputerScience • u/slybash • May 16 '19
How do I learn how to make "larger" programs?
As in, how do I learn how to structure projects that are not throwaway, small programs, but full-fledged software with GUI, multiple features, scalability, etc... in ways that are efficient and congruent with other people in the field? I'm a hobbyist, not in school (yet)
8
u/ZoomStop_ May 16 '19
If you are looking for experience in GUIs and such consider writing a frontend for a command line program. There are plenty of Windows command line programs that lack a GUI, and many that do have a 3rd party GUI that is poor or outdated.
12
u/asdff01 May 16 '19
The book that allowed me to do this is the legendary "Gang of Four" Design Patterns book. Code examples are in C++ and it was written a while ago, but is still recommended as a fantastic resource for learning how to design software well.
There is also the SOLID principles, for object oriented design.
1
u/pleasantstusk May 16 '19
This, with enterprise applications the difference between good and bad is about the structure! Good structure will contribute to good, clean and to some extent self documenting software
5
u/deong May 16 '19
I agree with you, but mostly disagree that the GoF promotes good structures. My recollection of the book was that I didn't find it especially objectionable, but the people most influenced by it write what I find to be abstracted to the point of nonsense.
My personal "prime directive" for good code is that someone who knows the domain should be able to read it and understand what it's talking about. If you develop an application for a cable company, you should have objects and functions named things like "Customer", "Truck", "Technician", "Channel", "ScheduleAppointment", "ActivateService", etc.
At times, you're going to need to do things programmers do. That may involve inventing new objects that abstract common functionality or parse files or whatever "programmer-y stuff" you need to do to build real applications. That's fine, but it's something you should do as a conscious understanding. There's a trade-off very often -- I can reduce some duplicate code at the cost of having a weird more abstract object. Pattern people tend to write code where every object in the system is an AbstractFactoryFactoryBuilderFactory. That's, in my opinion, a sin worse than whatever problem you're trying to solve with patterns in the first place.
1
u/pleasantstusk May 16 '19
Oh don’t get me wrong there’s a lot more to good maintainable code than structure but you can’t have it WITHOUT structure. Of course there’s a time and place for the design patterns and they aren’t a “one-size fits all” thing by any stretch of the imagination
The stuff you mention is the type of thing in the “Clean Code” book which is equally as important.
1
u/ideletedmyredditacco May 16 '19
structure
Is that a technical term? Sounds kind of vague. Aren't you just saying you can't have organized code without organization?
4
u/morphilng May 16 '19
You could start by tinkering with the tools used to create such applications. Most high-level programming languages, unless they're highly specialized, have tools and APIs that allow you to build a GUI for users to interact with your program.
The most convenient tools for something like this come in your IDE, generally. Coding a GUI from scratch sucks, but IDEs like Visual Studio feature GUI editors where you can "drag and drop" buttons and other elements, and allows you to edit the code behind those elements in a pretty straightforward way. You can get a pretty feature-rich IDE for free for most languages (Visual Studio Community is free for you to try if you want that), and these free versions are usually good for anything short of enterprise-level development.
3
u/WiggWamm May 16 '19
Learn about classes and object oriented code. It’ll help when you ant to make large projects cause it brings more organization
2
u/Sanders0492 May 16 '19
Pick something you have a passion to work on and just start trying. If you’re anything like me, you’ll get pulled to different projects because your attention span will run out. That is fine when learning, as long as you’re actually learning with each iteration, but I will say the real world was a rude awakening because I can’t just work on something else when I get bored lol
1
u/but_how_do_i_go_fast May 16 '19
What works for me is understanding my code and DYI practices.
Essentially, you will want to be able to have everything pristine and organized. Keep your dependencies as low as possible. Try to keep good programming paradigms. Have a top level config file. Make your own vanilla libs. Have SQL db's vs. json files vs. reading from text files vs. webscraping when necessary. Try to localize all of your code so that you can run and continue building it even when offline.
And remember that even the "smallest" programs have years and years of dev work and a lot of hidden code. Take `grep`, `find`, `brew`, for example. These are all very complex programs at their core.
1
1
u/worldDev May 17 '19 edited May 17 '19
Most important concepts are separation of concerns, modularity, organization of those chunks, and documentation. If you have some libraries you use regularly, dig into their source code. Wrap your head around the idea that your code can be similarly packaged, and interacted with if separated properly where another piece’s interaction of it ideally has no concern over it’s improvement, fixes, and optimizations. It really is easier said than done. It takes practice and experience to understand contextually how to break things apart how they will end up from the start which changes from domain to project, but you will get better at predicting end goal interfaces that don’t require future changes.
1
u/cheeseisakindof May 17 '19
I would focus on trying to modularize your code into libraries and separate files so that you can keep large projects in order and reuse your code easier when you’re able to.
Also make sure to give yourself documentation and comments for when you come back to it. After coming back to large portions of your code it will become important to know explicitly what is going on, especially as the size of the project grows.
1
May 17 '19
That's a very open ended question.
Larger could mean anything. depending on what language you want to do it in, how do you pick that. What kind of application do you need?
When learning to write applications and programs your objective should be to create something with a goal in mind. Personally I find I go in circles otherwise
A good exercise is to make a to-do list application in your chosen language and decide what features you want at the beginning.
Create a gui and figure out how to connect that to any kind of model(storage) add features as necessary or as you go along.
1
u/lehrnerdaniel May 17 '19
Another approach, to the ones already mentioned, is to find somebody with experience with more complex programs and learning from them. This way I could always learn more quickly and avoid common pitfalls.
As you mention, that you are a hobbyist, you could join an open-source project. People there are normally welcoming to others helping out and you could learn how the have approached their problems.
1
u/khedoros May 16 '19
By trying, making a bunch of mistakes, and learning how to fix them. Over and over again. While doing that, start looking at the code for the kinds of programs you're interested in writing. You'll start to see some of the solutions that you've figured out echoed in that code, sometimes in a more-refined way than you came up with. And some of the "why the heck did they do that?" things might start to make sense (although some might not; software's full of mistakes and technical debt).
I'll also say that the Gang of Four book is a great source of time-tested patterns.
For me, the hard part of design is that sometimes it's hard to see the benefit of a particular design until you run into a problem that it's well-suited to solve. So you kind of have to go back and forth between encountering problems, and reading about solution patterns, to hit the epiphany of intuition that lets you really understand the solution. At least, that's how I feel about it.
38
u/brtt3000 May 16 '19
Start making larger programs with what you know now and see what you find out along the way.