You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After fixing a number of bugs in the Product Opener server code, I have been exposed to much of the Perl code base. I have enjoyed the opportunity to get to know the team and to write code to contribute to the project. However, I see a number of issues with the code as it exists now.
Here is a list of the some the things I have noticed:
Functions are too large and complex. Methods are often hundreds of lines of code in length and have large cyclomatic complexity with deeply nested conditional statements. This makes code difficult to read and understand, increases the risk of bugs, lessens code reuse, limits testing and makes debugging difficult. A good rule of thumb for method size is 15 lines.
Object Oriented programming is not used. Although there is a library of Perl .pm ’modules’ in the ProductOpener namespace, they only contain procedural functions. There are a great many advantages to OO code, I won’t go into them all here.
A good book to get your feet wet on OO would be: Head First Object-Oriented Analysis and Design
The classic text on OO which is always worth reading is: Design Patterns: Elements of Reusable Object-Oriented Software
Perl 5 has had OO support for a while, but it is a fairly weak implementation. It looks like the Moose extension is the current standard for object oriented Perl, see more below.
HTML and Javascript are directly generated in Perl code. This makes maintenance difficult for both server and client code. There are a number of ways to address this, e.g. templating as in HTML::Template
As APIs become more popular with patterns like micro services, consider building business logic first as JSON REST services. This will automatically provide APIs for users and then you can further decouple your front end and business logic by using a pure JavaScript front end like Angular, React, TypeScript to consume those same services.
Reduced risk of occurrence of new or regression bugs.
Easier debugging of problems.
Quicker development time
Improved testability
Code reusability
Improved performance
Lower cylomatic complexity
Ways to implement these changes:
Perl code should be written as object oriented with the Moose project. This will immediately realize all of the advantages listed above. Moose improves upon standard Perl OO by introducing type checking, custom types, and many other features. While I have not used Moose myself it looks like it is the latest preferred approach to OO Perl.
Document code, e.g. with Perl POD as you go along while coding. Perl POD can be automatically converted to HTML and put online.
Write tests for all code. The test coverage in OFF is decent ( better than many projects I have worked on) but it should be a priority.
Consider a new architecture: micro-service with pure JS front ends, etc.
Consider a more modern language. Java, Node, Python etc. would be options if we started this project today.
I understand the OFF is a large legacy project that was started long ago when many of these technologies did not exist and Perl was the best choice for web applications. With the upcoming development of the self-service platform by Stephane, now might be a good time to consider implementing some of these ideas to secure a healthy future for OFF.
After fixing a number of bugs in the Product Opener server code, I have been exposed to much of the Perl code base. I have enjoyed the opportunity to get to know the team and to write code to contribute to the project. However, I see a number of issues with the code as it exists now.
Here is a list of the some the things I have noticed:
A good book to get your feet wet on OO would be:
Head First Object-Oriented Analysis and Design
The classic text on OO which is always worth reading is:
Design Patterns: Elements of Reusable Object-Oriented Software
Perl 5 has had OO support for a while, but it is a fairly weak implementation. It looks like the Moose extension is the current standard for object oriented Perl, see more below.
HTML and Javascript are directly generated in Perl code. This makes maintenance difficult for both server and client code. There are a number of ways to address this, e.g. templating as in HTML::Template
As APIs become more popular with patterns like micro services, consider building business logic first as JSON REST services. This will automatically provide APIs for users and then you can further decouple your front end and business logic by using a pure JavaScript front end like Angular, React, TypeScript to consume those same services.
Code documentation is lacking, both exportable at the class and method level and inline within the code. See issue Document ProductOpener Perl modules. #2203
The advantages to implementing the above:
Ways to implement these changes:
I understand the OFF is a large legacy project that was started long ago when many of these technologies did not exist and Perl was the best choice for web applications. With the upcoming development of the self-service platform by Stephane, now might be a good time to consider implementing some of these ideas to secure a healthy future for OFF.