« first day (2684 days earlier)      last day (2490 days later) » 

20:00
I'm in management now have an excuse, I spend about 10% of my time coding now lol
@Allenph Types aren't an easy concept to learn, especially when detached from the runtime and especially when your typesystem is rich.
is it not a case of you have an object, it has a type and a value?
My TypeScript presentation has 2 examples in it that still sometimes gets seniors scratching their heads
@Bonner웃 No, objects don't have types, they are assignable to types
{foo: 'bar', baz: true} is assignable to both {foo: string} and {baz: boolean}
is that not just type casting?
@Bonner웃 No, it's similar to interfaces
20:02
ah
@Bonner웃 ... no, that's not a good analogy. I was asking because it seems like you are not even experienced enough to qualify as "novice". I'm not trying to be rude; I am not an expert either.
An object wouldn't always match an interface perfectly
so it is more related to functionality rather than data
The interface will often be much smaller than the class that implements it.
Rather, I'm trying to point out that you know so little that you don't even comprehend what you don't know about it yet.
You've got a lot of learning to do if you want to take this seriously.
20:03
is that directed at me Levi?
@Bonner웃 He pinged you, so yes, probably.
If you just want to argue... well you don't have to know anything to argue...
Levi what are you going on about?
I don't see you making any tangible points
or even making comment on my point of writing 1 line vs many to achieve the same result
@MadaraUchiha looking at your example let basically works the same as var in C#
what is this presentation you were referring to?
Gawd that dog
20:11
@MadaraUchiha damnit. the game. fu.
@FélixGagnon-Grenier You are the first to ever catch that :D
it's... a pleasure ;)
That presentation is at least a year old :D
what bit did you say people got confused with?
type inferrence or generics?
@Bonner웃 The two examples at the end
Especially that first one
20:15
that is just basic generics
where T is inferred to be string by the compiler
I just get a blank grey box
which slide are you referring to?
@Bonner웃 Press the "Down" key on your keyboard
ah one sec didnt see that slide
that is a misuse of generics lol
would you really write:
<Props, CompCtr extends ComponentClass<Props>>(cls: CompCtr): CompCtr;

in an app?
@Bonner웃 Yeah, both examples are from our production application.
Would you have felt better with <T, U extends ComponentClass<T>>(cls: U): U;?
20:21
no, it still hurts
nope, wouldn't even have that
@PeeHaa there's just no warning some people I guess
do you not have a static code code analyzer that looks at the complexity of your code and warn of where code can be too complicated to understand?
@DaveRandom <3
20:21
code checkers he says, too complicated to understand he says.
This is not nearly the most complicated piece of shit code in our app.
This is one of the better parts, and I'm happy to say that all of us in the team can understand this understandably non-trivial piece of code pretty much at a glance
we have a legacy codebase that goes back 15 years, thank god in that 15 years our code has remained relatively simple lol
Well, our legacy only extends back 5 years, and boy, the amount of cleanup we've made, and the amount of cleanup there's yet to do.
we are just now rewriting our codebase, we still have a delphi codebase we need to rewrite in C# too lol
what company do you work for?
as in what work does it deliver?
and we are hiring btw lol, we are looking for 4 more devs ;)
20:39
@Bonner웃 the term is "cyclomatic complexity"
it should be under 4 for a function ... preferable under 3
@Bonner웃 when you are running PhpUnit, it will measure the complexity in your codebase and display it
thats the term, just ran the static code analyzer in visual studio for a project I've written at home, all but one are 1 2 and 3's, the only place that is a mess is code I copied from Topshelf
of course, it assumes that you have any tests to begin with
you c an do it by having the following segment in your phpunit config:
<logging>
    <log type="coverage-html" target="./tests/report" charset="UTF-8"
        highlight="false" lowUpperBound="35" highLowerBound="70"/>
</logging>
@tereško You must use factory methods at least right? Do you put them on your data mappers or have a separate object?
I find it hard to decide because I seem to be building a factory object for an extremely specific purpose.
there are factories mentioned in the examples
@Allenph I am not using DDD. Which means that my factories are not creating domain entities. Therefore I have factories that produce mappers in my services
20:50
@tereško I'm not using DDD right now either.
@Bonner웃 yeah .. just don;t look at the master branch too closely .... it's in a middle of being re-written
there is 1.4.x branch, which is for the stable/published version
@Allenph could it be because you have begun noticing some major overkills required for an .. emm ... "proper implementation"
@tereško Part of it is kind of that. The rest is that I'm trying to keep my overhead as low as possible to get some better coding standards in the code.
Looks like you just have a really generic method where you call all the setters.
And that it's reliant on your columns being named a certain way.
not entirely
the column names are not important, since you can use aliases
the important parts usually are the ... emm .. result names
20:55
In my case there will be two or more persistence mechanisms, so I can't rely on generic functions.
But I also think you answered my question.
To just use a method on the mapper rather than a separate object.
kinda like here
I almost always alias the column names, because I tend to use a lot of joins in my mappers
I don't have that luxury as I'm using an API.
for example, the code I wrote today had at least 4 joins in every mapper
@Allenph you can still use the mapper to rename the columns
or you can call the setters manually instead of relaying on utility functions
Then I'd repeat myself a bajillion times.
I'm just making an array that will be used to map the columns.
This is seeming dangerously close to active record. o.O
you can create some adapter, that is a dependency of your RestMapper instances
21:00
Yeah, some kind of factory. But each would be incredibly specific and likely have only one function.
Is there a reason people will make an object's (ex private $currency) variable private, then make a public function (ex public function getCurrency()) that just echo's the private variable?
@Allenph no
Also, morning php
@tereško What did you have in mind then?
@Allenph will your mappers create domain entities?
21:01
Mhm.
or will the just use them?
@FélixGagnon-Grenier I've thought about it and come to the conclusion I don't need anything like Amp for quite a while; I just don't have enough stuff that needs high performance like amp to justify the added complexity.
@Alesana google: "oop encapsualtion"
@tereško The mappers are going both ways. Both persisting things and grabbing them, if that's what you mean.
but btw, you almost certainly want to clone the injector before the ->execute()
21:03
	private $keyMap = [
		// API_KEY => LOCAL_OBJECT_KEY
	];
