Will somebody please critic my readability? | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
+ 13

Will somebody please critic my readability?

/* Java string reference. This will be The first CS1400 Assignment */ public class mishWun { public static void main (String[] args) { String firstName, lastName, favMovie, birthMonth; firstName = "Dillon"; lastName = "Lair"; favMovie = "Waking Life"; birthMonth = "July"; System.out.println("Hello class! My name is " + firstName + " " + lastName + "."); System.out.println("My favorite movie is " + favMovie); int birthDay = 7; System.out.println("My birthday is " + birthMonth + " " + (birthDay)); //Outputs first name, last name, birth month & date. } } I am currently taking my first CS course and I just want to know if I am on the right track in regards to making my code readable for my instructor. The readability of the code determines a percentage of the grade and I have taken out a snippet from my assignment for critique. Thank you all so much for your input.

1st Sep 2017, 8:06 AM
Apocryphon
Apocryphon - avatar
19 Réponses
+ 20
Beautifully indented. I might prefer standardising the curly braces: class something { } or class something { } but that is minor. Adding to the list, as has been pointed out by @Empty, try to group all variable declarations at the top of your program if possible.
1st Sep 2017, 9:03 AM
Hatsy Rei
Hatsy Rei - avatar
+ 10
yes , thats fine ... good beginning 👍
1st Sep 2017, 8:14 AM
Changed
Changed - avatar
+ 8
You are all life savers!! I will definitely be sure to take care of these details. I will also mention that I received friendly advice through the SoloLearn community! Thank you all again!
1st Sep 2017, 9:36 AM
Apocryphon
Apocryphon - avatar
+ 7
Now you may also work on making the output more readable, as sometimes, a line just after a line (single newline) hinders clarity and readability... But yes, your code is properly indented and that makes it easy to understand...
1st Sep 2017, 9:09 AM
Kinshuk Vasisht
Kinshuk Vasisht - avatar
+ 5
@Apocryphon, character limits depends on the device used and editor (IDE), some editors have side panels for file management, toolbox, etc. If you write the code on a laptop it's perfectly understandable that we see line wraps when viewed on smaller devices, but in general, personally I wouldn't go beyond 80 chars per line, but well, that's just me.
1st Sep 2017, 6:06 PM
Ipang
+ 4
Use IDE like eclipse it takes care of readability in terms of aesthetics. And also go through codes of experienced coders to get used to some of their habbits. Look for habbits you also like do not write code so others can read it well, you should like it also.
1st Sep 2017, 11:26 AM
AutomatedpROCESSES
AutomatedpROCESSES - avatar
+ 4
https://code.sololearn.com/csnh7j2lT4mQ/?ref=app Now that you feel satisfied, please critic my code...
6th Sep 2017, 3:09 PM
Kinshuk Vasisht
Kinshuk Vasisht - avatar
+ 3
Your code readability is fine, except for the assignment lines for firstName .. birthMonth which seemed to have a different indentation level, but I guess it's non-intentional. I would also remind you that Java uses a JIT compiler, which supports variable scoping further, I mean, declare your variables at the scope where they will be used, it makes your code be more efficient with resources. Best of luck mate..
1st Sep 2017, 11:31 AM
Ipang
+ 3
i have seen serverals empty lines in your code, its always better, or at least looks better when you standardize you code, and do remember whenever the dump ass show a demo in class, u should notice how all those demos, examples are formatted, and try to use what teachers like not what you preferred
3rd Sep 2017, 11:31 PM
EnRico Lam
EnRico Lam - avatar
+ 3
plz seperate comments of different code lines, and use the variable name with exact wordings, my comments usually indicates what i expect to output, but you may or may not do the same
3rd Sep 2017, 11:38 PM
EnRico Lam
EnRico Lam - avatar
+ 2
critique*
2nd Sep 2017, 11:45 AM
UPrejean
UPrejean - avatar
+ 1
Thank you for that. We are dealing with jGRASP for the course. But I will most certainly remember to limit to 80.
1st Sep 2017, 7:32 PM
Apocryphon
Apocryphon - avatar
+ 1
Well, in C# the custom is classes starting uppercase, unlike in Java. other than that, if you use a "code shortener" of these so popular lately, they will split multiple variable declaration in different lines, for you commenting each separately. I personally prefer it this way, after all, the variables are self explanatory. Oh, on C# you don't usually use the class String for defining strings, it's a native type, string. I know you wrote it in java, I'm just advancing some tips.
1st Sep 2017, 7:54 PM
myenemy
+ 1
1. You can use 'String.format' instead of concatenation, it has a little clear syntax. String.format("My birthday is %s %d", birthMonth, birthDay) 2. The birth* prefix is not required, month and date will do just fine in this case.
2nd Sep 2017, 1:58 AM
Salekin
Salekin - avatar
+ 1
I like everything about the code. Just for future reference, I would advice declaring every variable first before intialization and output. That way everything will be organized nice, neat and easy to read. Congrats
3rd Sep 2017, 3:02 PM
David M Gegbai
David M Gegbai - avatar
+ 1
yes you have maintained readability of your code . appriciate it.good going.
3rd Sep 2017, 8:56 PM
Piyush Manglani
Piyush Manglani - avatar
+ 1
and the last comment you better //[firstName] [lastName] //My birthday is [birthMonth] [birthDay]
3rd Sep 2017, 11:35 PM
EnRico Lam
EnRico Lam - avatar
0
the code indentation is Okay...
1st Sep 2017, 12:15 PM
Nobert Psandui
Nobert Psandui - avatar
0
Yeah, I just opened my mobile device and noticed that some of the indentation is off on the screen. I wrote the code on a laptop so I assume that's why. What would be a good number limit for the characters per line for future reference?
1st Sep 2017, 3:54 PM
Apocryphon
Apocryphon - avatar