Skip to content

improve: expand strings intro and rewrite inheritance concept docs#3115

Open
bull1210 wants to merge 1 commit intoexercism:mainfrom
bull1210:improve/concept-docs
Open

improve: expand strings intro and rewrite inheritance concept docs#3115
bull1210 wants to merge 1 commit intoexercism:mainfrom
bull1210:improve/concept-docs

Conversation

@bull1210
Copy link
Copy Markdown
Contributor

Quality improvements to two concept docs that had real problems.

strings/introduction.md

The existing file was 13 lines and only mentioned that strings exist and "have methods". Expanded it to cover the most commonly used String methods with examples, explain immutability properly, show why .equals() matters over ==, and introduce StringBuilder and String.format for building strings dynamically.

inheritance/introduction.md

Rewrote this one from scratch. The old version had a few issues:

  • Used bark() on a parent Animal class — semantically odd since lions don't bark
  • "It literally means in programming as it means in english" is awkward
  • Only linked to javatpoint.com instead of the Oracle docs
  • Didn't mention super or abstract classes at all

The rewrite uses a proper makeSound() method, introduces super with a real example, covers abstract classes, and links to the official Java tutorial.

inheritance/about.md

Fixed a syntax error in the interface example: interface Animal() — interfaces don't have () after the name. Changed to interface Animal and updated the method signature to makeSound() to match the introduction.

strings/introduction.md was only 13 lines with no examples of actual
String methods. Expanded it to cover common methods, immutability,
equals() vs ==, StringBuilder, and String.format.

inheritance/introduction.md had a semantically wrong example (Lion.bark),
awkward phrasing, a link to javatpoint instead of Oracle docs, and no
mention of super or abstract classes. Full rewrite with a clean example
and proper coverage.

inheritance/about.md had invalid Java syntax: 'interface Animal()' —
interfaces don't have parentheses. Fixed the interface declaration and
updated the method name to match the introduction.

Co-Authored-By: bull1210 <bull1210@gmail.com>
@Override
public void bark() {
System.out.println("Lion here!!");
public void makeSound() {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is it worth having an example of a child using something from the parent? The introduction opened by saying we can reuse fields and methods, but the first example looks like we're rewriting (by overriding) makeSound.

Consider a class, `Animal` as shown,
Inheritance lets one class build on top of another, reusing its fields and methods without rewriting them.
The class being extended is called the **parent** (or superclass); the class doing the extending is the **child** (or subclass).
The relationship is described as IS-A: a `Dog` IS-A `Animal`.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggest explicitly stating that Dog is extending Animal to make it really explicit and clear:

Suggested change
The relationship is described as IS-A: a `Dog` IS-A `Animal`.
The relationship is described as IS-A. For example, if `Dog` class extends an `Animal` class, the relationship can be described as a `Dog` IS-A `Animal`.

```

## Abstract classes

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think Abstract classes is a bit out of place in the inheritance introduction and would probably be better in class's about instead or a separate concept that comes after both inheritance and classes concepts (of the two, I favor as a separate concept).


## Building strings dynamically

When you need to construct a string piece by piece (e.g. inside a loop), use `StringBuilder` instead of concatenating with `+`.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Using + hasn't been introduced and there doesn't seem to be an example. I'd suggest adding one.

To read more about inheritance in Java, see the [official documentation][java-inheritance].

[java-inheritance]: https://www.javatpoint.com/inheritance-in-java#:~:text=On%20the%20basis%20of%20class,will%20learn%20about%20interfaces%20later.
[java-inheritance]: https://docs.oracle.com/javase/tutorial/java/IandI/subclasses.html
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'd suggest using Dev.java where possible. The top of Oracle page states that Dev.java has the latest stuff. The Dev.java page for inheritance is at For inheritance, the page is at https://dev.java/learn/inheritance/.

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.

2 participants