@bwoebi as part of fixing their problems they were supposed to remove the current CEO... so they retitled him COO, left the CEO seat empty, and moved over all responsibilities
excluding static methods which i hope you guys don't use, what uses you have for static:: self:: parent:: get_class($this) get_parent_class($this) and that kinda functions, in everyday's code?
i think i only have assert($arg instanceof static) somewhere, for something that should be solved with generics... Klass<T> where T is Klass<T>
meh, it's really not so bad, i tend to slip in and out of it as i go - write some code, write tests for it; write some tests, write code for it - and so on
regardless of the order of testing and writing code... i don't think it can give me confidence in my code, as it's basically black box testing but with not enough test cases provided
basically i can trick the tests to pass even if the implementation is wrong
not on purpose hopefully... :B
but, it could be a good way to perform basic verifications
basically a lot of the book is about testing behavior and it suggests that not all interaction should be validated, only the bits relevant to the test case
code is one, tests are about that very code and "all future refactorings"
i'm not sure that is a good idea... but it's no different from classic state verification
i mean, i would rather do that... than being acrobatic like this...
@WesStark i'm not entirely sure what you're trying to say, but i suggest rolling with whatever makes sense to you, whatever works for you (this applies to most everything). Don't get hung up on any dogma, others' or your own.
Hey, do any of you have suggestions on how i can implement User defined event triggers? ie, user can create a "trigger" for a database record change ? Are there any libraries for this?
The first hour of that helped me understand quite a bit...but I'm still missing something. Where does persistence take place? Do entities/aggregates and domain objects have methods to persist themselves, or should they be checked in to a repository?
@Allenph specifically, the repository interface is in the domain, the infrastructure layer contains the implementation that uses whatever voodoo you want to save domain entities
@Ocramius You would have to do that within an aggregate quite often wouldn't you? It seems like sometimes aggregates (being containers of bounded context) would have to save things in groups sometimes.
Repositories - Collection of value objects, entities or aggregates which can be queried with plain English. Value Object - Data Transfer Object. May contain validation logic. (Like an email.) Entity - Collection of value objects. (Can they have their own personal properties which are not value objects?) Aggregate - Contains bounded context. I can talk about actions which encompass many domain objects here. Used when I need a container for a transaction.
Repositories - Collection of entities Value Object - Data Transfer Object. Should contain validation logic. (Like an email.). Represents a "value" concept in the domain. Entity - Collection of value objects. (Can they have their own personal properties which are not value objects?). Must have an assigned identifier. Aggregate - Actual subject of an interaction. Is usually an entity. Can contain child entities and value objects. Its public API is the domain logic accessible to the outside world.
- When, if ever should I use services? Don't aggregates largely eliminate the need for these since I can use an aggregate to define an action involving multiple domain objects? - When do I need a factory? Why not use `new Thing()`? If I do need a factory...it seems like it would never encompass more than a single namespaced function. (I.E. function ` User/CreateUser()`)
@WesStark nah, they are just collections. It could be that they are DB-backed or just in-memory: doesn't matter
- When, if ever should I use services? Don't aggregates largely eliminate the need for these since I can use an aggregate to define an action involving multiple domain objects?
When you need to talk to the outside world
When do I need a factory? Why not use `new Thing()`? If I do need a factory...it seems like it would never encompass more than a single namespaced function. (I.E. function ` User/CreateUser()`)
new Thing() is very limited - using factory static methods is strongly encouraged
remember that __construct() is just a very special factory method
making them singleton makes a mess a' la laravel, where the responsibilities start to quickly become blurred due to how easy it is to mess up things when everything is accessible
but a UserRepository contains a factory that knows how to create a User without calling User::register(), and that factory changes over time as it is mostly technical layer
@Ocramius This doesn't make sense to me. If there are multiple ways of creating a user, you will simply be passing in different context and assuming the rest.
@WesStark also, you don't need to have a flexible factory concept there, as these 3 creation concepts are part of the discussion with the domain expert
@WesStark it doesn't - the data conversion is handled at application layer, but the concept of "importing a user" is part of the discussion with stakeholders (typical in SEM companies, for example)
@WesStark I see both sides. There's certain cases where it would make sense. If you don't have the context within a method you will end up imposing business rules for different contexts outside of the factory method.
If you only have one method for creating entities and certain methods of creating entities have different rules, you will have to enforce those rules somewhere.
You can do it with multiple factory methods, or by expressing those rules overtop of a single unified factory method.
I got ten days off in the middle, I'm looking forward to that, hopefully going to get away somewhere with them ...
but the rest of it will be total shit ... "I'm bored", "Can I have ___", "She done ____", "He done ____" ... omg, I've already got a headache thinking about it ...
6 weeks is way too long, you can entertain them for about 2 ...
then it doesn't matter what you suggest or how much time you take off work, they are irritated and bored ...