-
Notifications
You must be signed in to change notification settings - Fork 69
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
base: master
Are you sure you want to change the base?
Java family tree #20
Conversation
src/ru/gb/family_tree/Human.java
Outdated
|
||
public class Human { | ||
private long id; | ||
private String _name; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
В джава не принято называть переменные с символа земли, но с точки зрения синтаксиса возможно
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
На сколько я знаю, есть конвенция (по крайней мере в C#) на именование полей объектов через символ нижнего подчеркивания, как по мне оно упрощает взаимодействие с полями и их читаемость.
src/ru/gb/family_tree/Human.java
Outdated
public String FamilyTree(){ | ||
return FamilyTree(0); | ||
} | ||
public String FamilyTree(int tabsCount){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Очень странно для класса Человек наличие методов связанных с деревом. То есть этот метод добавляет различные отступы, которые важны не для работы текущего класса. Следовательно данная работа должна быть описана в классе дерева. Также названия методов пишутся с маленькой буквы
Added serializer class |
import java.util.ArrayList; | ||
|
||
public class FamilyTree implements Serializable { | ||
private ArrayList<Human> _tree; |
There was a problem hiding this comment.
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){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
название методов с маленькой буквы
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Хорошо, учту в следующем проекте.
Leave for review "Basic interfaces" execise |
sb.append(human.toString() + "\n"); | ||
return sb.toString(); | ||
} | ||
public void WriteTo(String path){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Название методов с маленькой буквы
"Genericks" exercise |
import human.Human; | ||
import human.comparators.HumanNameComparator; | ||
|
||
public class FamilyTree implements Serializable, Iterable<Human> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
По заданию класс семейного дерева должен был использовать параметр (быть обобщенным), но это обычный класс. Вижу, что есть класс FamilyTreeItem, который использует параметр, но этот класс тоже никак не фигурирует в описании класса семейное дерево
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Исправил
Pushed final changes |
"From simple to practice" |
"OOP Desing and SOLID" (part1 ) |
var human = humanBuilder.build(name); | ||
tree.add(human); | ||
} | ||
public void addHuman(String name, Human mother, Human father){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Надо передавать не Human родителей, а только их id и по id в данном методе найти уже Human в дереве
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
плохо, что есть такая связь
There was a problem hiding this comment.
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(); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
добавить методы сохранения и загрузки
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Они реализованы в классе FamilyTreeSerializer, я подумал что такое дублирование будет лишним и удалил вызывающие методы
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Они то реализованы, но как то этот функционал не прикручен к основному проекту
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Оно было в этом коммите 51000ce , но впоследствии я их удалил. Теперь буду знать, что не стоит так делать.
Added famiy-tree project