Vos commentaires

Хм, почему вы думаете, что это ошибка?

Yes, but be aware that this is a macOS-only piece of software.

Позволю себе процитировать абзац из книги:

Агрегация — это специализированная разновидность ассоциации, которая описывает отношения один-ко-многим, многие-ко-многим, часть-целое между несколькими объектами, тогда как ассоциация устанавливает связь только между двумя объектами.

Хочу отдельно сказать, что эти отношения в UML предназначены для того, чтобы в первую очередь описывать предназначение связи между объектами. По факту в коде у вас может быть одно и тоже как для ассоциации, так и для агрегации.

В этом случае разница действительно сильно размытая. Здесь я решил использовать агрегацию, чтобы подчеркнуть отношение часть-целое.

Здравствуйте!

> И там и там может быть отношение один к одному и один ко многим

Не уверен, почему у вас сложилось такое впечатление, но в книге указано, что:

Ассоциация — один к одному.

Агрегация — один к многим.

Здравствуйте, Александр!

Простите, у меня, вероятно, замылился глаз. В чём конкретно заключается ошибка?

Hi David!

To be honest with you, if I programmed such a thing myself, I wouldn't have a decent idea about whether or not a pattern can be applied there until later in the project: when I have a better understanding of how the actual GUI would look like, how this all be handled between requests, etc. I would probably implement the first version in a very straight-forward (e.g. fast and crappy) way to discover all hidden implications of the thing I'm building. Later, I would think about whether it makes sense to apply some of the patterns and refactor my existing code to that pattern.

你好!

抱歉,这本书没有有关此设计模式的信息。

Hi!

Thanks for your offer, I appreciate it! I'll let you know if/when we're ready to start with this project. For now, there's a lot of other stuff has to be done first.

Hi Tomasz!

To be 100% honest with you, the reaction of your team lead to your asserts in the production code will solely depend on his/her expertise and the project's code style conventions. Asserts in code are indeed not very common. I've seen assertions in non-unit-test code quite a few times in various projects over the years.

Usually, they are placed in such a way, that triggering them would mean that something that's very wrong happened to the project. Sure, you can replace them with exceptions, but that'll be just a waste of code for something that does the same thing. Personally, I'd use them if a simple assertion in code would spare me a very sophisticated unit-test that involves heavy mocking. Depending on the language you're working with, it's also possible to turn off assertions when building project for production.