Would you agree this is the definition of a PHP framework?

No, I am simply echoing the description found in https://en.wikipedia.org/wiki/Software_framework

Nope, if you have to write code to call “it” then “it” is a library. If “it” calls code that you write then “it” is a framework. If your code controls the processing flow, then you are using a library. It “it” controls the processing flow, then “it” is a framework.

Yes. That is what abstract classes are supposed to be for, to define in one place all the methods which may be used in any of the concrete classes which inherit from that abstract class. The fact that my abstract class is bigger than anything which you have ever written simply means that I have created more sharable methods than you can possibly think of.

Martin Fowler’s description of a transaction script (see http://martinfowler.com/eaaCatalog/transactionScript.html) does not match my component scripts (see http://www.tonymarston.net/php-mysql/infrastructure.html#component.script). You need to actually READ both articles to understand why.

Your definition of SRP is totally skewed. It says that I should take a monolithic piece of code and break it into manageable modules with separate responsibilities, such as presentation logic, business logic and data access logic. This is EACTLY what I have done by implementing the 3-Tier Architecture. By going too far and breaking these modules into smaller pieces you will do nothing but end up with a fragmented system in which all unity is lost. My Model classes do not contain any control logic as that is held in, and only in, my Controllers. My Model classes do not contain any view logic as that is held in, and only in, my Views. My Model classes do not contain any data access logic as that is held in, and only in, my Data Access Objects. There are no methods in my Model class which do not belong in my Model class. There are no methods which I can move into other classes, and if I did move them I would end up with more code as I would have to instantiate another class before I could call any of its methods. Every competent programmer knows that having too many classes makes your code slower.

My framework is a mini-application insofar as you can “run” the framework, and there are online screens in the framework which allow you to generate new components for your application, and then run those components which have default behaviour until to insert code to do something different or extra. The framework therefore provides default behaviour which is of use to the application, but the processing flow is still controlled by the framework, which makes it a “true” framework and not a library.

Yes it does. You said nobody would need that feature. The only reason that I added that feature to my framework because customers (note the plural) specifically asked for it.

So you admit that you don’t care what the customers think of the software that you write provided that your fellow developers think that it is “cool” and “pure” and written to “proper” standards.

No it doesn’t, by virtue of the fact that you have to write reams of code yourself before you can do anything. After you have installed this thing-which-masquerades-as-a-framework, can you run it? Can you generate application components with it? Can you then run those components with it?

Wrong again. I never said that I don’t follow proper coding standards or best practices. I most certainly do, but they do not happen to be the same as the ones which you follow.

This is called “default behaviour” which is what a proper framework is supposed to supply.

Wrong again. If you have to write code to call “it” then “it” is a library. If “it” can call code that you write to change the default behaviour that “it” provides then “it” is a framework.

If they do not supply any code which the application can use as “default behaviour” then they are missing one of the prerequisites of a framework.

I would never have guessed that from your constant stream of vitriolic attacks. If you actually agree with some of the things that I have written, can you point them out so that I can change them? It is simply not the done thing to agree with ANYTHING that I say. :grinning:

It is important because once something has been defined, then nobody should be able to come along and change the definition to mean something else entirely. The fact that some programmers have created libraries which they call frameworks does not automatically make them frameworks. Some people could also attempt to claim that left is now right, up is now down and in is now out, but that would be very confusing and very wrong.

Suppose some clever-clogs comes along and tries to change the definitions of encapsulation, inheritance and polymorphism? How much confusion would that cause?

Where in that whole article is it stated a software framework will allow you to, “use default behavior without any code”?

Sounds like what Martin Fowler calls the Super Class smell/ anti-pattern.

I thought we were talking about your transaction pattern?

SRP says, a class should only have one responsibility and need to be changed for only one reason. Your 9000 line monster class has several reasons for changing. Some make sense, and some actually don’t.

So we agree. You are doing more than just a framework with your framework.

I took your comment as calling me a know-it-all and I said, I know I don’t know it all and never will. You, on the other hand, think you know it all or act like you do.

Where is all that in the definition of a software framework? Please point out in any definition of a software framework, where the client coder doesn’t have to code, where, when a framework is installed, it must run somehow (which today’s frameworks do, to a point), that a framework must generate components (which some of today’s frameworks also do) and run with them. Where is that defined?

Boy, you totally flew by the point. You said, “I don’t care about today’s coding standards…”, while the whole time you have been saying there are no coding standards or best practices. Now there are? How much of PHPtheRightWay do you agree with? Probably not much. That is a standard and it is full of best practices.

No, it is application code.

That is another new definition. Where can I find it in the definition of a software framework?

But they do supply a ton of “default behavior”. Authorization, authentication, session management, configuration management, DI container, routing system, etc., etc. The application / the client coder can use all of it, or none of it.

There isn’t too much I agree with, but I do agree with your conviction to not simply take everything at face value and to question the status quo. I also agree that it isn’t worth the effort to take a huge mound of legacy code and try to make something modern out of it. I’ve seen such an attempt fail miserably, partially because of the code, but mainly because the devs that attempted it just weren’t up to the challenge. And even if they would have been up to the challenge, the effort should have been put in rewriting the application from scratch. There are some people who say refactoring is always the best way to go, however, when the code is so old and the application not that complicated, then I feel a rewrite is better.

Scott

You mean like you do, when it comes to the definition of a software framework?

Scott

Totally agree on this. Again I stick with “Choose your paths wisely”. Know them and score the advantages and disadvantages


By the way who would you define the follow in terms of product / application / framework / language / library / component / “a thing” ?

  • Joomla
  • Drupal
  • SAP
  • .NET Framework (this one is interesting because of it’s name… :slight_smile: )
  • Html Foundation
  • Angular
  • Sharepoint

For me the framework [origin freym-wurk] is the a “skeletal structure designed to support or enclose something” , the “foundation for someone else’s use”. If there’s an english word for it, why redefine it? That base can be a collection of libraries, the language itself, the tools used or a mix. A framework is the “frame for my work”. So all of the above can be consider the framework of “my applications” and some of them also “applications”. Some of them have “default” behavior and are ready to be used by the customer (SAP, Sharepoint, Drupal, Joomla, for instance), and the same time are ready to be adapted and add extra behavior making it a new “application”.

This is so context sensitive that I ask you what defines an application ? Does a frontend to another app defines an application? Does an REST service qualify as an application? Just like @fretburner said, why does it matter? The boundaries are so thin and so context based that it is just not worth it.

Joomla - Application(with a system for extension)
Drupal - Application(with a system for extension)
SAP - Application(with a system for extension)
.NET Framework (this one is interesting because of it’s name… ) Collection of libraries for .NET
Html Foundation - Framework
Angular - Framework
Sharepoint - Application(with a system for extension)

That is how I’d judge them.

Scott

Feature #2 which says:

This clearly tells me that the framework must supply default behaviour which can be overruled with feature #3:

Now put this together with feature #1:

This tells me that the only code you should have to write is when you want to override the default behaviour which the framework provides.

You really ought to learn how to read. The very first paragraph in that article says the following:

If you had eyes in your head you will see that NOWHERE in my Model classes do you have to call the superclass before you run your code. Your claim is therefore totally bogus.

My description of a Transaction Pattern is nowhere near the same as Martin Fowler’s description of a Transaction Script. Read the two links and you will see the difference.

It is your interpretation of “one responsibility” and “one reason for change” that I am questioning. In his article http://blog.8thlight.com/uncle-bob/2014/05/01/Design-Damage.html Robert C. Martin says the following:

What he is clearly saying there is that you should separate out all GUI logic, Business logic and Data Access logic which is precisely what I have done by virtue of the fact that my framework is based on a combination of the 3-Tier Architecture and the MVC design pattern. That is all the separation that is needed, and that is all the separation that I have provided. By going any further you are going too far and turning a collection of cohesive modules into a collection of fragments where all unity is lost.

The fact that it does more than is absolutely necessary does not stop it from being a framework. It satisfies all four characteristics described in https://en.wikipedia.org/wiki/Software_framework so it IS a framework. Anything which does not provide all four of those characteristics does not deserve to call itself a framework.

I have never said that I know it all, just that I know enough. I know when to apply a pattern and when not to. I now when to separate a monolithic piece of code into cohesive modules and when to stop separating so that I don’t end up with a bunch of tiny fragments where all cohesion and unity is lost.

Look at my earlier reply in this post.

There are many places on the web which supposedly show “best practices”, but they can’t all be right.

Wrong again. The framework is supposed to supply default behaviour, not the developer. The developer should only need to write code when he wants to override or extend the default behaviour.

Read the Wikipedia definition which I have quoted several times. You do know how to read don’t you?

Yes, but if the developer has to write code to invoke this default behaviour then that does not follow the description of a framework. The developer should only have to write code to override or extend the default behaviour.

Yet when I have the audacity to question some of the things that YOU believe in all you can do is brand me a heretic for not following your interpretation of “best practices”. That sounds like hypocrisy to me.

I am not using my own personal definition of a framework, I am using the standard definition found in https://en.wikipedia.org/wiki/Software_framework

If you looked at https://en.wikipedia.org/wiki/Framework you would see that there are many different areas which can have things called “frameworks”, but it is wrong to assume that a definition from one area can be used as the definition in a totally unrelated area. For “software framework” I use te definition found in https://en.wikipedia.org/wiki/Software_framework

You keep linking to component script. Why?

Again, you are confusing SoC with SRP or rather using SoC to support your usage of a monster class, which is totally off.

The fact you call your framework a framework isn’t being debated. The fact you call your framework a framework and all other frameworks libraries is.

The frameworks you call libraries do fulfill the 4 characteristics.

I would have to disagree with you here.

It isn’t what I believe, but practically all good PHP developers.

Scott

You really have shot yourself in the foot this time. You claim that my Model classes, which all inherit from my “monster” abstract class, are examples of the “call super” anti-pattern. Not only are you wrong - which I have already addressed in a previous reply - but you completely failed to notice what is said in the third paragraph, which is supposed to be a solution to this anti-pattern:

If you bothered to try to read and understand my code you would plainly see that I have implemented a series of these “hook” methods. For example, take the following processing flow from my ADD1 pattern:

  1. The Controller calls the insertRecord () method in the Model object, which is defined within the abstract class. This then does the following
  2. It calls the -cm-getInitialData () method.
  3. It calls the -cm-pre_insertRecord () method.
  4. It calls the _validateInsert () method which performs default data validation.
  5. It calls the -cm-commonValidation () method.
  6. It calls the -cm-validateInsert () method.
  7. It calls the -dml_insertRecord () method which calls the DAO to update the database.
  8. It calls the -cm-post_insertRecord () method.

If so many words are too difficult for you, you may find it easier to look at a UML diagram at http://www.tonymarston.net/php-mysql/uml-diagrams.html#add1

All of the method names which begin with “-cm-” (note that the hyphens should be underscores, but this blog software converts text surrounded by two underscores into italics - what a bummer) are customisable methods which are called as part of the normal processing flow, but which are defined in the abstract class as empty methods which do nothing. To provide custom logic at any point in the processing cycle all the developer has to do is copy the empty method from the abstract class to his concrete class, then fill this empty method with relevant code.

So not only am I not guilty of using code which fits the description of this anti-pattern, I am actually following his description of a solution to this anti-pattern.

What do you think of THEM apples? I am not as stupid as you think, and you are not as clever as you think. You see things which do not exist in my code, and you do not see things which do exist in my code. Is it any wonder that I think that all your arguments are nothing but total hogwash? You are the one who has accused my Model class of being both examples of a “god” class which tries to do too much, and in another post (in this thread) you also accuse it of being an example of an anemic domain model which does practically nothing. These two accusations contradict each other, and if you knew what you were talking about you would see that neither of those accusations apply. My code fits halfway between “too much” and “not enough” which is “just right”. This is known as the Goldilocks Principle (see https://en.wikipedia.org/wiki/Goldilocks_principle).

I realise this is off-topic, but I think it’s an important question nonetheless:

@tony_marston404 Are there any parts of the Radicore codebase where, as time has passed, you’ve revisited and felt that you would do it differently now, because you’ve since learned there was a better way?

Nowhere did I say you are stupid.

That sounds pretty similar to what Martin says here and what you will find, when the smell is apparent:

The documentation (of the framework) says something like “to do your own thing, just subclass the process method. However it’s important to remember to start your method with a call to the super-class”.

You can come up with all the examples of what is right with your monster class as you’d like Tony. Having a 9000 LoC class is one thing you will never convince me is a good practice.

Scott

I use my framework in my major enterprise application which I am actively supporting and supplying to large corporations all over the world. I am constantly being asked, either directly by a customer or from my business partner whose business acumen far exceeds mine, to make additions to the application. Sometimes I can achieve this with code that customises the core product without affecting the core product, but sometimes I need to add new components to the core product. Sometimes I can do what is necessary within application code, but sometimes I need to change the framework code.

There was a situation a few weeks ago where a change to a customer’s requirements did not quite fit the capabilities of the software, and I had the choice of a “quick and dirty” solution and a “proper” solution. As well as being a follower of the “If it ain’t broke don’t fix it” principle I am also a follower of the “If a job is worth doing then it’s worth doing well” principle, so any ideas of a “quick and dirty” solution were consigned to the rubbish bin. I spent about three days refactoring my code so that I could provide this new requirement as an option within the framework.

There have been many similar situations in the past where I have had to modify the framework code, and I always make the effort to do a “proper” job and not a quick bodge. If I look at the code and I cannot see where the old code joins the new then I know that I have done a good job.

If, when looking at my code, I see a better way of doing something (note that “different” does not always equate with “better”) and I can make the change without breaking backwards compatibility, then I will go ahead and make the change. It also depends of how big the change is and what the benefits of the change are. Spending a penny to save £1 would be a good investment, but spending £1 to save a penny would not.

I agree completely with this! However, I’d reword it a bit.

If a job is worth doing then it’s worth doing to the best of your ability.

And I’d add to that,

Never overestimate your own abilities.

Scott

Read it again. What Martin wrote is nowhere near how my framework functions.

You simply aren’t getting it, are you? Nowhere in my framework does it say that the developer, when writing his own method, has to start it by calling the method in the super-class. The super-class contains calls to numerous methods, some of which are “hook” methods. These “hook” methods are defined in the abstract class, and when executed they do nothing. When the developer wants the framework to execute custom code at a particular point in the processing cycle all he has to do is identify the relevant “hook” method, copy that empty method into his concrete class, then fill it with the relevant code. At no point does he have to call a method in the super-class.

So you are claiming that I am not following SRP simply because my abstract class has 120 methods and 9000 lines? I am following Robert C. Martins definition of SRP, not yours. And I am also following the first rule of encapsulation which states that ALL the properties and ALL the methods for an entity should be placed in the same class, so if an entity NEEDS 120 methods and 9000 lines then that is what it needs. Breaking such a class into smaller units would therefore be breaking encapsulation.

You’ve not really answered my question. I’m not talking about making changes or additions to your code because of customer requirements. What I’m asking is, have you learned or grown as a developer over the previous 10 years to the point where you can look at your older code and realise that it could have been done better, irrespective of whether you actually update the code or not?

Because of what you wrote in post #30 where you linked my Transaction Patterns with Martin Fowler’s pattern called a Transaction Script. Even though I provided you with a link to http://www.tonymarston.net/php-mysql/dialog-types.html which, in the very first sentence, contains a link to http://www.tonymarston.net/php-mysql/transaction-patterns.html you could do nothing but point to http://www.tonymarston.net/php-mysql/infrastructure.html#controller.script

They mean exactly the same thing. If you take a monolithic piece of code and break into smaller modules, it doesn’t matter whether you say you are following SRP or SoC, the results will be the same. These two principles can only mean different things if the results of applying them are different.

If those other so-called frameworks do not have all the characteristics of a framework, as defined in that Wikipedia article, then they cannot call themselves frameworks.

On what basis? I have said that I apply SRP only as far as described in Robert C. Martin’s article, yet you keep insisting that I should go even further. Why should I follow YOUR advice instead of Robert C. Martin’s?

You mean practically all good PHP developers that you now about. I would also question your claim concerning “practically all” and “good” developers. On that basis you can claim that anyone who does not follow YOUR rules must, by definition, not be a “good” developer, in which case their opinion does not count.

The truth of the matter is that some developers hold one opinion, while numerous other groups of developers have numerous other opinions. Nobody can claim to speak on behalf of the majority of PHP developers, and anybody who tries to is a charlatan.

You forget that I had over 20 years of development experience in other languages before I switched to PHP so I had already learned an enormous amount, especially application design and framework design. The only thing I have learned over the last 10 years is that there are a lot of developers out there with peculiar ideas who try to pass themselves of as experts when, in my eyes, they are nothing but charlatans and snake-oil salesmen. I can spot good advice when I see it, but too much of what I see nowadays is plain rubbish.