X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (X-Cart 5) (https://forum.x-cart.com/forumdisplay.php?f=56)
-   -   Decorator logic (https://forum.x-cart.com/showthread.php?t=77341)

vasilis 11-13-2019 12:46 PM

Decorator logic
 
I have been reading about the Decorator logic in the old LiteCommerce software, in this page where there is the following text:

Quote:

Decorator's primary purpose is to support the extensibility of the functionality through class inheritance. In particular, solving the problem described in the previous chapter. It renames classes in the inheritance chains so that the application begins to use the extending class too. Suffix “Abstract” is appended to the base class name, and an empty dummy class with the original base class name is inherited from the custom class. Example:

Core code: SomeCoreClass (base class) -> SomeCustomClass extends SomeCoreClass (custom class)

Generated cache: SomeCoreClassAbstract (renamed base class) -> SomeCustomClass extends SomeCoreClassAbstract (custom class) -> SomeCoreClass extends SomeCustomClass (blank dummy class)

Thus, the functionality of the custom class gets into the base (modifyable) class.

Does the same logic exist for X-Cart 5 as well, or has it changed ?

cflsystems 11-13-2019 04:40 PM

Re: Decorator logic
 
Forget about this LiteCommerce code there. This is what XC started at first and based all XC5 on it. That's why XC5 code is full with 'LC' references.

However in general yes this also applies to XC5.

I'd suggest to start here - https://en.wikipedia.org/wiki/Decorator_pattern - and similar articles. Also examine the code under classes and same under var/run/classes to see how it is done.

vasilis 11-13-2019 10:49 PM

Re: Decorator logic
 
Steve, I have actually read quiet a few stuff about PHP patterns and especially Decorator, Singleton, Factory patterns from a couple of books and various articles. (To anyone seeking to delve into PHP patterns, I would highly recommend the 'PHP Objects, Patterns, and Practice', Apress 3rd Edition by Matt Zandstra and the 'Learning_PHP_Design_Patterns' by William Sanders, O'Reilly editions). Also the specific wikipedia article that you suggested, has a nice schematic on the decorator pattern and a comprehensive definition.
Quote:

However in general yes this also applies to XC5.
so this logic applies to XC5 in general. Actually, I reckon that these LiteCommerce developer articles in GitHub are good articles for someone to start delving into the programming logic of XC5 and then go on to the developers's - unfortunately fragmentary - knowledgebase articles, in x-cart's site. These articles are characterized by more or less recipe-type of presentation, rather than presenting the full logic in a structured way, in contrast to the developer's knowledgebase presentation of other popular eCommerce platforms.

Quote:

Also examine the code under classes and same under var/run/classes to see how it is done.
One thing I noticed is that the cached code has various view classes for example of it's modules renamed, with the suffix 'Abstract' added to their name, as described in the LiteCommerce dev. articles. I will search for any other differences between the two codes, if this is what you mean.


All times are GMT -8. The time now is 04:09 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.