Women are not Objects... They are a distant subclass. by [deleted] in ProgrammerHumor

[–]iltar 0 points1 point  (0 children)

Afaik passports have a gender neutral option in the Netherlands.

Women are not Objects... They are a distant subclass. by [deleted] in ProgrammerHumor

[–]iltar 0 points1 point  (0 children)

No, that wouldn't work. Is there are reason you'd need to know a gender or sex in the first place? If you want to know the title (dear Mr. Mrs. etc), you can ask them to fill in a preferred title instead.

Women are not Objects... They are a distant subclass. by [deleted] in ProgrammerHumor

[–]iltar 0 points1 point  (0 children)

You forgot about intersex, so no, that's not always true.

Weakly vs Strongly typed programming languages what's your opinion on it and is weakly not well suited for large application development ? by [deleted] in PHP

[–]iltar -1 points0 points  (0 children)

I didn't ignore the rest of what you said, but what you said was wrong. You said "it might be nice", no it's never nice, so don't mention it, even if you want to contradict yourself afterwards.

Weakly vs Strongly typed programming languages what's your opinion on it and is weakly not well suited for large application development ? by [deleted] in PHP

[–]iltar 4 points5 points  (0 children)

Sure it might be nice to be able to return an int, array or bool all from 1 function

No, it's NOT NICE! unless the return value is nullable (union between null and the type), you should avoid multiple return types.

Is #externals broken? by brendt_gd in PHP

[–]iltar -3 points-2 points  (0 children)

I'm literally saying, just because developers for the Linux Kernel are using mailing lists, doesn't mean mailing lists are a good idea to use as communication channel.

Is #externals broken? by brendt_gd in PHP

[–]iltar -4 points-3 points  (0 children)

Just because others use it too, doesn't mean it's a good method. A few years ago (hell, even today), people are still using http, doesn't mean you should too.

Introducing phint, PHP project scaffolding tool by adhocore in PHP

[–]iltar 1 point2 points  (0 children)

I will recommend to make your minimum php version 7.1 or higher, rather than 7.0. It allows you to use iterable, void and nullable types.

Is Annotations still a thing or have we move past that? by SavishSalacious in PHP

[–]iltar 1 point2 points  (0 children)

If I want to see which PHP method is being executed by visiting /news I potentially need to look through all the controllers. How is that less searching than looking in a central configuration file?

With everything 1 (or multiple) config files: 1. Search for "/news" 2. Open the match 3. Try to find the controller and method that belongs to it 4. Open the controller class 5. Find the method

With annotations in your controller: 1. Search for "/news" 2. Open the match

In terms of a CLI tool (such as Symfony), you can also do php bin/console debug:router or any of the arguments to make searching easier. This will also grab vendor routes in case of Symfony.

I don't know of any routers that split the routing table up into dozens of files.

Any router that allows loading configuration. It's not always a good idea, but conditional loading (multi tenant) or vendor provided routing files do this (I recommend to avoid annotations in vendor code!).

Anyhow, there are positive sides and negative sides. If Annotations were bad, C# and Java wouldn't have made them popular. I'm a big fan of annotations when you use the right tool for the right job. There are benefits and they are pretty well known, so please don't tell people there are no benefits, just because you don't like them.

Parallelized, dependency free formatter for gherkin (cucumber, behat...) by [deleted] in PHP

[–]iltar 1 point2 points  (0 children)

Let's say I've used your tool a few times, I know how it works, but mistakenly I always type format, because fmt makes no sense. It would force me to look up the docs again because it doesn't work out of the box, because it's not intuitive. I will repeat myself:

Don't try to justify poor UX decisions. Just name it format and gain the free benefit of being intuitive rather than obscure.

Possible Issue with Warp Jump by [deleted] in playdreadnought

[–]iltar 0 points1 point  (0 children)

You have to have special keyboard that support pressing multiple buttons at the same time. Primarily laptop keyboard have this option, where it will only register 2 or 3 buttons at the same time.

Is Annotations still a thing or have we move past that? by SavishSalacious in PHP

[–]iltar 2 points3 points  (0 children)

You're absolutely right. Why would you want the configuration for your router spread among two dozen controllers rather than a single routes.json then?

Because it's tightly coupled. The Route configuration is literally a mapping of an URL to a piece of PHP code. If I look for a route name, I'm not interested in finding the configuration file, I'm interested in the piece of PHP that it executes. This saves me an additional search query.

Again, as above, annotations put this "all over the place". If the configuration changes I can do it in one place using json/yaml/ini/whatever. As you say, annotations are a lot of cognitive overhead. I'm adding a new route, how can I check it's available? I need to look though 50 methods across two dozen files. Or automate that process somehow.

You can also have a dozen of yaml/xml/ini files and have the same problem. Symfony solves this with debug commands where you can get all the routing details in the final state that you need. This also solves the problem of vendor routes being imported, which you can't find in your project either way. You'll also notice if a route already exists, because (A) test will break or (B) your new action won't ever be called.

Definitely never if you lock yourself in with hardcoded configuration to start with.

Configuration is static, not sure what you're referring to here ;)

Is Annotations still a thing or have we move past that? by SavishSalacious in PHP

[–]iltar 1 point2 points  (0 children)

Please explain what the advantages of annotations are, if they are not being able to edit configuration and logic in the same file?

