Skip to content

Conversation

AlejandraPedroza
Copy link
Contributor

@AlejandraPedroza AlejandraPedroza commented Apr 2, 2025

This PR revamps the content and code examples in the Classes page following external feedback.
Some of the key changes are:

  • Improve the whole page and revamp the code snippets.

  • Explain the use case for multiple init blocks.

  • Explain constructor chaining.

  • Add examples for primary constructors.

  • Clarify the open keyword.

  • Explain how to access a class property from a class member function.

  • Use the term "object" consistently.

  • Clarify what abstract classes are.

  • Provide example companion objects.

@AlejandraPedroza AlejandraPedroza requested a review from a team as a code owner April 2, 2025 14:13
Copy link

@ice-phoenix ice-phoenix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My main question is: what are the things we want the reader to know, after they've finished reading the updated "Classes" page? Is it basic syntax for classes, details about constructors, details about initialization, smth else? Right now the section is a bit all over the place, I feel.

In other words, when we set to improve the page, what did we want to achieve?

Copy link

@ice-phoenix ice-phoenix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the updates! In general, I like the new version.

I narrowed down my main concern to the struggle between "being succinct and to the point targeting existing developers" in the old version vs "being very detailed and explaining very basic things targeting novice developers" in the new one. I don't know how to find a good balance here besides taking a look at the actual feedback of users and what they are missing.

Additionally, I think it's important to remember that, while all and every feedback is important, a lot of people who were completely satisfied with the current succinct and to-the-point version didn't leave their positive feedback. We might "over-optimize" for the smaller part of our target audience which is more vocal and more novice, and they want very basic things explained in detail.

Note: feel free to disregard my general feedback and only incorporate the technical notes, as you are the person who definitely knows more about how to write good technical documentation. If you believe it should be done in a specific way, then that's what we should do.

Copy link
Contributor

This PR is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@github-actions github-actions bot added the Stale label May 31, 2025
@koshachy koshachy removed the Stale label May 31, 2025
Copy link
Contributor

github-actions bot commented Jul 1, 2025

This PR is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@github-actions github-actions bot added the Stale label Jul 1, 2025
@AlejandraPedroza AlejandraPedroza marked this pull request as draft July 1, 2025 08:35
@AlejandraPedroza
Copy link
Contributor Author

@ice-phoenix

Thanks for your detailed review!
The aim is to make the content more accessible and useful for both groups. Better examples and explanations will help beginners progress to the intermediate level and help experienced developers solve typical problems.
Also, when improving pages, we prioritize practical, widely useful information. We take user feedback into account, but assess very specific cases with low impact. Based on this approach, we work with SMEs to balance what and how we document: tech writers as content experts, SMEs as technical experts.
I appreciate your technical suggestions. I applied them overall.
From the content side, I reviewed why the page felt over-documented, and produced a clearer, more concise version.

@AlejandraPedroza AlejandraPedroza marked this pull request as ready for review August 19, 2025 14:55
Copy link

@ice-phoenix ice-phoenix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the update, it looks much more focused and to the point, compared to the previous version! I've left some comments, but overall I don't have a lot to add.

In all the places where we are technically not entirely correct, we are ambiguous enough and pragmatic enough; to fix these places, we would need to introduce too many additional things and details, which is not really appropriate for this page, I feel.

Copy link

@ice-phoenix ice-phoenix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

@sarahhaggarty sarahhaggarty self-assigned this Aug 20, 2025
Copy link
Collaborator

@sarahhaggarty sarahhaggarty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huge effort Ale! 🚀 It's definitely looking much better than the original. Thanks for the hard work!
Please take a look at my suggestions.
There's some for improving names in code samples as well as adding code comments for printed statements within the main() function of samples.
I made a couple minor structural suggestions and asked a couple of questions for clarification.

When you [create an instance of a class](#creating-instances-of-classes), you are creating
a concrete object based on that blueprint.

Kotlin offers a concise syntax for declaring classes. To declare a class, use the `class` keyword
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Kotlin offers a concise syntax for declaring classes. To declare a class, use the `class` keyword
Kotlin offers concise syntax for declaring classes. To declare a class, use the `class` keyword

* [Nested and inner classes](nested-classes.md)
* [Object declarations](object-declarations.md)

Both the class header and class body can be minimal.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean by "minimal" here?

* [Object declarations](object-declarations.md)

Both the class header and class body can be minimal.
If the class does not have a body, you can omit the curly braces `{}`:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
If the class does not have a body, you can omit the curly braces `{}`:
If the class doesn't have a body, you can omit the curly braces `{}`:

is declared in the class header, and it goes after the class name and optional type parameters.
```kotlin
// Person class with a primary constructor
// that nitializes the name property
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// that nitializes the name property
// that initializes the name property

```

## Constructors
Here's an example of a class with a header, body, and an [instance created](#creating-instances-of-classes) from it:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Here's an example of a class with a header, body, and an [instance created](#creating-instances-of-classes) from it:
Here's an example that declares a class with a header and body, then [creates an instance](#creating-instances-of-classes) from it:

This doesn't sound natural to me. I've suggested an alternative. I think it's because the "class with a header and body" is the important part. It separates it from the instance creation which is a different level of abstraction.

}
```
{kotlin-runnable="true"}

If a non-abstract class does not declare any constructors (primary or secondary), it will have a generated primary constructor
with no arguments. The visibility of the constructor will be public.
If there's a class that does not declare any constructors (primary or secondary), it will have an implicit primary constructor
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be good to put the rest of this content under a separate header. It doesn't really fit under "Secondary constructors". Maybe "Without constructors"?


fun main() {
// Creates an instance of the Person class
Person("John", 30)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Person("John", 30)
Person("John", 30)
// Person created: John, age 30.

// and converts it to an integer
constructor(name: String, age: String) : this(name, age.toIntOrNull() ?: 0) {
println("$name created with converted age: $age")
// Bob created with converted age: 8
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Bob created with converted age: 8


fun main() {
// Uses the secondary constructor with a String age
Person("Bob", "8")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Person("Bob", "8")
Person("Bob", "8")
// Bob created with converted age: 8

I think it makes more sense to add the printed statement here for the constructor.

// to the primary constructor
constructor(name: String) : this(name, 0) {
println("Person created with default age: $age and name: $name.")
// Person created with default age: 0 and name: Alice.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you move the code comments to where they will appear when triggered by the main function?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants