« first day (4029 days earlier)      last day (904 days later) » 
00:00 - 18:0018:00 - 00:00

6:09 PM
@ln-s Yeah, no worries. I didn't take offense at your questions. (I hang around here enough that mistaking me for a core dev is understandable.)
 
Thanks
 
so I made a DB abstraction... lol
I haven't tested code yet, still in the process of refactoring
but I just had this reaction of "I'll need to move this property in the other class... I need a PDO object in the other class... fuck it, move the other database methods in the other class..."
 
@Tiffany It happens to the best of us.
But yeah, a repository object that fronts a DB connection with domain-useful methods is a good thing to have.
 
caveat is I'm basically losing my logging, I haven't dug into how the logging system works, but I do know it's built on top of PEAR's...
figured it out... pass the logging object to the other class since it's a dependency
lol
I wonder if this will pass code review
but it works :D
 
6:33 PM
Wrap it in a PSR3 shell and inject that. :-)
 
if a service is global in your application, $GLOBALS is a ready-made container in pure PHP.
 
screamface.gif
 
the fun part is turning into deciding what goes in the abstraction and what stays in the original classes
it becomes easier when I start to split stuff out
 
It often does.
 
the single responsibility principle says that there should be only one reason to change a class. That would be both true for the original classes as well as for the new ones.
sometimes I remind myself to this when I have to make such kind of decisions.
but I found out it's better to do two implementations and then compare.
but the real hell is doing refactoring without automated tests.
 
6:48 PM
am I doing this right...passing table names as arguments...
 
@Crell you can build an object tree and then send events from the one continent to other - across all hills and the sea - just to throw it away in a fraction of a second or ... .
@Tiffany like for a database class?
 
very vague question... I apologize, I just feel like I'm doing something wrong by passing a table name as an argument, which is just a string...
 
well string looks like a good type to me for a name.
 
database method that I'm trying to abstract to be able to use in more than one class, but I don't know if the database query is the same... I could just assign the database query outside and pass the query...
 
what does that database method do? what are the collaborators with the database?
and which concrete problem are you trying to solve?
to make the database access more flexible?
 
6:53 PM
code reuse
I need to fetch info from a table, but it requires joining three other tables to pull the information...
because database normalization never occurred to this
 
let a repository handle the database details, give it the methods the other side needs and they just get what they ask for.
 
do I pass the query to it or pass table names?
 
the schema of the database may change, but the methods are stable. and if you need to change them, you can find their places of use quickly.
 
database schema won't change ... at least it better not ... otherwise I'm writing code that will require heavy refactoring ...
I'm extracting the data out of this database so it can be discarded
 
@Tiffany it works more like: $repository->findHotstuffByName('the cool name');
 
6:57 PM
I see
but I'm 99% certain database schema won't change
 
that is not about if it changes or not, but more like you wrote it has certain properties that are specific to that database.
if the data is not normalized how should the querying be able to be "normalized".
Just an example. A database must not be normalized, there can be reasons why it's not.
A repository can handle schema changes well because similar to a front controller it can shield internal decisions from the places of use.
But it's not the only trait of it.
 
I refactored the method to specify the table names, removed the parameters, and renamed the method specific to where it's being called... since I can't be certain the other classes will use the same query
I'm hoping I can but ... I don't have high hopes :P
 
the less parameters a method has, the less can go wrong ;)
 
class Repository {
  public method getThingASortedAscending() { ... }

  public method getThingById(int $id) { ... }

  public method getBleepList($sort = 'ASC') { ... }
}
And then put whatever database madness is appropriate behind that class.
And then if you find common patterns you can abstract better from there, or unify code paths, or whatever, go ahead and do so.
 
7:18 PM
I need to figure out how the autoloader works because a separate file isn't finding the abstraction class
I piggy-backed it into the file that resembles the "main" one, but I think the autoloader in this system depends on classes being the same name as files
 
Nearly all modern autoloaders rely on the filename matching the class.
 
hmmmmm......
 
Meanwhile, I just solved a problem very elegantly with a faked multi-return.

I don't know if I should feel proud or ashamed.
I feel like I should be able to do it cleaner than that.
 
7:48 PM
@Crell you used yield or what
 
No, just return [$a, $b]; and [$a, $b] = $this->doStuff();
 
...classes have to be children in order for the autoloader to recognize :|
 
wha ?
 
I assume asking if this app has ever heard of PSR-4 or composer is a waste of typing?
 
yes
before composer or PSR-4
 
7:52 PM
Just use composer init and edit composer.json accordingly to generate autoloaders for you
 
well, maybe around teh time of PSR-0
hmmm, I may be wrong because I added the parent class just to see what it'd do, and it still doesn't pick it up
 
