« first day (1754 days earlier)      last day (3194 days later) » 

10:01 PM
Super Ocramarios
 
@Ocramius IMHO, they're overly complex. And then you sometimes hit the limits of an ORM and need specialized SQL queries which then fuck up the whole point of ORM. … I've not seen a lot of complex ORM using logic which didn't end up using direct SQL queries at a few places…
 
that is the downfall of any framework
 
@Orangepill hmm?
 
@bwoebi that entire domain is NOT simple. Bashing it because "zomg they complex" is not a useful argument :P
 
ORM is a persistance framework
 
@Ocramius Is Doctrine also designed that way?
 
Yes
 
@SammyK The email that @NikiC summarized what I was thinking pretty well.
 
There's loads of way to run around the ORM rules so that you don't need to follow its logic strictly
although you obviously land in the area of "I told you so!"
but again, ORM is good for OLTP, not for the wider domain of SQL or wider area of OOP
it fits a grey area between both
 
OLTP?
 
10:06 PM
OnLine Transaction Processing
start transaction, apply business rules, commit
 
So we have Google Analytics integrated, but as a result, we get a lot of visits from Google's bot. Is there a way we can check if a given IP is that of a Google bot?
 
@Ocramius basically trivial changes/fetching?
 
@DemCodeLines unlikely. Just add a robots.txt
@bwoebi yes, isolated changes to small datasets (< 1000 records)
 
It uses a variation of 66.249... ip and I can't choose an individual one to target.
 
@DemCodeLines check the user agent
 
10:07 PM
oh man
 
That's what OLTP is all about: purchasing tickets, bank transactions, stock market interactions, payments, contact forms, simple messaging systems
OLTP is not about "find the standard deviation of the data on this huge amount of records", to be clear
 
@Ocramius also… another thing I've noticed… ORMs fetch much more data than needed for a specific operation… they basically fill all the needed associations in too.
 
that's the domain of SQL
@bwoebi depends on the fetching strategy being used
But yes, there is noticeable overhead, ofc
 
@Ocramius issue is: either you fetch multiple times (lazy) or you fetch everything at once (eager).
What you want is fetching everything you need at once.
 
wow, software isn't perfect. Who could have possibly known that?
 
10:10 PM
@bwoebi yeah, I usually just fetch multiple times initially and then use stuff like manual hydration once I need to optimize that stuff
 
@danack who says
 
@Danack That's news!
 
as in my first iteration of my app is doing hundreds of queries (and I don't care at all ;-) )
 
@Ocramius as long as you don't push that to production…
 
No, ofc, but my first iteration is just guaranteeing "correctness" of the business logic
I also must make sure that I'm not eagerly loading the entire DB into memory (that happens if you're not careful, exactly like a query that goes bananas or non-optimized sql queries)
 
10:13 PM
That sounds like there are much more fallacies with ORMs than with pure SQL…
 
Well, it's fitting a non-oo model on an oo-model by normalizing/denormalizing data multiple times in both directions, so... congrats on discovering warm water!
 
@Ocramius not sure what you mean with discovering warm water?
 
That you didn't find anything new there
An SQL join operation is basically de-normalizing a normalized dataset into a resultset that is a product of multiple results
an ORM would take that stuff and re-normalize it into objects
this sort of stuff obviously breaks if you customize the joins, for example
 
ah
okay, I get now what you're saying
 
yeah... MAGIC
 
10:17 PM
I strongly suggest you to use a proper ORM (SQLAlchemy/Hibernate/Doctrine) btw, because you're still looking at a box and saying "magic" without seeing the benefit. The benefit really can be seen once you build an app with it.
the amount of pain introduced by it is exactly the amount of pain you'd get by using any framework
pros and cons are very similar
 
if it's still magic, even if it has a benefit that's bad
 
@Ocramius [that's why I'm generally not using any framework]
 
@ircmaxell it may be bad, but shit's gotta be done at some point :P
And writing a join result normalizer for every custom query is just time consuming to the extreme
 
@Ocramius and shit's got to be maintained at some point
 
@ircmaxell indeed, even more a plus for what I just said
 
10:19 PM
"result de-normalizer"
 
