I have a challenge for ZF2

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

I have a challenge for ZF2

dennis-fedco
I have this existing application with existing feature for product X.  You select product options from menu options and it generates a PDF.  Code that runs this spans throughout a 6000-line technology soup PHP file collection.  It is a complex intertwined procedural/oo aplication (600K lines) that uses outdated and questionable programming practices, has no clear separation of components, and more so represents files spanning thousands of lines of php code with SQL, HTML, jQuery, and CSS, with functions all rolled into one.  Each file calls functionality in some other file, and tracing a single feature through these can be quite an exercise (thereby creating its own entangled architecture of sorts).  It is somewhat modularized, but not in a ZF2 module sense.  To call a certain module, you can say router.php?m=<module_name>, which effectively calls a certain file.

My task is to make this work with a new product Y that uses different parameters and different custom computations to create the PDF for Y.

Original intent was to rewrite this entire application in ZF2, but this is prohibitive at the moment due to the customer needing functionality *now*, and re-architecting this app in ZF2 will probably take years.  

Normally, I would Copy and Paste code that runs X into some place and call it Y, and then go over the copied code and change parameters and computations accordingly, to make feature Y work.  Problems:  code duplication, code divergence, lack of testing, no DI, no separation, etc.

So here is the challenge -- I want to take steps towards ZF2, and ZF2 can call any existing code ...  but ... how?    

Do I just create an "empty facade" ZF2 wrapper around these files?  Maybe create custom routing that somehow works seamlessly with existing application?  These are not cleaned up library code files, these are actual business logic files, embedded in long spaghetti code PHP .  Putting a ZF2 facade around them seems a bit superfluous as it won't magically make them a ZF2 application, but maybe is a start.  I am not entirely sure HOW to ZF2-ize my task, or if it will be good to do it in the first place.  I think I may just succumb to copy and paste approach and fail to take steps towards ZF2, unless there is some sort of a nice solution that I can implement here that hopefully will not take too much time when compared to the copy and paste approach.  

Do I try to ZF2-ize this app or just forget about it?  What if something else, like decoupling/organizing/refactoring this application is a better mindset to take in the long term, in a sense preparing the codebase for ZF2 instead of thinking about ZF2-ing it from the get go?
Reply | Threaded
Open this post in threaded view
|

Re: I have a challenge for ZF2

Malte Riesch
wow, seems you have some task cut out there....

I suppose the best approach depends on what the expected life-time of
the application is, if it needs to work for some time still and
especially if there are more features likely to be added, in this case
to zf2-ize it makes sense (to me) because otherwise the technical debt
is just going to grow..and grow...

In the past when confronted with spaghetti-legacy-code applications and
having had to add functionality to it, or fix bugs, I found a carefully
exercised test-driven approach useful..

