From time to time it is a good idea to be quizzed regarding technical aspects of your profession by a colleague or someone your senior in experience. It helps you to be a better developer and helps you to prepare for the next steps in your career advancement by ensuring you know your stuff. The following questions are those that you might expect to run into in a Senior Level PHP interview. Have some more? Leave them in the comments.
What’s procedural programming vs object oriented program?
What are the benefits to using OOP?
What is polymorphism?
Polymorphism is a term in OOP that describes the ability for objects with different functionality to implement a common interface. An example of this could be a notification system that has multiple delivery methods. An interface is defined that designs/defines common methods between the deliverability methods, such as
What is encapsulation?
Encapsulation is used in OOP to hide certain properties or methods from a client. This is done to protect the integrity of the data within an object from being modified where it is not intended to be. Encapsulation is implemented through the use of abstract classes, interfaces as well as property and method visibility classifications.
What are the different property and method visibility classifications within a class?
When would you use each?
What’s the difference between and abstract class and an interface class?
When would you use each?
Explain how you would utilize abstract and interface classes in the following situation:
I need to build a notification system. The notifications can be of many different types. They may be text messages (SMS), push notifications, emails etc. To ensure that you are able to have a consistent code base that ensures maximum re-use.
What is another example of using abstract and interface classes, using something from your everyday encounters?
Vehicles: Class FordRanger extends the Truck abstract class which implements the Vehicle interface.
Within the Vehicle interface you may define methods such as
startEngine, etc. Within the Truck abstract class you would then implement these methods, or perhaps keep some of them abstract and define them within the FordRanger class if it differed between each truck.
Why are namespaces used?
How do you set a custom name for the reference if a conflict occurs?
What is static binding?
How do you access static variables?
When would you use static instead of self to access a variable?
What does the
final keyword do to a method and when would you use it?
What does the
const keyword do to a property and when would you use it?
What are traits? How/why are they used?
What are a few design patterns that you have experience with?
Can you explain the intention of each of them?
Can you explain an example implementation of each?
For each of those design patterns, which category of design pattern do they fall into?
(Behavioral, Creational or Structural)
What is type casting?
What is type hinting? How do you use it?
What is your level of experience and expertise with MySQL (enter other relevant data storage here)?
What are the different kinds of joins that are used within MySQL?
What does an OUTER join do?
What is the software design cycle?
Do you have experience with Agile development methodologies?
Can you briefly explain characteristics of it?
What is regression testing?
Regression testing is a type of software testing which verifies that software, which was previously developed and tested, still performs correctly after it was changed or interfaced with other software. Changes may include software enhancements, patches, configuration changes, etc.
What’s the difference between a monolithic app and a micro-service architecture?
When might you need to consider refactoring a class?
You can tell that a class is needing refactoring if it doesn’t pass what some call the “smell test”. Does the code stink? Then it doesn’t pass the “smell test” 😉 To put some actual detail behind that, when reviewing the class, are there a lot of switch statements or if/else chains that are handling several different cases that could perhaps be better structured via an inheritance/polymorphism structure? Perhaps you have a Product class that is currently handling different types of products using a switch or if/else, when it would be better served as each product type (single product, variation product, digital product, etc) having its own class that inherits and/or extends base classes that contain shared logic.