So far the answer to almost everything in this project has been "add more types", "add more recursion," or "add more functional programming." It's a novel place to be.
 
manual require, my brain is starting to reach "can't see the forest for the trees"
successfully separated \o/
 
8:08 PM
It's also making heavy use of enums... and would be making heavy use of pipes and PFA, if I could. :-(
 
8:24 PM
Like... I think I just realized that this entire library is basically a nested array reduction. Like, the main logic flow is a recursive reduction.
I wonder if I could double down on that to make it even cleaner...
 
8:43 PM
... Aaaaaand I just got bitten by internal functions no longer allowing passing extra arguments. Excrement!
 
8:53 PM
@Tiffany if you don't have PSR-0 or PSR-4 schema, you can also add a "classmap" autoloader entry in composer.json and tell composer to scan a directory for classes (interfaces, traits etc.) it generates a classmap from each time you do composer dump-autoload. That requires to update if new classes are introduced, but the autoloading works with no need for require_once calls etc. in the code.
 
I've learned so much on this project, I almost want to rewrite my book now...
 
9:09 PM
@Crell That is always a good outcome from any project or body of work.
 
Indeed.
Like, I have a whole chapter on what recursion is, why it's kinda cool, but in practice not all that practical in PHP because of stack levels.

And that's true on a micro scale, but here am I building this entire library around a recursive reduction process with multiple stack layers in each recursion... and it's really really nice.
 
Chapter 11 "The cool but impractical practice of recursion in PHP"
Chapter 12 "Never mind..."
@Crell =D
 
In essence.
Problem is, it's hard to make an example small enough to fit in a chapter. This library definitely does not.
 
9:40 PM
@StatikStasis Chapter 13: goto chapter_11;
 
@Crell github link, most books do that nowadays
 
I find it tacky.
 
or provide a link to a zip file with examples
Well look at it this way, book will be cheaper if you save the large examples for the interwebs
 
The book is an e-book
Not a physical one
 
Not for ebooks. :-)
 
9:47 PM
Even better, provide a link
 
Why, like, I don't want to context switch to something else while reading a book
 
I would limit myself to describe a problem in it's basic form and then taking it to the max with a full blown example
 
Also, I might not have internet while reading it
 
Well, this example would be a tour of a complete serialization library.
I'd need to do a reduced-scope version of a similar problem instead anyway.
 
@hakre this particular project doesn't use composer autoloader, it uses its own, and not really possible to change that at this point in time. The "core" project does utilize composer finally, and we're allowed to pick out libraries if they're useful, which can be used downstream, but it still has its own autoloader too.
 
9:54 PM
Sounds like the technical debt in that project is huge
 
definitely
look up the definition of "legacy code" you'd find several of our repos as examples XD
also, hi, I'm Tiffany, I spent about ~60 minutes wondering why a field wasn't coming in only to realize I had a missing comma in my SQL query
 
Oopsies.
 
Enabling the query log from the db has always been an interesting way to look at a project
and tailing it ...
 
I'm still in testing phases so tailing it isn't much point because it runs about ten seconds
 
Worst project I saw was 1000+ queries just to load the index page
ridiculous
Worst part most of them were duplicates
 
9:59 PM
yikes
 
the money excuse works best in every case
 
what are the little tabs on the sides and bottom for different tools called? I seem to have turned them somehow, and was going to google how to turn them back on but I don't know what they're called... toolbar tabs maybe?
 
Technical debt sinopsis: "we won't improve this even if this makes your life miserable because that's why we pay you for right? Being miserable every single day, besides we are making money with this lol, suck it up"
navbar tabs maybe ?
 
I'm looking at jetbrains.com/help/phpstorm/… but they're not labeled
 
Nikic would know best ?
maybe ping him
 
10:06 PM
he works on php-src
 
and phpstorm ?
 
narp
 
So I've read a thousand times
really ok
:|
 
Hit ctrl F12 and the console one should come up
If everything has vanished, you may be in presentation mode
 
it's possible, I kept misspressing keys earlier
@ln-s I'm relatively positive he works only on php-src but I could be wrong. I was starting to dig through the chat log via search but wasn't finding what I hoped
 
10:12 PM
You mean the database tab and companions right ?
 
I mean regarding nikic working on php-src exclusively
 
No, your question
I just right clicked and the contextual menu refers to it as "toolbar"
 
like the bar on the far left, Project, Structure, the tabs at the bottom for Git, Terminal, TODO
 
View -> Status Bar
 
I can alt-key them but I like the visual indicators
 
10:15 PM
tool buttons, navigation, etc anything related to your question is in the view menu or at least it should be there
 
yeah, I must be in a presentation mode because it behaves like it's making somethign appear, but nothing does
 
