My first try using switch | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
11th Dec 2017, 9:31 PM
Benjamin Windisch
8 Answers
+ 5
👍👍👍👍
12th Dec 2017, 5:05 PM
Vyshnav Vishnu
Vyshnav Vishnu - avatar
+ 4
Nope. There are code conventions for how to format your code properly. This creates a standard between code and makes it a lot easier for others to deal with code from other people. As well, it'll make it a lot easier for you to deal with your own code later. http://www.oracle.com/technetwork/java/codeconventions-150003.pdf ^Here is a whole PDF on the common code convention for Java. I formatted the code that you posted above so you can see what I'm talking about. Trust me, you didn't do a bad job compared to what I see most people do, but I just wanted to give you that nugget of advice so it'll help you out later on. https://code.sololearn.com/cBdtn8uFB3Gz/#java ^Formatted your code to meet standards. Also, when you name variables, to the best of your ability name them something that's related to their purpose/function. This isn't something you did wrong, but something I thought of while typing this. A lot of people name their variables stuff like j9 or p2, rather than something like userInput or numAccounts. Get what I mean? The second set of variables clearly show what they're used for so you're not wasting time having to guess or find out.
11th Dec 2017, 9:47 PM
AgentSmith
+ 3
Good job. :) Works like a champ. Only tip that I have for you is to properly format/space/etc... your code. It's a good habit to form now, especially if you end up working with others or for a corporation later. Lot easier to form good habits in the beginning than trying to break habits and form new ones later.
11th Dec 2017, 9:33 PM
AgentSmith
+ 3
Thanks mate :) I tried to make it easy to read. You think i should put it all closer together?
11th Dec 2017, 9:36 PM
Benjamin Windisch
+ 3
Alright, I see. Ill go through the pdf - this certainly seems like a thing to get used to earlly on ;) . Appreciated
11th Dec 2017, 9:51 PM
Benjamin Windisch
+ 3
You're more than welcome, Benjamin. Trust me, learn it now. lol I'm actually telling you this out of experience. I was a solo programmer for a LONG time, so I formed all sorts of bad habits that didn't matter much because I was the only one looking at the code. However, after obtaining a corporate job, I ran into 2 issues. 1. I came back to some code I hadn't looked at for nearly a year. It was messy and things weren't properly named, so I had to spend a lot of time mapping things back out and trying to figure out what I was thinking in that moment. 2. Being on a team also meant that others would need to view and edit my code too. Believe me, it's embarrassing when you're looking at an entire team that's using proper conventions and their code is uniform with one another, and then you pull up yours and it's a complete mess. Even worse, your team now has to read your code, try to figure out what you were doing, and also figure out what the variables do which weren't properly named after its function. Best of luck to you bro! You'll get the hang of it and it'll come natural to you once you're use to formatting it a certain way.
11th Dec 2017, 9:57 PM
AgentSmith
+ 2
Java
16th Dec 2017, 5:33 PM
Kovalenko Kristina
Kovalenko Kristina - avatar
0
@ Netkos please can I ask a question
27th Dec 2017, 7:02 PM
Chukwuemeka Great
Chukwuemeka Great - avatar