The PHP 7 Revolution: Return Types and Removed Artifacts

The thing is, that if your code works fine and does not limit or make you nervous to change code, then it probably is not needed.

I just refactored a 10,000 line Wordpress plugin ( one giant class ) to many classes and about 1000 lines of code and the plugin functions exactly the same with the public api.

People were afraid to make changes, so they made very few. Since refactoring, the business has modernized many new features, and are not afraid to ask for changes. This plugin was either going to die or be rewritten. Refactoring has breathed new life.

I do not have a problem with refactoring my code because of security issues. That is why I stopped using register_globals as soon as I read about the problems and before it was actually deprecated.

Once I have written a piece of code I leave it alone until I have a good reason to look at it again, such as to fix a bug or to deal with a change in user requirements. If a new feature becomes available in the language I don’t search through my codebase looking for places where the new feature can be used simply because I don’t have the time (nor the inclination).

That’s just your opinion, and it’s an opinion that I don’t share. You can show the same piece of code to 10 different programmers and they would all want to refactor it in 10 different ways. There is no such thing as “one size fits all” when it comes to coding style, so someone will always object that my style is not the same as theirs. I learned a long time ago that it is impossible to please everybody, so I don’t waste my time trying. The first person I have to please is me, followed by my paying customers. The opinion of other programmers is not important to me.

Precisely. I have been maintaining and enhancing my framework for over 10 years without difficulty and the ERP application which I built using this framework has also been maintained and enhanced for over 8 years, again without difficulty. I am never nervous about changing my code. Sometimes I need to do something in my application which could best be done by changing the framework, so I change the framework. Sometimes what starts off as a small change ends up as a larger change as I see a need to refactor other parts of the application so that the desired change can be implemented in as clean a manner as possible.

The point is that I decide when and how to refactor my code. I am getting sick and tired of all these junior programmers (anyone with less than 35+ years experience is junior as far as I am concerned) telling me that I should refactor my code for no reason other than it should mimic their particular coding style.

I guess that makes you a junior PHP developer then :smile:

You obviously haven’t read my CV which states that I started programming in the late 1970s. That’s probably before you were born.

You obviously didn’t get the joke, as PHP has only been around for 20 years.

Seriously though, you’re just defining the terms junior and senior to suit yourself, despite it having absolutely no relevance to the discussion at hand anyway. The number of years you spend practicing a profession has no bearing on whether your ideas or arguments have any validity.

3 Likes

You obviously didn’t read his response because he said “Junior PHP Developer” (PHP hasn’t been around for 35 years…) :stuck_out_tongue:

I’m a bit offended, as I haven’t been born for 35 years yet, but I have 15+ years of programming experience that has been through various jobs. I hardly consider myself a junior programmer, but I’m more than willing to call myself a junior programmer when it comes to Ruby, which I only have at most a year worth of experience with.

To say the title goes beyond the languages is a bit hard to agree with. You may understand the concepts and practices well, but unless you also understand the language very well (and its quirks – every language has them), then you are no better than the guy who just started in the same language… (at least not much better). Once you know the language, all of that quickly changes by a factor of multiple because your past experience starts to really show the difference in what you know with the given language to that of the “new” programmer who may still have to learn those concepts and practices.

This is a very good point. At least it means we can call tony a “Senior”… and we all know how well new technology and seniors work together ;p

If we’re playing the ‘experience’ card, I’ve been programming professionally for 15 years, I teach at a university and I’m doing a PhD which is centred around code smell/bad practice detection.

1 Like

umm okay, if this is what you believe. But still like I said, I never assumed that you were an incompetent programmer, the term ‘incompetent’ is very ambiguous and I’d rather use the word unmodernized here. As your later post indicates, you started programming a long time ago all the way back to 1970s, and your first programming language was COBOL, which was a procedural language. Its understandable that it must have taught you many concepts and habits that were common and acceptable at that time, but were no longer considered good practices nowadays, such as global variables, singletons, long functions/classes, etc. Also your understanding of OOP is very shallow and unconventional, as you believe using objects alone makes it OOP, while in fact its far away from that. Apparently coming from a procedural coding background was a huge obstacle for your transition into the OO world, as some old habits would not go away easily.

Anyway, a modernized programmer, however, learns new concepts and adapts with time. Thats actually why many coders are doing refactoring, since they learned new skills and practices that will help with their development in a long run. It’s never too late or old to learn, but it seems that you treat it as personal insult whenever people tell you that you need to refurnish your coding skillset and do something differently. Years of old programming experience can be beneficial or detrimental, depending on whether it helps you write better programs now and in future. So honestly, I consider that your so called 30-40 years of programming experience a hindrance here, since you fail to adapt to the modern programming standards and instead holding on to your old inappropriate procedural programming mindset that was common in the 1970s but are more or less obsolete nowadays. The world of computer and programming changes and moves rapidly with time, and I find it surprising how you willingly stay behind. Perhaps you still do not understand the nature of this industry, but I dont want to make an assumption so I will stop here. Good luck.

2 Likes

Just because “some” people consider those things as “bad practices” does not mean that everybody else should follow suit. Different groups of programmers have entirely different ideas of what is “good” or “bad”. You are allowed to write software your way, I am allowed to write software my way and Joe Bloggs is allowed to write software his way. “To each his own” is an old saying, just like “one man’s meat is another man’s poison”. The world is full of differences, so stop attacking me just because my methods are different from yours.

I object to the word “shallow” as “simplified” would be more appropriate. My approach to OOP is based on this description which I found in my early research into the subject:

Object Oriented Programming is programming which is oriented around objects, thus taking advantage of Encapsulation, Polymorphism, and Inheritance to increase code reuse and decrease code maintenance.

