Procedural PHP vs Object Oriented PHP [closed] - php

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I am fairly new to PHP (you just have to see some of my previous/recent posts!). I have done a lot of my learning by studying other people's frameworks and attempting to rewrite them for my own purpose.
Out of the examples of code I have seen, it seems about 50/50 Procedural to OOP. My question is not which is better, but when should I consider using OOP over Procedural?
By the way, I don't want to encourage an open discussion of personal opinions as to why one should be used above the other. I am fully aware, after researching, that some people just prefer to use one or the other. I am after a legitimate reason as to what would encourage me to use one over the other and in what situations.
I have also read through a few different (but similar) questions on the subject, but they seem to be flagged as not constructive because it starts a debate. I don't want this, I am on a Q&A site as I am looking for an answer, not an argument.

Even thou it is 2014, you are still allowed to wash your dishes by hand, communicate with all your friends only in person, landline phone calls or letters send by the local postal service.
And you might feel incredibly well doing so.
But if you try to host a lot of dinner parties for a lot of people and organise important projects with a lot of people from remote destinations, having hard deadlines, you might consider getting a modern dishwasching machine and a smartphone.
Same goes for OOP vs. procedual. If you are just adding a tiny piece of functionality (display the current date, echo a random hash string) on your wordpress weblog: Go procedual.
If you are writing a tiny tool that does something you need to get done, if you are writing a tiny cron job batch script in PHP or if you are just fooling arround - do as you like.
But if you plan to develop sustainable, maintainable, testable, reusable, quality software that has a lot of features you should at least use OOP. Because it is bloody 2014.
OOP will enable you to blackbox and whitebox test units of your code seperately. It will enable you to not only efficiently reuse libraries and modules written by others but alos enable you to produce modules and libraris that can be reused by others.

Related

Is a compare between PHP and NodeJS worth? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
I start this topic saying that I use PHP since 2014 and I'm experienced with it, but recently (yesterday) I started to give a look to NodeJS.
Node is growing fast and it's been used by a lot of web-services.
I started using it yesterday, but I found it less "beginner-user friendly" than PHP.
I'm not saying this as a beginner in computer programming, but as a Node-beginner.
What is your opinion?
Is it worth knowing both languages?
Is it worth knowing both languages ?
If you come from php development, learning node is a great idea.
It ll teach you in a soft way the concurrent programming pattern, and also event/stream programming,
it will lead you to face problems regarding the underlying OS in a soft way.
All sort of stuff that PHP greatly solves for you right out of the box and which you never think about.
Node will also give you the impression of a bigger playground to explore.
But, if you want to be productive when it s about building website, i believe PHP is better.
On the other hand, if you are looking for performance, node may be better, but true performance comes with compiled languages like GO, not scripted languages.
Finally, if php was not plumbed by all those damn heavy javaesque framework, it would be a really nice environment with a good trade off between speed and complexity.
Node gives you speed, but it comes with a price about the complexity which can be very costly.
As a beginner of both language i noted the following advantages of both languages
PHP
Mixing code with content
Deep code base
No client app needed
SQL
Speed of coding
NodeJs
Separating concerns
Newer code means more modern features
Service calls are thinner than HTML-fat PHP calls
JSON
Raw speed
You can read full article Here