I realize you're just religious about this stuff, so don't even consider picking this stuff
 
@Ocramius I generally made the experience that using frameworks creates more pain than it helps.
 
@ircmaxell normalizer, sorry :P
 
I think ORM is like any other tool... there are cases where it is appropriate and cases where it isn't.
 
@Ocramius and that is where you fail. You write-off my arguments and standpoint without understanding it. Without attempting to understand it. Yet alone the fact I've used ORMs before (and continue to). You say "don't consider picking stuff"
 
10:20 PM
@bwoebi a good example of when you'd want to use such a tool is this typical use-case: ocramius.github.io/a-complex-orm-faster-than-sql/#/23
@ircmaxell no, I simply know that you are typically very stubborn when you start with a sentence like "if it's still magic, even if it has a benefit that's bad"
so I'd love to avoid a discussion on that in first place :P
 
yeap, that's what I said aloud when I read that sentence
 
(enters ORM debate) I think ORMs should be replaced/refocused/repurposed to be "ACID" helpers?
 
Two coders thinking the other to be wrong sighing at each other.
 
How unusual :P
 
10:24 PM
Instead of doing stuff like hydrating, and extracting away SQL, etc. Why don't these ORM tools do less of that and more things like helping with the UoW problem.
Or with batch inserts
things like that
 
@DavidGraham mostly because of lack of time. As I already said, feel free to help out on github.com/Ocramius/ChangeSet
 
Batch inserts was also started, but the dev that started it just changed job and stuff :P
We know our code is shit, eh, not negating that.
 
They should be called SQLMs not ORMs
SQL Mappers
 
@Ocramius It's more common to discuss than to sigh ^^
 
10:27 PM
Yes, I just feel like re-iterating myself, whereas I said above that I accepted the magic part and I also explained why I think it's ok to use magic to build objects from SQL resultsets
 
@Ocramius I was looking at the github.io link you sent me... and became confused at this part:
 
(which also was a re-iteration of what I said yesterday)
 
public function banUser($userId)
{
    $user = $this->repository->find($userId);

    $user->getBans()->add(new Ban($user));
}
 
@DavidGraham yes, example is borked
 
So you are fine with using the repository calls inside entities and domain services?
 
10:28 PM
Services, not entities
 
oh ok
 
I'm still a little confused about AR (aggregate roots). In layman's terms, these are just methods we add to an entity that encapsulates stuff that child entities would be involved on?
 
It's basically just the subject in the sentence representing your interaction
 
Such as $blog->addPost(); and then $blogRepo->save($blog);
Post would also be an entity. But I use blog entity to do stuff with it some times.
 
10:30 PM
$blog is the AR here
 
yeah
but I could bypass it, when say, I want to work specifically with the Post (no blog involved)?
right?
there I would go to methods on the Post entity?
 
hmm, sorry, I think I confused it with "direct object" in english grammar
 
yeah, I got what you meant
 
@DavidGraham only if the Post is also designed to work as an AR
you'd usually avoid direct interaction with it unless it's a new context
 
Everything is an AR of 1 in a sense
of 1 minimum
itself
 
10:33 PM
yar, except that you'd avoid having too many ARs, because keeping integrity becomes problematic otherwise
 
Ok, so what is in the Post entity then?
behaviors that are used only by the AR of post? (blog)
 
Doesn't matter, as long as the AR is the only entry point, it could all be public properties as well
 
So blog is the only one that accesses Posts methods?
 
the AR is responsible of keeping consistency in its boundaries
yes
 
in PHP how would you protect those methods? You wouldn't "extend" Blog to Post, right?
 
10:34 PM
You simply never expose Post instances outside of Blog
 
If a new developer decides to new up a Post somewhere, then it's his fault for not knowing what the AR is, right?
 
It's a stupid domain because it's too simple to model more than just "post new", "post change" or stuff like that
@DavidGraham yes, sadly we do not have protected/private classes in PHP
 
DDD really is a great way to tackle project complexity. Sure it's not the only strategy, but it works well, especially with natural human thinking
I'm surprised it still feels like an under-rated concept
 
One better domain to model is something like a poker game
 
@Ocramius I'm not sure if we shouldn't just reintroduce var and abolish private, protected and final
 
