New articles Năng lực quản lý: nhân tố thứ năm     ♥ Lựa chọn mục tiêu cuộc đời     ♥ 10 bí quyết cân bằng công việc và gia đình     ♥ Cô đơn trên mạng     ♥ Chứng khoán: Giấc mơ và ác mộng     ♥ Tám     ♥ Những tính năng của blog VnVista     ♥ Các mạng xã hội thống trị Google     ♥ Điều gì tạo nên một giám đốc công nghệ thông tin giỏi?     ♥ Cố gắng xóa bỏ những ấn tượng xấu     ♥ Cần một cách làm ăn mới     ♥ Tiếp thị hướng đến doanh nhân     ♥ Đưa cửa hàng thật lên chợ ảo     ♥ Bí quyết quản lý các nhân viên trẻ     ♥ Một số câu hỏi phỏng vấn “đặc biệt” của Microsoft     ♥ 4 bài học thành công trong kinh doanh     ♥ Tạo dựng hình ảnh một cô gái trẻ chuyên nghiệp     ♥ Góc “khác” của thế giới online đêm     ♥ Phong cách người Mỹ     ♥ Chỉ nghĩ đến tiền cũng làm người ta ích kỷ     
New blog entries SHEET Chỉ chừng đó thôi      ♥ NHỮNG REVIEW HÚT MỠ BẮP TAY THỰC TẾ      ♥ 自己破産 大阪市      ♥ Hướng dẫn cách viết hóa đơn bán hàng cho HKD      ♥ Dịch vụ làm visa Áo (Austria) diện du lịch, công t      ♥ Những con số "siêu khủng" trong vụ án Vạn Thịnh Ph      ♥ を超え 10      ♥ SHEET Xin dìu nhau đến tình yêu      ♥ Ích mẫu thảo dược liệu là gì?      ♥ Doanh nghiệp không phát sinh doanh thu      ♥ Hồ sơ điều chỉnh lại quyết toán thuế TNDN      ♥ SHEET Trên công trường rộn tiếng ca      ♥ Địa chỉ sửa tivi Samsung Giá rẻ Tại Hải Phòng      ♥ SHEET Trò chơi      ♥ toptayninhvnn      ♥ SHEET Trống cơm      ♥ Tủ đồ nghề xưởng gara 3 ngăn      ♥ HÚT MỠ TOÀN THÂN KHÔNG PHẪU THUẬT AN TOÀN      ♥ HÚT MỠ NỌNG CẰM CÓ HIỆU QUẢ KHÔNG?      ♥ SHEET Em là chiến sĩ Điện Biên      
 
Reply to this topicStart new topicStart Poll

Liệt Kê · [ Bình Thường ] · Tách Biệt+

Programming Best Practices


sônkimkam
post Mar 28 2018, 10:13 AM
Gửi vào: #1
No avartar

Group Icon

Nhân viên
**
Thành viên: 75,055
Nhập: 5-March 18
Bài viết: 22
Tiền mặt: 272
Thanked: 0
Cấp bậc: 3
------
------
Xem blog
Bạn bè: 0
Thêm vào nhóm bạn bè
Gửi thiệp điện tử
Trang thông tin






user posted image

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.


--------------------
Nhóm bạn bè:

Thành viên này chưa có người bạn nào trong mạng VnVista, nếu bạn muốn trở thành người bạn đầu tiên của thành viên này, hãy click vào đây


Cảnh cáo: (0%)----- 
Nếu bạn thấy bài viết này vi phạm nội quy forum, hãy click nút này:
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

Thank you! Reply to this topicTopic OptionsStart new topic
 

Bản Rút Gọn Bây giờ là: 29th March 2024 - 03:16 AM
Home | Mạng xã hội | Blog | Thiệp điện tử | Tìm kiếm | Thành viên | Sổ lịch | Xem phim online chất lượng cao