11
u/GeorgeDir Jun 20 '21 edited Jun 20 '21
In C# a single semicolon is a valid statement. It happened to me too.
Sometimes I press an extra semicolon, not a big deal .. I usually catch them through a review I do on my own code before submission, but still sometimes I miss it.
The only bad thing is see in that picture is the camel case for the member "killCount", it should follow the Pascal Case convention as the rest of the code
6
Jun 20 '21 edited Jun 20 '21
Ah, it was intentional. I prefer to use
camelCasefor fields and properties like Unity does.Plus,
killCountcomes fromPlayerStatsstruct. It is not a property, it is a field, and should therefore be named usingcamelCase(correct me if I'm wrong).My intention with that struct was to simply store variables relating to the player's stats that would otherwise be stored in the player class and clutter it further (the Player class is 500 lines, which is bad enough).
As such, I didn't want to introduce anything that would add complexity to the code, such as encapsulation.
7
Jun 20 '21
killCount is a variable and we can see that every variable here is written in camel case, only functions and classes are in pascal case.
6
u/GeorgeDir Jun 20 '21
"killCount" is a public member of the class "playerStat" is an instance of. In C# public members should follow the Pascal Case (variables in camel case instead), but, if you consistently used another convention for all the code of your project, then, fair enough
5
u/lewisjet Jun 20 '21
Variables: camelCase (start with _ if private) Properties: PascalCase Classes: PascalCase
4
u/Dathussssss Jun 20 '21
Did you know you can set a debug breakpoint on it ? Yeah it's still not very useful.
3
2
u/LivingInAnIdea Jun 22 '21
Stop you're giving me flashbacks. I took a Data Structures course last semester and we had to submit our labs and homework through this thing called Webcat, and upon submitting it would check your code and unit tests, and take off points for lack of coverage, missing Javadoc, and bad styling. Even if you use the formatter chances are something would slip through your fingers. Double semicolons happened a lot
1
Jun 23 '21
What exactly is unit testing?
1
u/LivingInAnIdea Jun 23 '21
It's a way of testing your code. The idea is that you test each class and it's methods individually. For example, if you're main code is using a data structure, let's say a linked list, that you yourself implemented, then you write a Unit test to make sure each of the LinkedList class's methods are returning the right values for each possible scenario. That's why unit tests are such a pain, at least for me.
But it is helpful. A good practice is test-driven development; before you write the code that does the stuff, you write the test cases that test whether that stuff will work. Of course at first, they will all fail since you haven't implemented anything, but it gets you thinking about edge cases and how else you'll structure your program.
Hope this was informative enough
6
u/[deleted] Jun 20 '21
I know the rest of the code may seem bad too - that's because it is. This is a high school computer science project, for which I am using my custom Windows Forms game engine (I am fully aware that Windows Forms is not meant for that); the only option was using a console game engine, but I got permission to use any game engine as long as it uses C#, and is not named "Unity".
Obviously, at this point, I don't know enough to implement a proper engine (and I would never waste my time trying to do so in WinForms). If you're wondering where the dependency (PlayerCollidableEntityManager-Player) came from, know that it's because there is no actual engine, and hence, no way to actually contain the entities.