« first day (2470 days earlier)      last day (2704 days later) » 

00:02
@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
00:45
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>
01:27
or, well, it will be when it's finished indexing
/cc @JoeWatkins ^
02:02
tdd is for crazies though
i'm trying to be open about it but nope
02:31
@WesStark how so?
it's like programming by reverse engineering :B
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
it's a natural flow
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...
thoughts?
02:54
wow first time I notice the chat! ... :-)
it's well hidden, they don't want to be blamed for causing procrastination
I was wondering if the chat only appears when you accumulate a certain number of points ... Or I was probably just blind ...
In anycase, glad i noticed it :-) This will be handy. The IRC chat at PHPFreaks is gething lame lol
@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.
sure, just trying to improve my knowledge
i'm not even against it actually... it's neither worse nor better than alternatives
they all have advantages and disadvantages
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?
 
1 hour later…
04:09
has anyone used the webdav extension at github.com/jedisct1/PHP-WebDAV-extension ?
@Stephen just use sabre.io instead
it's I/O - an extension can unlikely help you in peformance
huh. sabre/dav is a webdav server. I want a webdav client
oh, I see
7 hours ago, by Wes Stark
> @Ocramius unfollowed you
explain yourself :B
@WesStark too much F1 bullcrap
04:16
i knew it
i should get another account only for that
F1 is just for getting asleep on Sundays
sorry. but the problem is that now twitter also shows replies
i rarely start threads about F1
no, no, it's just the actual posts :P
twitter is not a friends-list, don't misunderstand. It's just human-controlled pub-sub
;-)
you are not the first that complains about that
i'll get another account
I'm not complaining :P
well, besides F1 being only good for falling asleep
04:19
i'm done with f1 anyway
they will have flip flops next year @Ocramius
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 the repository implements persistence
no. actually i've asked @Ocramius that
04:21
@Ocramius So, I should be checking things in the same place I'm taking things out?
@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
I thought so. But I wanted to make sure. It seems like a violation of SOC to put SQL in both the repository and the DTOs.
@Allenph rephrase plz
jimbo was wondering how to implement a "duplicated email address" kind of error
he said to inject repositories into domain objects
but i think that should be done within services
@WesStark I gave @Jimbo some very clear examples of that
04:22
as aggregates should be completely standalone and self consistent
While I thought I might have finally got a grip...now you guys have confused me.
@Allenph $repo->save($thing)
the $thing doesn't know about the outside world, and never ever about the DB or I/O in general
@Ocramius Or, $repo->saveThings($collection)
?
@Ocramius Now THAT made it click.
@Allenph depends, but I usually never need to save multiple
In DDD, acting on multiple aggregates at the same time is quite rare
@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.
Oh, I see.
04:25
@Ocramius what's with the bolding in that example scenario?
@Allenph No, you pass the aggregate to the repository
An aggregate should have it's own repository. Not just utilize it's components repositories.
correct
@PaulCrovella the highlighter doesn't understand gherkin
That would NOT however be the case with an entity, though...correct?
An entity does not have bounded context.
entities are part of aggregates?
04:26
@Allenph usually, an aggregate IS an entity
whether it has sub-entities is a different thing :D
That video made it seem like the only difference between entities and aggregates is that entities have bounded context.
No, aggregates have - an aggregate is the subject in a series of operations
Expound?
entities are just objects with an assigned identifier - it's more of a technical detail
Could you provide an example?
04:28
User::register() : User, User#ban() : void, User#logIn($credentials) : void
These are interactions on a User "subject"
or object complement, whatever, can't remember how it's called in Engrish
but basically, it's the "thing" at the center of a certain interaction with your system domain
subject and object?
"direct object"
@WesStark Are you the Wes that used to have the panda avatar?
yes
yes @Allenph
Oh, so you already have experience with my idiocy.
04:30
@Allenph also, in this case, since a User has an identifier, it also is an entity
most aggregates are also entities
most aggregates are also state machines
sometimes aggregates contain more sub-entities that are implementation details not to be exposed to the outside world
aggregates are just a group of objects that make sense to keep in a single unit. an aggregate can be as small as a single class
they are the "units" that are the subject of your transactions
I prefer to say that they are the 'wall" between domain logic and application logic
anyway, that said, back to learning haskell
gl. why are you doing that to yourself? :D
in a strange way I think he's doing it to us
04:34
@WesStark because it's awesome
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.
Is that correct?
repositories are about persistence. they wrap around data mappers
wait
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.
(see full text)
Questions I still have...

- 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
04:40
I guess one thing a factory would be good for is denying me an object if the parameters I supplied to construct that object were invalid.
@Allenph the constructor can do that too, but the constructor can only be one
as soon as you add parameters to the signature, you start having a BC mess
Also, User::register() is much more explicit than new User()
And much closer to the ubiquitous language
@Ocramius

