News for hackers. Stuff that matters.
Re:Modern PHP without a framework by Falkon1313 on Sunday April 01, 2018 @03:49AM (#16727246)
While it's good in some respects, all this enterprisization is exhausting and can, perversely - counter to its intentions, be a significant drain on productivity. Once upon a time, we were focused on the important things - problem-solving, domain data, and business logic. But now we're almost entirely focused on abstraction, generics, and boilerplate while the important objective-related stuff that pays the bills just gets whatever scraps of time are leftover (if any).

We used to spend 90% of our time determining the right nail to use, the right wood to use it on, and where best to place it, and only 10% of our time on selecting and wielding the hammer. Now we spend 90+% of our time figuring out which GenericAbstractToolFactoryManagerFactoryInterface to invoke and how to properly invoke it a in such a way as to coerce it to ultimately generate something that eventually might generate something else that will hopefully drive some sort of fastener into something in such a way that will possibly hold it together, and the rest debugging why instead it is generating a generator that generates chisels that are chopping away at the foundation.

Yes, that's an exaggeration, but how much so? We are smart people, we do figure out how to use these complex combinations of systems to build functioning (bloated monstrosities of) applications. But are they really reducing technical debt or adding to it?

Are these systems really going to be easier to maintain in a few years when they have 357 dependencies that have each evolved over time (and or been abandoned)? Easier to optimize, when that means modifying what's going on under the hood of those dependencies? Easier to extend, when doing so would lead to conflicts with those dependencies?

I'm predicting that the next wave of discovery and hype in the field will be focused on improving productivity while reducing technical debt by removing the cruft that we're building now and replacing it with something simpler and more to-the-point.

Re:Modern PHP without a framework by iforgotpassword on Sunday April 01, 2018 @06:52AM (#16727672)
In my current job I inherited a 7 years old php project that's marked as legacy and scheduled to be phased out in 2020. Until then its mostly maintenance and adaptions to changes in stuff it interacts with.

It's built with php5, uses pretty static file structure, no namespaces but an autoloader. It has around 150 source files. I must say that it was surprisingly easy to get into the code base. The fact that there are no namespaces means class names have been picked carefully, no generic stuff like "dataholder". About half the classes are entirely static and there is still a lot of assoc arrays being passed around while in other places proper classes are used. The front end is just bootstrap with a little bit of additional js and ajax where it makes sense. Still it is really easy navigating the code base and finding the right spot to extend. I hardly ever felt constrained by the project's design, if ever rather by the inconsistencies of php(5) itself. Yes, sometimes it's annoying to implement a dynamic page update via ajax by hand without fancy abstraction, but if you're not building a modern spa it's not that bad and you actually get what's going on.

That other java code base I'm involved with is about 4 years old and really modular and fancy and maven and every time something needs to be added a discussion starts on how to do it, which parts to abstract away in which way, which library or framework might be suited best, and after five trillion years coding might actually start. I might have exaggerated a bit here but that's somehow the feeling I have more and more in modern software development.

Re:Modern PHP without a framework by sametmax on Sunday April 01, 2018 @07:17AM (#16727729)
> class names have been picked carefully

Boom. You can stop here. This has nothing to do with PHP or your project.

It's just the previous devs were good professionals. This is why "it's easy to navigate and extend".

Proper naming is one of the most important tell of a code work well done. You got lucky.

But a (good) framework will enforce a reasonable structure that will drive even less skilled professionals in a unperfect but sane direction. It's still possible to take bad decisions, but less often, and the cost of it is reduced.

Re:Modern PHP without a framework by mgkimsal on Sunday April 01, 2018 @07:33AM (#16727765)
Came here to say something similar. Not sure if you were downvoted or what, but I've inherited projects with function names like "runFunc()" and "doit()" which then have 18 global variables imported, then 1000+ lines of "if(foo=='j' && (barfoo!='f' && foo_old2=='ff') || 7) { // do j stuff v3".

You did indeed have a more professional set of folks developing that.

I just inherited a small PHP project written 2 years ago:

* no version control * running as root on apache 2.2 in /var/www/html * php 5.5 * about 12 "pages" each with a healthy mix of html/php ('header/footer' are abstracted to external incudes)

the problem with the 12 "pages" is there's around more than double the logic states and I need to add more. there's a bunch of

if($_SESSION['step3done'] && $_SESSION['step3errors']!="") {}

interspersed all over the place. Do I continue the pattern? Or refactor? The previous developer would add 'new' stuff in a matter of a few hours, because they'd just expand on that pattern; it's now unwieldy, and I need to add 'new' stuff, and expectations are "a few hours".

FWIW, it's probably what I'll do, but am migrating code in to version control, adding items in an issue tracker, and documenting my concerns in tickets, a README, and some code comments. It may come across as a bit passive-agressive, but it's not meant to; just trying to keep a history of concerns while also hitting their short deadline.

PHP needs to be upgraded regardless.

Re:Modern PHP without a framework by kilburn on Sunday April 01, 2018 @05:01PM (#16730405)
Don't worry about the possible "passive aggressive" interpretation. You are doing the best that can be done in your position. If they don't see it... well, that's their problem, not yours. You are already being more than enough accommodating by just accepting to work on such a mess of a project!
Re:Modern PHP without a framework by linoge on Sunday April 01, 2018 @07:31AM (#16727761)
I don't get why this comment is voted down.
Re:Modern PHP without a framework by daanlo on Sunday April 01, 2018 @07:47AM (#16727797)
Imho because the poster says: it is possible to have maintainable code without entreprization and the comment says: "that just due to good developers". Which is exactly the point of the post: you don't need entreprization if you follow the basic simple rules.
Re:Modern PHP without a framework by sametmax on Sunday April 01, 2018 @08:03AM (#16727834)
Yeah but you see, "entreprization" can help less skilled developers to stay on track and produce maintenable software.

It's the difference between flask and django in the Python world.

Beginners tend to go for flask. It seems easier.

But I actually always recommend Django to beginners, and only flask to experts.

Why ?

Well, because I've worked on a lot of code bases with both django and flask, and when you don't have good devs, the result with flask is disastrous. Indeed, flask delegates a lot of decisions to the dev, and as a result, if you don't know what you are doing, the project ends up with bad structure and terrible security.

E.G: django out of the box rotates your session key, provides csrf token, and en entire auth system. But I've worked last year on a flask project that used unsalted md5 password hashes. Their auth backend returned 403 for most errors in the authentication process, even for bugs, with unrelated 3 words messages.

The thing is, if your project is not a success, you don't care. But the goal of a project is being successful, and if it is, less skilled devs will probably have to work on it.

Hell, most projects don't even start with skilled devs. The reason is simple: there are too much demand for tech, and not enough devs. So we do with what we have. I mean, I have companies in the silicon valley paying a lot of money for me to work from my bedroom in France because they can't hire the expert they need around them anymore.

And when I arrive on a new project, guess what happens ? If it's a framework I know, I can start working on it from day one. If it's not, I'll need time to adjust. It's it's custom, I'll need more time, in direct correlation with the skill level of the other devs that worked on it.

Re:Modern PHP without a framework by baby on Sunday April 01, 2018 @09:53PM (#16731703)
Completely agree with you, basic php is really straightforward: one webpage = one php file. Nothing fancy. Basic Java is 1k layers of abstraction. That's why people tend to learn php on their own and java in school.
Re:Modern PHP without a framework by tboyd47 on Sunday April 01, 2018 @11:30AM (#16728766)
That's exactly what Ruby on Rails seemed like it was about to do ten years ago. But it was followed up by a counter-revolution that took us even further into enterprise bloat. It's as if there are hidden psychosocial forces that drive web developers in the direction of more complexity.
Re:Modern PHP without a framework by Zelphyr on Sunday April 01, 2018 @02:30PM (#16729722)
I think a vast majority of people in general, and developers especially, equate complexity with quality. And even when they realize that the inverse is true they don’t take the time to reduce that complexity.
Re:Modern PHP without a framework by h2j24 on Sunday April 01, 2018 @10:58PM (#16731976)
I have to disagree with you here regarding "enterprisization". Having worked in multiple large Java code bases leveraging multiple DI frameworks (Spring, Guice, and Dagger), I've definitely seen both sides of the argument first hand. I'm targeting DI specifically here, because it is most often complained about when talking about "enterprise" software. What I've learned is that proper use of DI is hugely beneficial in large code bases. Where things really break down is when the code base suffers from a lack of philosophy. The biggest issue with DI is that it is very easy to abuse, but these abuses have very specific patterns and can easily be avoided by applying a principled approach to development.

Regarding the beauty of DI, let me provide an example of a typical large application. Such an application may need a UserInfo class to model a user's information in the app. This user info class will likely have many dependencies: it needs a way to persist itself to disk, to make network calls for server syncs, and any other ancillary components. As an app component, I don't need to understand any of this. I just add a component to my constructor and I immediately have access to any functionality I may need. Using DI in this way also has a nice side effect: classes can be stateless singletons and still be easily testable with mocks. And the best part is none of this is magical. All of it is governed by a few simple rules.

Re:Modern PHP without a framework by agumonkey on Sunday April 01, 2018 @08:16AM (#16727877)
I worried that PHP would go too much 'pro' when they started consolidating things. But I thought they wouldn't reach JavaEE levels of fluff.. since most PHPers were more into pragmatics than hyperstructure.

I pity them

Re:Modern PHP without a framework by eitland on Sunday April 01, 2018 @09:17AM (#16728118)
Modern Java EE is actually really simple and lightweight. (My background is mostly php, later Java, all the time with some other languages like python w/flask, javascript etc in between.)
Re:Modern PHP without a framework by agumonkey on Sunday April 01, 2018 @10:49AM (#16728552)
I should have said J2EE sorry
Re:Modern PHP without a framework by LaneRendell on Sunday April 01, 2018 @03:59PM (#16730114)
Just wanted to say so much this. It's why I avoid web programming if can I.
Re:Modern PHP without a framework by daanlo on Sunday April 01, 2018 @07:38AM (#16727778)
Amen!