No need to apologise to us; it is you who will suffer from inconsistent indentation.
Danielx Anderssonx wrote:. . . I'm sorry for my bad indentation in the code below. . . .
That is what PS told me off about here. What you start off with when furnishing a room is postits or similar for, “fridge goes here,” “microwave goes here,” “chair goes here,” “cooker goes here,” “table goes here,” etc. Then you put those items there, and later, as I said here, you remove them. OP has obviously reached the stage where they have completely served their purpose and he can remove the comments. Maybe we could do with some documentation comments, or shall we call that an advanced topic?
Junilu Lacar wrote:. . . A lot of the comments you have in your code are a lot like somebody taking a pad of Post-It notes and putting labels like "My Shoes" . . .
Junilu Lacar wrote:T...I would still argue that even a beginner should be able to see that they are writing a method like getCircumference without the little reminder that it is "A method that returns the circumference 'getCircumference()'." I don't know, maybe I'm expecting too much from people.
When I wrote redundant comments before, it was because that was what we were taught. One of my first programming languages was Pascal (I learned BASIC at the same time). This is how we were told to comment our code:
Comments like these were reasonable and some redundancy was necessary when control structures contained many lines of code and it was difficult to easily discern the structure of the design/program. That was then though. Nowadays, we can write descriptive names with practically no limit to the length of the names we give other than what common sense tells us...
@OP, do you think you really need comments like this?
What additional information are you getting from the comment that the code doesn't already give you? Also, what do you think happens when you decide to change the method name somehow? You'd have to change two things right? The code and the comment. Ideally, the code will speak for itself because you choose good names that express the intent clearly enough. That would make this kind of comment redundant, in which case you can delete it.
Piet Souris wrote:Yes, looks very nice! And of course, we are all different, so a personal style is inevitable and welcome too. Keeps this site as interesting as it always is.