If it's of any interest, here's a link to a book that I found personally
quite insightful in regard to this as it is all about test-driven
refactoring of legacy code (it's also available on safari books):

http://www.amazon.co.uk/Working-Effectively-Legacy-Robert-Martin/dp/0131177052


I suppose it comes down to analyzing risks and benefits...

hope this helps at all, good luck!


On 11/02/14 16:18, dennis-fedco wrote:

> I have this existing application with existing feature for product X.  You
> select product options from menu options and it generates a PDF.  Code that
> runs this spans throughout a 6000-line technology soup PHP file collection.
> It is a complex intertwined procedural/oo aplication (600K lines) that uses
> outdated and questionable programming practices, has no clear separation of
> components, and more so represents files spanning thousands of lines of php
> code with SQL, HTML, jQuery, and CSS, with functions all rolled into one.
> Each file calls functionality in some other file, and tracing a single
> feature through these can be quite an exercise (thereby creating its own
> entangled architecture of sorts).  It is somewhat modularized, but not in a
> ZF2 module sense.  To call a certain module, you can say
> router.php?m=<module_name>, which effectively calls a certain file.
>
> My task is to make this work with a new product Y that uses different
> parameters and different custom computations to create the PDF for Y.
>
> Original intent was to rewrite this entire application in ZF2, but this is
> prohibitive at the moment due to the customer needing functionality *now*,
> and re-architecting this app in ZF2 will probably take years.
>
> Normally, I would Copy and Paste code that runs X into some place and call
> it Y, and then go over the copied code and change parameters and
> computations accordingly, to make feature Y work.  Problems:  code
> duplication, code divergence, lack of testing, no DI, no separation, etc.
>
> So here is the challenge -- *I want to take steps towards ZF2*, and  ZF2 can
> call any existing code
> <http://zend-framework-community.634137.n4.nabble.com/Best-Practices-on-incorporating-non-OO-non-ZF2-code-into-ZF2-app-tp4661601p4661602.html>
> ...  but ... how?
>
> Do I just create an "empty facade" ZF2 wrapper around these files?  Maybe
> create custom routing that somehow works seamlessly with existing
> application?  These are not cleaned up library code files, these are actual
> business logic files, embedded in long spaghetti code PHP .  Putting a ZF2
> facade around them seems a bit superfluous as it won't magically make them a
> ZF2 application, but maybe is a start.  I am not entirely sure HOW to
> ZF2-ize my task, or if it will be good to do it in the first place.  I think
> I may just succumb to copy and paste approach and fail to take steps towards
> ZF2, unless there is some sort of a nice solution that I can implement here
> that hopefully will not take too much time when compared to the copy and
> paste approach.
>
> Do I try to ZF2-ize this app or just forget about it?  What if something
> else, like decoupling/organizing/refactoring this application is a better
> mindset to take in the long term, in a sense preparing the codebase for ZF2
> instead of thinking about ZF2-ing it from the get go?
>
>
>
> --
> View this message in context: http://zend-framework-community.634137.n4.nabble.com/I-have-a-challenge-for-ZF2-tp4661664.html
> Sent from the Zend Framework mailing list archive at Nabble.com.
>



-----------------------------


Registered Office: 15 Stukeley Street, London WC2B 5LT, England.
Registered in England number 1421223

This message is for the designated recipient only and may contain privileged, proprietary, or otherwise private information. If you have received it in error, please notify the sender immediately and delete the original. Any other use of the email by you is prohibited. Please note that the information provided in this e-mail is in any case not legally binding; all committing statements require legally binding signatures.


http://www.weareifp.com




--
List: [hidden email]
Info: http://framework.zend.com/archives
Unsubscribe: [hidden email]


Reply | Threaded
Open this post in threaded view
|

Re: I have a challenge for ZF2

dennis-fedco
hmmm .. looking at the situation .. the lifetime of the project is ongoing and more features will be requested well into the foreseeable future.

It might just be the case of "It works... put up with it".  I think it is possible to do some minor incremental rewrites, cleanups and adding some unit testing along the way, while working on the application.  This will  take quite a while, and when completed, will not get the app into ZF2 world.  ZF2 requires a paradigm shift and a redesign of the architecture.  Incremental clean up will not get it there.  I am thinking it may be a good idea to abandon trying to ZF2-ize the application, and instead use ZF2 for new smaller projects, ... should there be a need for ZF2 and new projects.
Reply | Threaded
Open this post in threaded view
|

Re: I have a challenge for ZF2

stormwild
In reply to this post by dennis-fedco
I was thinking why not continue to work with the existing application and
then also allocate time to recreate it using ZF2?


On Wed, Feb 12, 2014 at 12:18 AM, dennis-fedco <[hidden email]>wrote:

> I have this existing application with existing feature for product X.  You
> select product options from menu options and it generates a PDF.  Code that
> runs this spans throughout a 6000-line technology soup PHP file collection.
> It is a complex intertwined procedural/oo aplication (600K lines) that uses
> outdated and questionable programming practices, has no clear separation of
> components, and more so represents files spanning thousands of lines of php
> code with SQL, HTML, jQuery, and CSS, with functions all rolled into one.
> Each file calls functionality in some other file, and tracing a single
> feature through these can be quite an exercise (thereby creating its own
> entangled architecture of sorts).  It is somewhat modularized, but not in a
> ZF2 module sense.  To call a certain module, you can say
> router.php?m=<module_name>, which effectively calls a certain file.
>
> My task is to make this work with a new product Y that uses different
> parameters and different custom computations to create the PDF for Y.
>
> Original intent was to rewrite this entire application in ZF2, but this is
> prohibitive at the moment due to the customer needing functionality *now*,
> and re-architecting this app in ZF2 will probably take years.
>
> Normally, I would Copy and Paste code that runs X into some place and call
> it Y, and then go over the copied code and change parameters and
> computations accordingly, to make feature Y work.  Problems:  code
> duplication, code divergence, lack of testing, no DI, no separation, etc.
>
> So here is the challenge -- *I want to take steps towards ZF2*, and  ZF2
> can
> call any existing code
> <
> http://zend-framework-community.634137.n4.nabble.com/Best-Practices-on-incorporating-non-OO-non-ZF2-code-into-ZF2-app-tp4661601p4661602.html
> >
> ...  but ... how?
>
> Do I just create an "empty facade" ZF2 wrapper around these files?  Maybe
> create custom routing that somehow works seamlessly with existing
> application?  These are not cleaned up library code files, these are actual
> business logic files, embedded in long spaghetti code PHP .  Putting a ZF2
> facade around them seems a bit superfluous as it won't magically make them
> a
> ZF2 application, but maybe is a start.  I am not entirely sure HOW to
> ZF2-ize my task, or if it will be good to do it in the first place.  I
> think
> I may just succumb to copy and paste approach and fail to take steps
> towards
> ZF2, unless there is some sort of a nice solution that I can implement here
> that hopefully will not take too much time when compared to the copy and
> paste approach.
>
> Do I try to ZF2-ize this app or just forget about it?  What if something
> else, like decoupling/organizing/refactoring this application is a better
> mindset to take in the long term, in a sense preparing the codebase for ZF2
> instead of thinking about ZF2-ing it from the get go?
>
>
>
> --
> View this message in context:
> http://zend-framework-community.634137.n4.nabble.com/I-have-a-challenge-for-ZF2-tp4661664.html
> Sent from the Zend Framework mailing list archive at Nabble.com.
>
> --
> List: [hidden email]
> Info: http://framework.zend.com/archives
> Unsubscribe: [hidden email]
>
>
>


--
------------------------------

Alexander R. Torrijos
Web Developer
Mobile: +63 919 991 5653
Res: +63 2 822 7219
http://alex.stormwild.com
Skype/YM: artorrijos

------------------------------
Reply | Threaded
Open this post in threaded view
|

Re: I have a challenge for ZF2

Stefano Torresi
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: I have a challenge for ZF2

dennis-fedco
In reply to this post by dennis-fedco
How about this?

I will be doing rewriting, and refactoring. I will be going towards *some kind of framework*.
But ... Hey ! I *might as well* go towards ZF2.
HOW exactly I will do that is unclear right now. I know that ZF2 can be used as not-a-framework (aka classes used separately), and that classes can also be used as a framework.

Hence, I propose an idea for a colossal rewrite towards ZF2:
  • Step 1: start using ZF2 directory structure where I can, even what's inside of it may be a big huge mess
  • Step 2: start separating controllers, Model code and View code into its proper directories and folders, as convenient.
  • Step 3: continue to modularize, class-ifize, and SOLID-ifize the code, until further ZF2 things become possible
Whether it's worth the effort to go towards ZF2, or just towards some kind of framework is worth considering further.
Reply | Threaded
Open this post in threaded view
|

Re: I have a challenge for ZF2

dennis-fedco
I gotta give it up for projects that put everything together with no separation.

it is all right there!

You want to change CSS?  It's right there in the file!
HTML?  Sure it's right there where you are editing it!
SQL?  It's right here dude!
jQuery?  Same thing!
All in one file!
You can have this feature done in no time, just editing one file and be done with it!

Writing this in ZF2?
I'd have to go to at least 7 different files for a single feature.  And that's one thing I do NOT like about ZF2.  It is a click-and-chase file-golf.  While doing ZF2 labs - 40% or more of my time was hunting down the proper files and clicking on them and scrolling to the right spot.
Reply | Threaded
Open this post in threaded view
|

Re: I have a challenge for ZF2

Matt Kynaston
In reply to this post by dennis-fedco
On 13 February 2014 18:28, dennis-fedco <[hidden email]> wrote:


> Hence, I propose an idea for a colossal rewrite towards ZF2:
> Step 1:  start using ZF2 directory structure where I can, even what's
> inside
> of it may be a big huge mess
> Step 2:  start separating controllers, Model code and View code into its
> proper directories and folders, as convenient.
> Step 3:  continue to modularize, class-ifize, and SOLID-ifize the code,
> until further ZF2 things become possible
> Whether it's worth the effort to go towards ZF2, or just towards some kind
> of framework is worth considering further.
>

Yes, that's basically how I started moving a large project across to ZF1 a
while back. It's not easy, but can be done in smaller steps.

But you don't mention tests. Do you have any? If not, start writing them -
you can't refactor like this without knowing what you've broken.

Matt
Reply | Threaded
Open this post in threaded view
|

Re: I have a challenge for ZF2

dennis-fedco
Matt

why did you decide to go towards ZF1 then?  Why not a homegrown framework, or "whatever framework the code happens to fall into as I refactor"?

And how is that project doing now?

Tests, yeah.  I am not there yet but I have been thinking about how to test that code.  I do not have much experience with this just yet.  I will probably create a tests directory, and start putting test scripts in there.  I imagine testing simple functions is easy and there are lots of examples out there for those, but testing convoluted stuff, like tightly coupled components, I imagine is harder.
Reply | Threaded
Open this post in threaded view
|

Re: I have a challenge for ZF2

Matt Kynaston
On Friday, 14 February 2014, dennis-fedco <[hidden email]> wrote:

> Matt
>
> why did you decide to go towards ZF1 then?  Why not a homegrown framework,
> or "whatever framework the code happens to fall into as I refactor"?


It was there, it provided solid components we could start to replace the
wild and wooly db classes, mailers, etc with. But above all it provided a
structure. When a contractor is confronted with spaghetti code they either
cut-and-paste it into an even bigger mess or start trying to write their
own framework (and fail).


>
> And how is that project doing now?


Two and a bit years in and there are still plenty of hairy bits left ;) But
no regrets - the product has a future it never had before.

Matt

>
>