Live data from Hacker News

PHPAlgorithms – PHP algorithm and data structure library

github.com

1–10 of 21 posts

Re: PHPAlgorithms – PHP algorithm and data structure library

#3
I think it would be better to publish the individual structures as standalone files without dependencies.

Then I might use one of them in the future.

But pulling in thousands of lines of code by someone from the internet is nothing I would ever do. Because I cannot review it all to be sure it is not malicious. Reviewing a single file without dependencies is something I might do.

Re: PHPAlgorithms – PHP algorithm and data structure library

#4
post #3

I think it would be better to publish the individual structures as standalone files without dependencies. Then I might use one of them in the future. But pulling in thousands of lines of code by someone from the internet is nothing I would ever do. Because I cannot review it all to be sure it is not malicious. Reviewing a single file without dependencies is something I might do.

It makes more sense you keep only the files you need, I do not understand how exactly the author should bundle this OOP using algorithms in 1 source file that will satisfy everyone requirements and at the same time won't contain some code you won't use.

Re: PHPAlgorithms – PHP algorithm and data structure library

#5
post #3

I think it would be better to publish the individual structures as standalone files without dependencies. Then I might use one of them in the future. But pulling in thousands of lines of code by someone from the internet is nothing I would ever do. Because I cannot review it all to be sure it is not malicious. Reviewing a single file without dependencies is something I might do.

It makes more sense you keep only the files you need, I do not understand how exactly the author should bundle this OOP using algorithms in 1 source file that will satisfy everyone requirements and at the same time won't contain some code you won't use.

That is kind of what I am doing myself, still learning some concepts so the code is not very reliable but merely educational.

https://github.com/sh4ka/coding-exercises

Re: PHPAlgorithms – PHP algorithm and data structure library

#6
post #3

I think it would be better to publish the individual structures as standalone files without dependencies. Then I might use one of them in the future. But pulling in thousands of lines of code by someone from the internet is nothing I would ever do. Because I cannot review it all to be sure it is not malicious. Reviewing a single file without dependencies is something I might do.

This makes me feel bad about clicking Install > Activate on all those WordPress plugins every day.

Re: PHPAlgorithms – PHP algorithm and data structure library

#7

Earlier quoted context omitted.

It makes more sense you keep only the files you need, I do not understand how exactly the author should bundle this OOP using algorithms in 1 source file that will satisfy everyone requirements and at the same time won't contain some code you won't use.

That is kind of what I am doing myself, still learning some concepts so the code is not very reliable but merely educational. https://github.com/sh4ka/coding-exercises

One class per file and mybe some namespacing would be nice to see.

Re: PHPAlgorithms – PHP algorithm and data structure library

#8

Earlier quoted context omitted.

It makes more sense you keep only the files you need, I do not understand how exactly the author should bundle this OOP using algorithms in 1 source file that will satisfy everyone requirements and at the same time won't contain some code you won't use.

That is kind of what I am doing myself, still learning some concepts so the code is not very reliable but merely educational. https://github.com/sh4ka/coding-exercises

I just had a quick look, some observations if you don't mind,

- use a good linter and fix all warnings you get from it if possible

- use code formatting so all your code has the same formatting

- you put the isDead function in the Piece class and pass the board object, IMO it makes more sense to put it in the Board class or even better make a Game/Puzzle class , then you can reuse the Board and Piece unchanged when you implement different rules but the board and pieces are the same.

Re: PHPAlgorithms – PHP algorithm and data structure library

#9
post #3

I think it would be better to publish the individual structures as standalone files without dependencies. Then I might use one of them in the future. But pulling in thousands of lines of code by someone from the internet is nothing I would ever do. Because I cannot review it all to be sure it is not malicious. Reviewing a single file without dependencies is something I might do.

Didn’t we all give up worrying about that with the rise of package managers?

Re: PHPAlgorithms – PHP algorithm and data structure library

#10
post #3

I think it would be better to publish the individual structures as standalone files without dependencies. Then I might use one of them in the future. But pulling in thousands of lines of code by someone from the internet is nothing I would ever do. Because I cannot review it all to be sure it is not malicious. Reviewing a single file without dependencies is something I might do.

This concept of reviewing every line of OSS and copy / pasting the ones you agree with is really holding PHP dev back. Embracing dependency management is an important way to focus your codebase on your application code and is just a modern practice in all languages (https://12factor.net/dependencies). This is part of why JS (particularly node / isomorphic) is continuing to take over previously PHP marketshare. The actual (vs handwavey) security risks are low especially for popular projects.

In this case, if the datastructure or algorithm were useful to your project, you could: 1. Not use the algorithm / data structure at all, resulting in worse performance. 2. Hand roll your own version which is more likely to have improper implementation issues than an OSS version, likely resulting in performance or security issues and wasting your time. 3. Use the OSS version which is likely to have bugs / errors / security issues already solved.

Post reply on HN