"When you need to talk to the outside world" seems vague to me. I thought aggregate methods might be used in such a case?
@Ocramius I don't understand this.
04:42
@Allenph if you have 2 ways to create a User, but you already have a public User constructor, you start having a problem
@Ocramius they are not collections as in data structures. i wouldn't call them that
repository is the name
@WesStark they are a Map<Id, Entity> of unique elements
Generally called Collection
also a class is a map of functions and variables :P but we call it class
Yes, that's the data structure ;-)
It's a data-structure, not a DDD-structure :P
yes, i'm saying that you can simplify everything to "key value pair"
04:44
I'll simplify YOU to a k/v pair!
GO AHEAD
(MAKE MY DAY)
he'll just change keys again
SIGSEV in concat_function – #74960
@Ocramius So a service is used in this case to define rules. Instead of putting those rules inside the action, we ask a service if our action is okay?
@Allenph the repository's goal is preventing you to fetch the same entity multiple times from the database. just that
while the data mapper contains the queries
04:47
@Allenph the example I make in that blogpost is not just a "query", it's actually performing a payment against an external payment gateway
"outside world"
good morning
But anyway, the more you use aggregates, the less services you will need
Mostly because the decision logic is in the aggregate itself
Woah, woah, woah.
There's a layer below the repository?
A data mapper?
Yes, but that has nothing to do with DDD
that would be whatever ORM/DBAL/contraption you want to use
it never leaks in the domain
So...is that an object itself?
04:50
Could be, or you can hardcode everything in the repository implementation - doesn't really matter that much
the data mapper has almost always the same api of the repository
Repositories are singletons?
@Allenph no
forget about singletons
04:51
@Allenph singletons are... basically NEVER to be used :P
Except for extremely technical stuff such as an EventLoop
the repository just wraps around the data mapper and prevents you to fetch the same thing twice
Then...what's to prevent me creating multiple repositories and ending up querying multiple times anyways?
@Allenph nothing
you can use optimistic or pessimistic locking at DB level to prevent shooting yourself in the foot though
this prevents aggregate concurrency issues
04:53
Do repositories have factories?
no
data mappers use factories in order to provide you the objects
simple examples around a very simple domain
new UserRepository(new UserMysqlDataMapper($PDO, $userFactory));
Start from the first PR, obviously :P
Why aren't factories singletons?
Still seems like they don't need to be objects at all.
04:55
why are people obsessed with singletons
@Allenph you can have multiple implementations and multiple dependencies. Just.do.not.use.singletons.
Why are people obsessed with instantiating objects that don't need to be instantiated?
forget singletons, forget the term singleton
@Allenph they need to be instantiated most of the time - a factory could be reflection based, and the reflection definition can be injected
Any class with just static methods is a singleton, is it not?
this is how must data mappers work
04:57
Seems like a service and a factory should almost always be singletongs.
@Allenph yes, basically, which is part of the issue with it
forget about static methods too
@Allenph services are generally "unique" within the context of a certain dependency injection setup, but they aren't singleton
$userFactory = new UserFactory();
$userFactory->newUser("Allenph");
unset($userFactory);
Why not that vs...
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
04:58
UserFactory::newUser("Allenph");
User::register() is perfectly valid
no need for a separate object either, but that's because it's domain logic
@Allenph how do you pass the $factory around?
So the factory can just be a method on the entity or data object?
learn about dependency injection
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
@Allenph ya
04:59
it's the most important thing
@WesStark I know about dependency injection. That's why I'm confused.
posted on July 21, 2017

New Cyanide and Happiness Comic

@Allenph how do you pass this UserFactory::newUser around?
The repository will not use the factory associated with the domain object?
@WesStark you don't
05:00
indeed
the reason why User::register() (static) is acceptable is that this method is part of the domain definition
in the domain, flexibility is not needed - clear definition is more important
whereas in technical layers the opposite is true
Then you'll end up with multiple factory methods...
@Allenph yes
Well that makes zero sense.
User::register(), User::fromImportedData(), User::fromCreatedSubscription()
05:02
i disagree with doing that.
Why? The three above are all defined in the domain, transposed as interactions on the User object
@Ocramius All user objects should be the same though.
That's the whole point.
Obviously, you need to pass in some context too: User::register($existingUsers, $username, $passwordHash)
There should be one unified creation method, no?
@Allenph hm?
No
these are 3 different creation points
05:03
Why not just have one method which is passed the whole context...always?
$userFactory = function(*){ return new MyDefaultUserImplementation(*); };