hit Ctrl + ` then view mode
 
Tool Window Bars
turned out to not be a view mode
jetbrains.com/help/phpstorm/… this is what tripped me up for 20 minutes
I pressed it thinking it pulled up event log
 
downside of spring / summer: night fall takes longer ... I can't take out my telescope earlier
plus it was 96.8F (36C) today and it's not even summer
 
@Tiffany it is possible to also use own autoloaders with composer. just in case you're looking for a migration path (e.g. defining a project with a composer.json file).
 
10:28 PM
^ seconded, I've done that in quite a few nightmarish projects
 
it might... there will be a lot of things changing over the next year
a lot of things
like splitting this project into separate classes used to be heavily frowned upon, but I'm able to get away with some of it, hopefully all of it
idea being, whatever makes it easiest for me to get it completed. splitting it up into separate classes makes it easier for me, so that's what I'm doing :P
 
@ln-s actually I've also done this in quite some, also larger, legacy projects. It's not making it better just by that, but composer is a pretty good utility and it helps to define a PHP project in a de-facto-standard way you would go forward with anyway.
 
Well, when you have crack head joe writing autoloaders which are broken and then "patching" with require_once all over the place
it does make it better
 
if I think about, one key component is the auto-loading. and as this is discussed with splitting classes (that is getting more classes), it pays to have autoloading.
include the old autoloader, composer has the "files" ""autoloader"" that is just the include directive.
like an escape hatch if classmap autoloading wouldn't work (or just interim when integrating composer, whatever)
 
@Tiffany "I had to refactor it to be better in order to understand WTF is even going on" is most of the things I've done to TYPO3 core lately. :-)
 
10:35 PM
like I said, I write multiple implementations lately.
if you need to refactor the code to understand it, it's for sure a sign the documentation of the code-base is broken.
 
With all due respect, I got offered a typo 3 project once, I said "NOPE!"
 
No offense taken. They hired me knowing "modernize ancient OSS projects by rewriting most of it" is my jam. :-)
 
somehow I read that in a tone where "all" is not that much
you are a braver (read: much more patient) man than me, for sure :-P
 
s/patient/stubborn/
 
I mostly write VBScript and powershell so I cannot be throwing stones around this glass house
 
10:38 PM
Like, literally what I've been working on the last 2 months is a lever with which to upend the global arrays.
 
I'm extremely stubborn, but these days I avoid legacy stuff ... if I can rewrite it tho! That's a whole different deal
 
the one time I came close to a typo3 project is ages ago. neither did I had to touch the frontend nor any code.
so can't judge.
 
@ln-s omg yeh I will dissect batch files with a .com extension if it's because I am rewriting them
or PHP4
 
@DaveRandom those that were create with bat2com ? ^^
typo3 must have roots in php4.
 
real men hand-edit WIN.COM
 
10:41 PM
with edlin, yeah
 
I miss the qbasic editor actually, that was a fine piece of work
 
and there was no internet.
 
@hakre TYPO3 started in 1998/9. It dates from PHP 3 era, and has been 1/3 rewritten several times since then. Not always the same third.
 
gentle refactoring :P
 
Anyone know off the top of their head what the named args vs positional args performance is like? (hot path)
 
10:50 PM
@Crell I've heard rumors they have a huge array library.
could explain it.
 
@hakre They do. They have several "static utility classes", covering various topics.
 
@hakre I just barely remember this, the first IBM-format computer we ever had in the house (a Gateway 2000 486) had a 28.8 modem card in it by the time it was retired - I still have it in storage and the last time I tried to boot it ~5 years ago I got as far as DOS. it now has a DX4-100 in it which is not the original CPU, not sure what it came with
 
We're working on it...
 
@Crell these work well with autoloading. but you have to decide: abstract or final?
 
I want to destroy them. But first I want to destroy the arrays that use them. Which is what I'm working on now: Building a tool with which to destroy arrays.
My career is is a 15 year long scorched earth campaign against PHP 4 and associative arrays.
 
10:52 PM
shhh, no-one tell him about unset()
 
:-)
 
@Crell go with nikic's php-parser and create versatile tooling along the way.
it helped me so much to clean up old code. just apply a change on the whole source tree, commit and go forward.
structural search and replace in Phpstorm is also not that bad.
you can even make it an intention for a more interactive approach.
 
11:16 PM
@Crell out of curiosity, what is the burden with these "static utility classes"?
 
Makes testing harder. Also, they're many thousands of lines long.
 
so they deal with global state? and perhaps there is duplication because everyone writes a new utility method when needed?
 
00:00 - 18:0018:00 - 00:00

« first day (4029 days earlier)      last day (904 days later) »