0

Steps to build any basic Java Program??

how to build any basic Java Program, how to solve its problems and bugs

7th Mar 2017, 5:57 PM
Fake Mask
2 ответов
+ 1
Hi, as any program, the first thing is to subdivide your problem into smaller problems. For example, if you want to create a problem for a library that keeps the status of all the available books and their position, you will need an object book, shelf and...shelves (a group of shelves). You can create all this classes without thinking about how the others are going to be, making the coding easier. Another important tip is coding is the last and less important part about solving the problem. Before sitting to write, you should make schemes about the general behaviour of the program, methods you need, relationship between elements... If you come from C, you might want to think an algorithm to solve the problem, but in OOP you have to think about the objects involved and their relationships.
8th Mar 2017, 6:29 AM
Qwerty
+ 1
About the bugs, well, Java is more restrictive than C or C++, minimising the bugs. If your program is not doing what it should, it's probably a condition not set correctly or something like that. Use rubber duck debugging. Take a rubber duck and explain to him the code, line by line. The error should be clear once you say it out loud. You have to treat him as a real person for it to work. You could also use other similar objects, but it's been proven that rubber ducks are better at Java than stuffed animals (just kidding). This method is real though, and very useful, google it if you don't believe me. Rubber duck debugging.
8th Mar 2017, 6:34 AM
Qwerty