BACKGROUND / IDEA
I am currently working on a small framework just to improve my php-knowledge. This framework should be very simple (minimizing overhead) and flexible in terms of later expansion.
DIFFERENT MEANINGS
As a result of reading more advanced tutorials, notes of serious php-developers, different class structures (singletons, Singletons, dependency injection, JIT, …), oop, mvc, routing, caching… and a lot more I find it very difficult to filter “the proper way” (if there is one) as it seems to me that everyone says something different.
Many people praise there opinon as “the best” and say that everything appart from that is evil. In my oppinion there is not a right or false. There are just several ways to achieve one’s goal.
WHAT I DID SO FAR
- index: ini settings, define constants, call bootstrap (not oop)
- booting: autoloader class, namespaces (include files on demand)
- static classes: htmlManager, fileHandler, databaseManager, …
- singletons: none
- non-static classes: controller, models, views, routes, …
I know that this is very basic and I did not that much so far but I want to create a solid platform first.
QUESTIONS
Before I want to go any further in my project I’d love to hear your opinion on the things listed below.
- How do you organise/structure small or even bigger projects?
- What are your experiences concerning simplicity, logic, performance, readability, expandability and reusability of code?
- Is there really a “proper way” of coding or it this just interpretation?
- Is there anything one should not use because it is already obsolete?
WHAT I DON’T WANT TO HEAR
- Forget about a framework or php
- Don’t do this, don’t do that without naming the reason why
Many thanks in prior for every response I get.
Go for it.
That’s because some people don’t have an understanding why something should be solved in a certain way or why something is terrible practice, but they see something on some framework and they think it’s the best thing since sliced bread.
Although opinions may differ, you cannot argue with clean code and proper OOP if that is what you are after. In proper OOP singletons and
statics have no place. Also what most people call MVC is actually some wrong view on the pattern (mostly because again they have seen some framework do it some way). Which is not always bad, but it is not MVC.Not everything that isn’t the best is terrible in my opinion. But some stuff is just bad practice. And some pattern are defined in a way to make your applications easier to maintain, debug and test. If you are going to implement some other pattern that’s all fine with me, but you will loose the benefits of some other pattern.
Generally speaking the first rule of thumb I use when doing OOP programming is following the SOLID principles.
These have no place in proper OOP. Amongst others because the will tightly coupling the classes. Which make maintainability, readability and testability a pain.
Good, because they are just a fancy
global.Separation of concerns in both code as structure. One of the pattern can help you with that: MVC, MVP, [MVVM](Model View ViewModel). For me personally I like the MVC pattern the most because it has some nice benefits against other patterns.
Readability and testablity are the most important.
Right after that SOLID (which is also handled by the first point (overlap))
As I stated before: Just go for it. Do it and screw it up! Best way to learn is actually doing it and making terrible mistakes. I think the framework I made 1 year ago (although imho still better than 90% of what is out there) is a proper piece of crap ™.