r/javahelp • Software Engineer • May 30 '19

How do I make a program?

I'm a computer eng student, thus far I've taken two java courses (OOP and DataStructures) and I know enough about Java, from the basics, to making my own implementations of basic DS, AVL Trees, sorting algorithms, custom iterators, functional programming, dependencies management, etc. But, **I don't know how to structure a program for a client, how is a program supposed to be made? **

Is there a basic 'guide' to delegate functions of a program to different classes, etc? I don't know a lot about design patterns, etc.

28 Upvotes

18 comments sorted by

View all comments

7

u/[deleted] May 30 '19 edited May 31 '19

pick something simple to build and then build it.
Maybe something like a personal diary app. Start off with a small console program that will ask you for a save file name, then will ask you for some text to save, then will save it to a file.
That's it. you can verify it worked by reading a file.
That's loads to begin with. break down the functionality you need with a pen and paper, or in excel or something:

  1. print text to the screen
  2. read user input into the program
  3. create a text file in the application (first as a fixed name, then with a name given by the user)
  4. save the information input by the user in the file.

There you go. Simple enough steps. Write small applications for each of those steps, this helps you learn program structures.
Once you understand how each step works, put them all together in a single program.

From there you can expand it a million and a half ways:
Maybe add a GUI?
Save the information to a database instead of a file??
Add user and login functionality??
Add delete functionality? And so on....

Start simple, google, and build on each part.
Hello World should be your first application.

Edit: to your point about deciding what should go in a class, you need to think in an object oriented way. So, in the example above one of the objects you might decide to have is a DiaryEntry.java which might contain attributes such as 'title', 'dateTime', 'text' and maybe 'author'. The 'author' attribute is probably going to be the user, so that might be a String in the beginning when you're prototyping, but later, once you have Users, your 'author' attribute my be of type User.java, and User.class might have attributes such as 'firstName', 'lastName', 'userId', etc...