PHP vs NodeJS - text based RPG [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
I know this isn't a very good question to ask because people may give bias answers, but was wondering if someone could list the pros and cons of using PHP vs NodeJS as a backend language in developing the average text-based online RPG.
The RPG will store its data in a MySQL database and will have typically 10-20 players online simultaneously.
For the long-run, which language would you think is more suitable?
I have several years of experience in PHP and barely any experience in NodeJS. It seems PHP has really good synergy with MySQL but I've been really hearing good things about NodeJS. Also, what design approach should I take (i.e. MVC).
Would be great to hear from someone who has a lot of experience in both languages.
Node.js is not a language. The language is Javascript.
Both are perfectly good choices, the main difference is the asynchronous approach of everything nodejs related. This increases the performance and scalability, but it's harder to debug and uglier to write and read (Learn about the callback hell). You need to get the asynchronous concept very well if you want to have the advantages people usually credits nodejs with.
This being said, you can program asynchronously with PHP, but it's far less common.
So if you are confident with PHP, you need the results fast or don't want to experiment go with it. If you want to learn or experiment, go with Node.
If the limit is 10-20 simultaneous players the performance shouldn't be such a a problem.
About the design approach, I would leave the details for last. MVC is very common and you will probably use something like that to organize your code but the choice depends on lots of factors and you should probably think about this after having the use cases / stories of your application defined and limited.

Learning process of PHP (Framework Symfony, OOP) [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I am starting a new challenge. I am on my way to learn PHP since (I already have good knowledge in HTML CSS), i would like to have you advise in a good procedure of learning this.
To be specific my final goal is to be a very developer in PHP by the end of 2015 and able to work on project on my own and/or with team as freelancer.
I would like to hear from you guys a step by step learning programs which will conduct me to have confirmed knowledge in PHP OOP and Framework Symphony2. As i don't want to skip the stages i'd like your advise :
I have basic understanding of (loop, if/else, function).
I am looking some course (updated) and exercise to push up my level slowly but efficiency. A list of step would be a great start.
I'd suggest that you ensure that have a solid understanding of generic programming principles before you focus on a specific language. Knowing markup languages like HTML is relatively easy in comparison. When you get to programming, there's a lot more things to consider.
There's plenty of available free resources that should be able to help you.
http://www.tutorialspoint.com/computer_programming/
welcome to SO. There are lots of resources out there, some easier than others for a beginner. I would start on something like code academy and augment that with resources like php.net.
Then when youve covered those tutorials (I would do all the markup stuff like HTML as well) think of a personal project and build it. Its all very well reading manuals and doing tutorials, but you need a real live project to force you into finding solutions for real debugging issues. That cant really be taught.
Its worth noting that PHP isnt the only server side language out there, so keep an open mind and be ready to investigate other avenues as you find them.
Bear in mind to be able to hold your own in the industry is very different from being able to handle your personal projects ok. There are a lot more variables (no pun intended) in industry and the skillset you need to have is often wider.
Good luck with it.

PHP or Lift framework for a web application? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I'm currently developing a web application using PHP, but I'm considering developing the web application using the lift framework instead, because twitter and foursquare have implemented it. I know a few benefits using lift/Scala but, could you guys mention some benefits compared to PHP?
Many thanks
Resmus Lerdorf, the inventor of PHP, once said with regards to foursqaure (build with scala/lift) that it's the first site for a long time that doesn't have a single security hole he could find.
If you're having trouble enumerating the reasons why you'd use scala/lift over PHP, you'll probably want to stick with PHP. PHP is a far more mature and supported platform - oodles of documentation, huge community, tons of tools and libraries.
Scala is a great language, but the primary reason it's being used by Twitter and Foursquare is it's ability to work with enormous sets of data on a horizontally scaled architecture. These are very specific problems for these companies, and Scala was chosen for this purpose very deliberately.
As someone who has recently begun learning Scala, the community and documentation is minute compared to PHP's. Especially where Lift is concerned. And things like IDE support is still in it's early stages.
There's really no way to compare the two technologies (very different approaches). If want to use Scala, use it, but you'll probably be investing more time and energy if you're not already proficient (also, some background in Java doesn't hurt). PHP is just PHP, it's so easy to just pick up and use.
If you ask such a question you'd better stay with PHP. Once your project becomes more and more complex and you are fed up with PHP limitations the question will disappear on its own.
But Lift does not have to be the framework of your choice.
You should consider anything except PHP a good language for web applications, but Scala is a pretty excellent one, although it will change the way you think about programming as a whole. Some people can't handle that, so be warned.
PHP advantages:
Is installed even on the cheapest "5ยข-a-month" webhoster.
PHP disadvantages:
The libraries are not stable and change every now and then, often without notice.
The whole language is buggy and generally doesn't work as a sane person would expect.
The documentation is unusable, sometimes wrong, sometimes only understandable with the user supplied usage examples (which are often wrong or not optimal, too).
No quick way to see the implementation of some language-supplied code.
The API is one big mess ... this shouldn't be called API, it should be called MCOBRIM: Messy Collection of Buggy, Random and Ill-named Methods.

Localization as an afterthought-- screwed? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
So I signed on with a startup web development company as a subcontractor. They are putting together a large, complex user/product management system for a company that needs to support multiple levels of hierarchial localization. I signed a 3 month contract, and upon looking at their code, wish I hadn't.
They opted to write their own MVC framework (I guess the client company didn't want to use a prewritten one) and it's extremely poorly written. There's SQL scattered throughout almost every model view and controller (and there's no parameter-based find methods, it's all SQL) and they haven't even THOUGHT about localization yet-- something that will have an affect on nearly EVERY query.
The due date is 4 months away, and I honestly think we'd make good progress by scrapping the whole thing and going with CakePHP. Have any of you been in a similar situation, and what did you do?
PS: This is written in PHP/MySQL.
Rewriting from scratch is almost always the wrong idea (Read Joel's article Things You Should Never Do -- Part 1). But you have to start implementing small changes (big in your case). The sooner you get the code cleaned up the better it is for developing in... Get a sane data access layer and try to sort out the ad-hoc MVC first.
Also, while you are fighting battles, start planning out what needs to happen and get the upper brass used to the idea that some features might not make it in. I don't know your code base, or big or how messy it is... but if it is really bad then they should be prepared to ship a product minus some features rather than a half-baked solution.
Take charge on these issues, you (like the rest of us) get the pleasure of inheriting the sins of a codebase's previous owners. Is there any chance they would extend the contract or pay overtime for extra work you put in?
When you work for someone, you play by their rules. I've worked on a couple of sites using Expression Engine. I hated every minute of it, and I strongly recommend against it every time it comes up with my client, but what can you do, other than grind through the work until you're done?
Feel free to offer the suggestion about CakePHP, but I would drop it if nobody wants to hear it. Be happy you're only on for 3 months.

Categories