@Allenph no, what I meant was: are there new statements in your mappers
Yes.
so, they are already factories
Sure. That's my point though.
In my example before I encapsulated that piece into a dedicated factory object.
@tereško Thanks!
21:05
.@rianjohnson Can't wait for the #LastJedi Blu-Ray! I sure hope you included this amazing deleted scene... https://t.co/lmdnIh0K5d
@Allenph sounds like you are pusing more and more logic in your mappers :(
@tereško My mappers seem pretty similar to yours.
It's just that every mapper has it's own custom applyValues.
@Allenph then try comparing it with this: github.com/teresko/blank/blob/master/src/Model/Mapper/…
I dont actually use applyValues anymore in my new code
I got rid of it, because it was obscuring, what was actually happening
@tereško Where are you actually setting the object properties?
All I see is $account->setCreatedOn($datetime);
in the fetch() method
yes, because that was only value being mapped in that small example
21:13
I was looking in the fetch method.
All I saw there was $account->setCreatedOn($datetime);
One setter call.
fuck
wrong edit
@Allenph yes, because that was only value being mapped in that small example
these days I tend to call explicit setters on the object, that is being populated
and one of the main reasons is actually parameters like this, where value is not something scalar
@tereško Ahh. But don't you end up writing those setter calls a billion times?
not really
@mikelodeonn The only reason I came back was to make Weird Al's lyrics come true.
Hmm. All right. I'll just use the setters.
21:18
@Allenph worst case scenario I have had - 4 mappers for the same entity
For different sources?
and then I created a super class for those 4 mappers, which had a method: populateBanner()
Or when you say mapper are you meaning methods?
no, for different states of a banner: new, in-review, published .. and something else, I do not recall
@Allenph no, I mean classes
Hmm. I can't really visualize what you mean, but I understand your point about the magic method.
21:20
for example, I had an entity Banner and one of the mappers it had was ArchivedBanner
all my mapper implement the same pseudo-interface: fetch(), store(), remove(), exists() ... as in, those are the public methods that they can have
Right.
(there is no actual interface defined)
You use one method for store?
Does it decide whether to update or insert based on presence or lack of ID?
yes, because I do not use DDD - if an entity has ID value, it is an update, if ID is null - creation
Ahh.
21:24
well ... at least usually
in case of that Banner entity it was actually more complicated
because saving a "published banned" was actually creating a new entry, but assigning a "parent" based on existing ID
the point is that store() method "saves the thing" .... the service layer should not really give a flying fuck - how
another example: remove() methods
sometimes they delete the entry, sometimes they just hide it
Looks like you're not calling new in there either.
nope
So, I went to go implement it that way because it seems like a good idea, then I ran into a bump.
What happens when I want to make an array of etntities?
21:33
as in: collections
Sure.
That seems very strange. I would tend to agree with hakre.
Your class adds additional functionality, but in the end new is still being called by the collection.
So it still seems appropriate to just say new in the mapper for a collection?
21:55
because collection is something of a special case, as I see it
besides, it will be a collection of a specific thing, so the the "new" in that context does not create additional coupling
So why not just use an array?
Is there anything really wrong with that?
I want a fast lookup
with an array would have to do a loop
and you can't really use the same array with multiple mappers
besides, I try to make add a little architectural boilerplate as possible - especially since architecture has a lot in common with battle plans: they do not survive the contact with an enemy
if you only add the code as much as you need, it will be easier to alter it
Then I'm just adding an array.
I'm trying to learn best coding practices, this might be based on opinion but would it be redundant to put the key of an array as a value for the array? For example $currencies = ['usd' => ['code' => 'usd', 'symbol => '$', 'name' => 'US Dollar',],];?
as you might notice, my collections have ArrayAccess interface implemented, because initially they were replacing arrays
22:10
@Alesana Depends how you will be selecting a record later
If it's by code put the code as key as you did
It is by code so it has to be the key, but for some reason I feel like the array that is the value should contain all the information about it. I guess there's no real reason though.
So then in __construct I have...
$this->code = $code;
$this->symbol = $currencies[$code]['symbol'];
$this->name = $currencies[$code]['name'];
@Alesana You could think of the array the same way as you think of a SQL query though.
It's basically the exact same conundrum.
Since I asked for it by ID should I still select the ID?
That's not neccesarily an answer, but if you have a way you like do do that, I'd do it the same way.
@Alesana I would pass the params separately in the constructor instead of the array in most cases
@PeeHaa This is actually something that's been confusing me a lot. There are times when I need to pass an array in the constructor, but I also need to ensure that it has certain keys.
@Allenph I have came across that conundrum as well. I think in that case since it might be slightly more expensive to select more things through relational databases I would not select what you're using to select it.
22:16
I could just make some kind of DTO, but...
@PeeHaa The array is actually in the constructor, it contains information about all currencies. It would retrieve it from a JSON file in production but in this case I am completing an assessment and they ask for it to be 1 script file.
@Allenph Use a validator. But actually first think about whether you actually need to pass a random array instead of typed and checked params
@PeeHaa I'll post an example when I run across it again. There is always some kind of catch-22 when doing that and I don't remember what it is.
@PeeHaa Hmm I don't actually pass the array. Here is my Currency class.
Oh that was to Allenph
I am slow
fghj
[pp2340-
22:23
Either @tereško is drunk, he's talking in cryptic code, or his cat has taken him hostage
I'm gunnu go with the cat one
was cleaning a keyboard
22:50
When writing unit tests for an external API do you mock the API, or do you use the actual API?
Some might say those are integration tests, not unit tests.
Well, I have two objects. A domain object with no behavior other than getters and setters which seems dumb to test, and a mapper which maps those domain objects to an external API.
I feel like they both can and should be tested, I just don't see any cases that don't involve hitting the eternal API.
23:04
Does anyone have a code example of validating an api against the json schema defined as per its swagger/open api spec?
23:33
@Ekin I've 7 left. Favorite I've done so far is regexcrossword.com/playerpuzzles/59e565c95008d
I forgot @tereško has a cat

« first day (2684 days earlier)      last day (2490 days later) »