Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java family tree #20

Open
wants to merge 41 commits into
base: master
Choose a base branch
from
Open

Conversation

Sile9t
Copy link

@Sile9t Sile9t commented May 21, 2024

Added famiy-tree project


public class Human {
private long id;
private String _name;
Copy link
Owner

Choose a reason for hiding this comment

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

В джава не принято называть переменные с символа земли, но с точки зрения синтаксиса возможно

Copy link
Author

@Sile9t Sile9t May 28, 2024

Choose a reason for hiding this comment

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

На сколько я знаю, есть конвенция (по крайней мере в C#) на именование полей объектов через символ нижнего подчеркивания, как по мне оно упрощает взаимодействие с полями и их читаемость.

Comment on lines 77 to 80
public String FamilyTree(){
return FamilyTree(0);
}
public String FamilyTree(int tabsCount){
Copy link
Owner

Choose a reason for hiding this comment

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

Очень странно для класса Человек наличие методов связанных с деревом. То есть этот метод добавляет различные отступы, которые важны не для работы текущего класса. Следовательно данная работа должна быть описана в классе дерева. Также названия методов пишутся с маленькой буквы

@Sile9t
Copy link
Author

Sile9t commented May 28, 2024

Added serializer class

import java.util.ArrayList;

public class FamilyTree implements Serializable {
private ArrayList<Human> _tree;
Copy link
Owner

Choose a reason for hiding this comment

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

такой нейминг ничего не дает в джаве, но снижает читаемость

import java.io.ObjectOutputStream;

public class FamilyTreeSerializer {
public void Write(String path, FamilyTree obj){
Copy link
Owner

Choose a reason for hiding this comment

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

название методов с маленькой буквы

Copy link
Author

Choose a reason for hiding this comment

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

Хорошо, учту в следующем проекте.

@Sile9t
Copy link
Author

Sile9t commented May 31, 2024

Leave for review "Basic interfaces" execise

sb.append(human.toString() + "\n");
return sb.toString();
}
public void WriteTo(String path){
Copy link
Owner

Choose a reason for hiding this comment

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

Название методов с маленькой буквы

@Sile9t
Copy link
Author

Sile9t commented Jun 2, 2024

"Genericks" exercise

import human.Human;
import human.comparators.HumanNameComparator;

public class FamilyTree implements Serializable, Iterable<Human> {
Copy link
Owner

Choose a reason for hiding this comment

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

По заданию класс семейного дерева должен был использовать параметр (быть обобщенным), но это обычный класс. Вижу, что есть класс FamilyTreeItem, который использует параметр, но этот класс тоже никак не фигурирует в описании класса семейное дерево

Copy link
Author

Choose a reason for hiding this comment

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

Исправил

@Sile9t
Copy link
Author

Sile9t commented Jun 5, 2024

Pushed final changes

@Sile9t
Copy link
Author

Sile9t commented Jun 11, 2024

"From simple to practice"

@Sile9t
Copy link
Author

Sile9t commented Jun 12, 2024

"OOP Desing and SOLID" (part1 )

var human = humanBuilder.build(name);
tree.add(human);
}
public void addHuman(String name, Human mother, Human father){
Copy link
Owner

Choose a reason for hiding this comment

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

Надо передавать не Human родителей, а только их id и по id в данном методе найти уже Human в дереве

Copy link
Author

Choose a reason for hiding this comment

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

Подправил, но не полностью. В будущем буду пристальнее за этим следить.

import java.util.Scanner;

import model.human.Gender;
import model.human.Human;
Copy link
Owner

Choose a reason for hiding this comment

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

плохо, что есть такая связь

Copy link
Author

Choose a reason for hiding this comment

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

С этим тоже немного разобрался

service.addHuman(name, mother, father);
getFamilyTree();
}

Copy link
Owner

Choose a reason for hiding this comment

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

добавить методы сохранения и загрузки

Copy link
Author

Choose a reason for hiding this comment

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

Они реализованы в классе FamilyTreeSerializer, я подумал что такое дублирование будет лишним и удалил вызывающие методы

Copy link
Owner

Choose a reason for hiding this comment

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

Они то реализованы, но как то этот функционал не прикручен к основному проекту

Copy link
Author

Choose a reason for hiding this comment

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

Оно было в этом коммите 51000ce , но впоследствии я их удалил. Теперь буду знать, что не стоит так делать.

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