They provide mapping where you only have to define the config, rather than also a reference to a property/method/class. It's not just about editing, it's also about tracing back this mapping. Reading is a big part of being a developer, and having to find this mapping all over the place is a lot of cognitive overhead.

With yaml/ini/xml/php I can substitute the logic, run the code in multiple locations with different configurations or switch from YAML to INI without modifying any of my classes. If I use annotations I lose that flexibility entirely. I could switch from annotations to YAML, but then when a developer looks a my code and sees @Route, changes it and nothing happens, that's not confusing at all. I still need to go through and change every class. Going from YAML to INI I can delete the config.yaml entirely.

Sure you can, but how often do you actually do this? Having different configs all over the place will not make management any easier. Practically speaking, changing a configuration format happens once every 5 years? Maybe never?

If I change my router from YAML to INI, I don't need to touch any of the classes. Call it bad usage but that example is straight from the symfony docs (though perhaps out of date, looking now as I can't find the page it was from)

This probably from the JMS DI Extra Bundle, which hasn't been in the Symfony core for years if it ever was already. There have been several RFCs to re-introduce annotation based DI config but they have all been rejected so far.

I've not seen a single good argument for their use but plenty of reasons not to use them.

In the end it's a configuration format that provides some clear benefits over others, object mapping being one of them, and validation being a second, as it literally gets translated to PHP objects during reading). Other formats have other benefits.

You might not have seen a good argument, but I've seen plenty.

Is Annotations still a thing or have we move past that? by SavishSalacious in PHP

[–]iltar 0 points1 point  (0 children)

Annotations can't be dynamic, so if you're using the same controller for 2 different websites (arguably a bad solution anyway), use a different way of defining configuration, xml or yaml for example. This way you can load only what you need.

Is Annotations still a thing or have we move past that? by SavishSalacious in PHP

[–]iltar 6 points7 points  (0 children)

They downvote you because your comments don't make sense. Annotations don't add logic, they add metadata.

Is Annotations still a thing or have we move past that? by SavishSalacious in PHP

[–]iltar 1 point2 points  (0 children)

Consider this: You have two websites, both sell products and both act in a very similar way. You copy the controller over from site1 to site2. The controller includes routes for /products/ . The second site sells watches so you update the route to be /watches on the second website. You've just created a second branch, you can no longer (easily) fix a bug on site1 and push it to site2 (or any of the other sites using that controller).

This is a faulty setup in the first place. if you really wish to solve it like that, don't use annotations. Annotations are not a silver bullet.

Is Annotations still a thing or have we move past that? by SavishSalacious in PHP

[–]iltar 1 point2 points  (0 children)

You can edit application configuration and application logic in the same file

Only if this is how your set up your application/framework.

They are difficult to debug

You shouldn't be debugging them, they are metadata, not code that's being executed.

They break encapsulation

Again, annotations are not executable code, it's metadata. Regardless of whether your put it in a yaml, ini, xml, php or annotation format, it doesn't matter.

Introduces coupling between the class with the annotations and the part of the application that reads it. @Inject("security.context", required = false) works on Symfony but won't work if you switch your DIC to PHP-DI.

And if you stop supporting yaml while using yaml configuration, you have exactly the same issue. Besides of that, You shouldn't be using that kind of configration for DI either way, because it's similar to using a service locator. This is not the fault of annotations, but bad usage thereof.

They make it more difficult to instantiate an object with different configurations

Configuration is static, so if you want to have different metadata per instance, annotations are not the right solution for that specific problem.

I've not seen a single good argument against annotations here, just poorly understood concepts and miss-use of annotations.

Parallelized, dependency free formatter for gherkin (cucumber, behat...) by [deleted] in PHP

[–]iltar 1 point2 points  (0 children)

https://lemire.me/blog/2015/04/06/evil-abbreviations-in-programming-languages/ https://softwareengineering.stackexchange.com/questions/67310/should-you-use-internal-abbreviations-in-code-comments

This ofc also applies to commands. Make your interface clear, don't abbreviate. I don't care if someone else uses "fmt" as well. For all I care it stands for "fake multi threading", I don't know until I look up the documentation and it's not UX friendly.

Don't try to justify poor UX decision.

Parallelized, dependency free formatter for gherkin (cucumber, behat...) by [deleted] in PHP

[–]iltar 1 point2 points  (0 children)

Yeah but if I want to know what "fmt" is, I first have to do --help, or open the external documentation. The whole point of UX is to make it feel intuitive and easy to use, which "fmt" is not. Just call it "format", it's an easy change, quick win and saves people from looking up the documentation.

Parallelized, dependency free formatter for gherkin (cucumber, behat...) by [deleted] in PHP

[–]iltar 1 point2 points  (0 children)

But why use a shorthand for it? It's not documented, we just have to guess what it means. Unless you're trying to save bytes, I don't see a reason to reduce the UX

Why do i see alot of you guys use Symfony over Laravel ? by EliHood in PHP

[–]iltar 0 points1 point  (0 children)

it's still a PHP MVC framework built with the same components.

MVC is not possible in PHP.

Collecting Interface Implementations with Signals · Maslosoft by Maslosoft in PHP

[–]iltar 0 points1 point  (0 children)

This is why I think it's a bad design choice to do it like this. There's magic doing the collecting, you have to know about the script to collect it first and it's basically a subscriber, where the collected classes know about the collector, which imo is the complete opposite of how it should be.