userFromImportedData($userFactory, $data);
userFromCreatedSubscription($userFactory, $data);
@Allenph because you have 3 possible ways to create a user
@WesStark that's useless, harder to read, and further away from the domain definition
@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
@Allenph yes, different contexts are needed
Ohhhhhh...
I see. You don't have to think about the different context all the time.
05:05
For instance, a User::register() may check for a duplicate user, whereas a User::fromPastRegistration() just needs to accept any data
Because it's encapsulated in a plain English function.
@WesStark looks like a me mistake
Seems like domain object definition could get very long and have hundreds of methods.
i just don't want to have User::fromImportedData. why User would know about converting data from one of a million possible formats
userFromMysqlRecord($userFactory, $record): User
@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)
05:08
@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.
Right?
@WesStark that would be what the repository does internally. You are not CREATING a user there, you are unserializing a persisted one
We are talking about domain interactions, not serialization/deserialization
we are talking about factories... not creating entities
Of course if your repository uses a REST API you will need a factory to do that garbage
@WesStark User::register() is a factory in the domain
anyway... i don't know... static methods are crap is all i know
That's very short-sighted if taken as an absolute, but I agree with you when it comes to technical layers
@Allenph no, you actually impose the business rules INSIDE the factory method :P
05:10
@Ocramius that's my point.
`class User {
    static function register(ExistingUsers $existing, Username $username, Email $email, PasswordHash $pass) : self {
        if ($existing->contains($username)) { throw new Exception(...); }
        return new self(...);
    }
}`
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 need to use to learn exceptions.
I never use exceptions.
Ever.
Make it fail, make it fail early
@DaveRandom excellent
@JoeWatkins ready to try again
05:15
I think I need to do something
morning Joe
@Allenph though don't lose yourself among mostly unimportant things
I'm going to build something simple this weekend to see if I've got it.
o/
05:17
Will you guys tear it to pieces for me?
If not I'll ask teresko.
He's good for that.
@Allenph if you present it in the form of a PR, you can poke me for a review
I'll gladly destroy it
meanwhile, I still don't understand the (.) function
you are all too eager, it's friday ... slow down, my head is spinning ...
@Ocramius boob
05:18
also called "the tit operator"
yeh
@Ocramius Actually I was planning on giving you access to my self-hosted file server through SFTP and encoding it in some horrible compression.
ahaha
@JoeWatkins I'm awake since wednesday @_@
And then complaining here in public when you didn't want to do it.
@Allenph PLZ NO
05:19
@Ocramius You know I'm joking, right?
@Allenph I'll send you an invoice
Hahahaha.
@Ocramius sleep now
@Ocramius o.O plz take a rest
I'm going to go have too much brandy and watch Going Clear.
05:20
REST is for the HTTP compliant
Thanks for the help.
@Ocramius gooood ... and also humans ...
(Especially you @WesStark since you decided to help me after already knowing what a pain in the ass I am.)
Later.
the last time I stayed awake for more than 24 hours, me and @ircmaxell were doing jit stuff ... good times ...
can't think of anything I would stay awake for today ....
I fried my brain on this tonight btw:
"Compiling to Categories" - brilliant idea, incredible possibilities, brain fried though https://youtu.be/vzLK_xE9Zy8
frikken brilliant - compiling code to circuits, graphs, shaders
05:26
max time i am awake is almost 2.5 days
@Ocramius doesn't feel like a friday video ... let me check ...
!!friday
it's somewhat different
More like "IT'S FRIDAY WTF AM I DOING WATCHING ABSTRACT ALGEBRA TALKS?!"
:D
happy friday all \o/
05:30
Ok, am hungry, going for brexit
@Ocramius then sleep ... enjoy ... and do sleep ... remember ... sleep ...
this is the last peaceful friday I will have until september ... last day of school for kids for 6 weeks ... 6 whole weeks ...
they are going to ruin my life ...
I know right. got two weeks vacation starting tmr. so does the son. which kinda negates my vacation. though I guess we'll still have fun together.
@Allenph lol. i like discussing about code. later
You northern european farts and your short summer vacations.
You homeless italian expat and your endless vacation
05:34
Hey, at least I'm living with YOUR taxes
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 ...
this is why god invented summer camp
:P
we don't really have those here ... not where they stay there anyway ...
may teach daughter a new language ... or may learn a new language with her ...
italian!
:B
05:51
Italian takes about a day to learn
pizza! spaghetti! stronzo!
finito.
i knew this was coming
ahahah
maybe add some vino… and some ciao bella. but that's really it, then. will get you fed and laid forever.
bella ciao bella ciao bella ciao ciao ciao
questa mattina mi son svegliato
oh bella ciao, bella ciao, bella ciao, ciao, ciao
questa mattina mi son svegliato
e ho trovato l’invasor
@PaulCrovella i've always wondered if you guys know who bud spencer and terrence hill are

« first day (2470 days earlier)      last day (2704 days later) »