As PHP 4 supported these essential OO concepts - encapsulation, polymorphism and inheritance - I found it very easy to employ these concepts and produce software which had better reusability and maintainability than what I had produced using my previous languages. Although lots of extra features were added in PHP 5 to support OO I have found absolutely no practical use for any of them, which is why I don’t use them. As far as I am concerned any programmer who is incapable of writing effective software using nothing more than encapsulation, polymorphism and inheritance is just that - incapable.

I do not NEED to refurbish my coding skills just so that I can do everything the same as you. If I did everything the same as you then I would be no better than you, and I’m afraid that your best is simply not good enough. Progress can only be achieved by change, by trying something different, so I choose an approach which is different from yours. Rather than being a total failure it actually works, so don’t tell me that my approach is wrong.

Tony is right.

He doesn’t need to refactor his application. He doesn’t need to adopt the ‘best practices’ of our industry, or modern programming techniques and language features. As long as he’s happy to maintain his legacy codebase, let him continue to do so as he pleases.

As I see it, best practices ARE worthwhile for developers who:

  • Want to develop software they hope will be adopted and used by other developers
  • Want to reuse some of the many high-quality, 3rd party libraries out there to be more productive and avoid re-inventing the wheel
  • Want to be employed in some capacity where they work as part of a team, and
    will rely on these standards to be able to collaborate on code with their
    colleagues

While it’s true that best practices aren’t unbreakable rules, most (if not all) of them have been widely adopted because they minimize the likelihood of problems and mistakes.

As an analogy, imagine a skilled and experienced steelworker who works on high-rise buildings. He might think “Ha, I know what I’m doing! Any competent steel worker doesn’t need all this safety equipment and regulations, it just adds unnecessary time and complication to my work!”. The the point of these guidelines is two-fold: less experienced workers will minimize their risk of getting into trouble by following them, and even the most experienced professional can make mistakes. Following best practices reduces your need to work harder to avoid problem areas.

4 Likes

And:

  • Want their code to be easily understood/modified by others
  • Want their code to be as easy to maintain as possible
  • Want to make their code as robust and bug-free as they can

It’s worth taking a step back and thinking about why practices have been deemed either ‘best’ or ‘bad’. These practices have all been tried and tested with the results reported by numerous academics and professionals who have fallen into holes and found themselves having to rewrite large sections of code because it was built on foundations which made it difficult to maintain.

Pointing out “This is a bad idea because it stops you being able to alter the code to do x later on and you’ll need to rewrite it or a hacky workaround” is essentially what a ‘bad practice’ (or “code smell” or “antipattern”) is.

Tony’s clairvoyance apparently allows him to guarantee the client will never ask him to do x and that it will never affect him.

1 Like

Why, then, are you so hesitant to try these practices we all speak of, and to accept the problems in security with your approaches even after having been given the materials that clearly demonstrate their substandard design?

3 Likes

Yeah I totally agree, practices are deemed good or bad for valid points, its the experience from hundreds or thousands of professional developers who have going through the problems again and again to figure out what should be done and what should not be done. People wont tell you that you should do this and should not do that for no reason at all. I am an advocate for design patterns, especially good design patterns, since they offer benefits that I will appreciate considerably in future.

1 Like

You guys miss a very important point.

Tony has a different experience as he stated very many times, so the opinion of others does not matter that much. Also he has 35+ years of professional experience which places him around 55 years old. You wouldn’t argue with your parents or grandparents about their way of doing things for one month non-stop telling them they are doing it wrong, would you? :wink:

1 Like

“I’ve come up with a set of rules that describe our reactions to technologies:

  1. Anything that is in the world when you’re born is normal and ordinary and is just a natural part of the way the world works.
  2. Anything that’s invented between when you’re fifteen and thirty-five is new and exciting and revolutionary and you can probably get a career in it.
  3. Anything invented after you’re thirty-five is against the natural order of things.”
    ― Douglas Adams, The Salmon of Doubt
2 Likes

You make a point, sure my parents and grandparents do some wrong things their own ways, but there is a difference since they aint public advocates. Of course I wont argue with them, because they are not standing in a public stage and telling other people that they should be doing their wrong ways because its correct in their eyes. If they are happy with what they are doing, its okay, but it becomes a problem when they start to tell people, especially the general public that their wrong ways are the approaches to take. If my parents or grandparents are public advocates for their wrong behaviors, I’d definitely argue with them since they will be effectively damaging the society. But they are not, and they never will, so this hypothetical situation is not meaningful anyway.

So you see, a forum is a public community in which we come to learn, educate and exchange ideas. It is not my house, in which I can do whatever I want to, good or bad, right or wrong. You can say the president sucks at your home or with your friends, no one will have a problem with it, but when you say it in a public area with lots of people coming from various regions and background, you will have to back up your claim with evidence why the president sucks. It’s the same thing here. Like @fretburner said in an earlier post, if Tony is happy maintaining his legacy code, let him be. There’s not a problem with that, but it becomes an issue(or more precisely, a war) when he starts to claim his code is superior and that the other people are doing the wrong thing instead. In fact, he does make an very interesting blogpost last year, very nice to read Id say:

Yes, it is when you start to claim superiority in front of public that you have to back up yourself with reasons for validity of your argument. Otherwise, people will counter, friendly or aggressive, which cannot be helped. Anyway, I am not interested in starting another argument with Tony anymore, I am just stating the reasons why people are arguing with him. I hope you understand that, these arguments from previous posts do exist for a reason.

1 Like

Please, lets NOT talk about other members here.

Either stick to discussing the topic, or not post.

NOTE

If I see any further posts that are in the slightest Off-Topic I will delete them in their entirety

How about we lock this topic and let the discussions on various aspects within branch off into their own topics?

Sounds good to me.

For those unfamiliar, it’s the “Reply as linked topic”

Topic Closed