10:38 PM
the only thing you can interact with is the table
 
and in the context of the player, you can also read your own hand
 
but Cards could be an AR
an AR that is under the AR of table
 
but that's about it. You cannot "change" your hand. You can pass it to the table/discard/pass
Well, a poker game is the AR
(poker match)
 
10:39 PM
there is a good talk about "identity" by Mathias
 
I suppose in DDD you can arrange the domain in different ways. You just pick the best one for ubiquitous language.
 
well, from my naive perspective, a poker game has only 2 possible practical aggregate roots, eh
 
That guy is like single-handedly bringing DDD to php
 
you may add the AR of a tournament if it is in the context of a tournament
 
Does Mathias have any open source example DDD code? Unfortunately a lot I find is using Doctrine2 and it gets in the way for me I think. Maybe it shouldn't, since entities and methods are inpendent of Doctrine, right?
 
10:42 PM
I think he uses D2 anyway
(for PHP stuff)
 
You need to do more DDD talks in php like that
 
I am not an expert, I just digest, simplify and pass down to newcomers
 
Yeah I've seen that one, where they converted it from the blue book example
 
and apply at work
 
If you work in Law, you have the most perfect use-case for DDD ever
I work in sports information, also needs heavy DDD
 
10:48 PM
@DavidGraham it's actually interesting: by modeling their domain into objects, we found many legal flaws and loopholes in how you can avoid being fined and stuff like that
 
lol wow
 
we basically fixed them by producing explicit events to be sent for review to a manager or supervising authority
 
DDD just got me out of that speeding ticket
lol
 
client => super happy
 
You trigger the events in specific methods of your entities?
 
10:49 PM
most of the problems actually come from the stuff that was designed SQL-first :P
 
yar. It's hacky but it works good enough
 
domain first
then sql/db
 
yes, but that wasn't the case for half of the app >.<
 
I actually think it's a spiral. You start at the domain, and then think about the data structure and spiral back and forth. Many times the client needs a better domain.
 
10:51 PM
Well, that's one advantage
 
What interesting Stats/Information can PHP provide on the language-level?
 
in my world for example, people use the term "Teams" to mean lots of things. We could use a document database and store a big ol "Team" or we could look at the domain and fine tune it to be "Teams" "Rosters" "Roster People"
 
Like I can see referrer, get/post etc. What else?
 
I mean, look at the domain (with Database in back of our mind)
 
@DavidGraham or maybe it's all 3, but in different contexts (bounded contexts)
 
10:53 PM
so what exactly does a bounded context do? Code-wise, what does that look like? do?
 
It's a "Team" for HT, a "Roster" for helpdesk, and "Roster People" for your notification system
a bounded context can usually be thought as a separate app
 
oh I see. We shouldn't be afraid of storing these in the same place in the database. But entity-wise, they are 2 different classes?
 
your HR management app calls the entities "Team", the helpdesk frontend uses a "Roster" full of available helpdesk contacts
 
with different rules.
 
that's the catch, they are on different DBs
copies :P
 
10:55 PM
Realllly?
 
and the systems talk with each other only by ID
 
In case the database needs to do something differently on one side of the bounded context
 
but it will most probably do that
 
So bounded context means the language doesn't match
 
correct
 
10:56 PM
areas where the language doesn't match
 
it's a different language
 
you code (what may seem at first redundancy)
?
 
yar
 
wow, wonderful
these terms seem so scary, but they are practical things
 
well, otherwise, if you share the data in one table, you are going to have trouble if the model doesn't fit perfectly in both domains
 
10:57 PM
yeah
 
oh, how fitting:
Put differently: abstracting repetition is easy and satisfying, but refactoring a wrong abstraction into a good one is hard and costly.
 
....one moment...absorbing this...
ahhh
so don't assume DRY = Good
 
right
 
Yeah, you can quickly spot and abstract repetition later
but the reverse is costly
got it
 
here's an use-case with "Team" and "Roster": in a "Roster", a person MUST have a Jabber ID to be contacted (an address, to be clear), whereas in a "Team", he may just need an email address and a name
and maybe also info such as "salary"
 

« first day (1754 days earlier)      last day (3194 days later) »