coding standards – Does a third-party module need to implement hook_help()?

After having spent hours reading through (very old) coding standards and best practices threads on drupal.org, and even trying to revive the Contrib Development Best Practices group on groups.drupal.org which seems to having been abandoned for years, I’m still struggling to getting an answer to whether a third-party module needs to implement hook_help() to comply with the Module Documentation Guidelines or not.

Above guidelines state

All but the most trivial modules should implement hook_help().

Yet, should is not must, which sometimes leads to discussions within the Security Advisory Application Issues Queue.

I was not able to identify someone to ask, whether it is a requirement or a (strong?) suggestion.

As we’re currently reworking the PAReview (pareview.sh) tool, it would be great to know for having a distinct severity for a missing hook_help(). That’s why I’m hoping to getting a hint from the grey-bearded Drupalists here, on where to address this inquiry.

Don’t get me wrong, I don’t want to start a discussion here, nor subjective answers on whether there should be a hook_help or not. I just want to know which board is deciding such issues and where to ask when it comes to contrib module coding standards and best practices.

coding style – Variable name re-use: can it be a good thing?

Famously, from how to write unmaintainable code, it is said unmaintainable code reuses variable names:

Wherever the rules of the language permit, give classes, constructors, methods, member variables, parameters and local variables the same names. For extra points, reuse local variable names inside {} blocks. The goal is to force the maintenance programmer to carefully examine the scope of every instance. In particular, in Java, make ordinary methods masquerade as constructors.

I understand how this can be abused, but I’ve seen very readable code make good use of this technique. Generally that code has small method bodies, and the name is consistent, in that it always represents the same effective object (although it may be normalized or transformed in each step, or maybe a default value that was overridden). Often there is also only one object that matters in the method (so the code follows single-responsibility principles well).

However, I can’t remember any concrete examples of this from well-regarded open source, although I have seen them. Anyone have some examples that demonstrate how to use this technique well, and how it may be clearer than alternatives? Pull requests that refactor in this direction with notes as to why would be especially good answers.

coding style – Are there published guidelines, standards, or references that propose unlimited chars per line?

In general, you want to make your code readable. This means that the amount of characters on one line is up to you, your organization that you work for, or your professor if you are in school.

If you have an ultra wide monitor and you are developing your own code for your own project, then it is completely up to you.

Here is a link that talks about line widths that can be too wide making it difficult for the person reading the code/text to understand: https://baymard.com/blog/line-length-readability

There is no concrete answer to this question. Use your best judgement.

Identify and explain five (5) new developments in coding and information theory that sit at the intersection of combinatorics and complexity [closed]

  • coding theory
  • Differential entropy and continuous channel capacity.
  • Error detecting … IT 2000-8, slide
    +5 Other properties : correction of single errors, detection of double errors.
  • We would like to maximize the code rate under the reliability constraint Pe ≤ 10. −15
    +In both cases, we can identify erronous bit. defined ∀m, n = 1,2,.

plugins – A clarification regarding using ACF vs. just using WordPress and coding things yourself

I hope this isn’t off topic but I keep coming across companies who specifically WANT you to use ACF to build custom functionality and I’ll be honest, I don’t get it. I don’t get why.

Here’s an example:

Company wants you to develop a CPT, enqueue a slider library and use that for the output, and then…

Use Advanced Custom Fields to create the three slider image fields

Now, doing this without ACF would take me about 15-20 minutes.

With regards to complexity and capability, with everything else being asked of the developer, having to rely on ACF to build the fields seems regressive?

Does anyone know what the benefit of using ACF would be here? What am I missing?

algorithm – C++ Coding Exercise – Maximum unit to load into a truck given it size

You are assigned to put some amount of boxes onto one truck. You are given a 2D vector of box_types where box_type(0) is the number of a type of box and box_type(1) is the units per box for that type. You are also given an integer value for the truck size, this the maximum boxes you can put in the truck. Return the maximum unit that can be put in a given truck.

Example

input : box_types = {{1, 3}, {2, 2}, {3, 1}}
truck_size = 4

output: 8

Explanation:

There are

  • 1 box of type 0
  • 2 box of type 1
  • 3 box of type 2

where 0, 1, 2 is the index of the vector

You can take all the boxes of the first type, second type and one box from the third type

max_unit = (1 * 3) + (2 * 2) + (1 * 1) = 8

Here is my implementation

#include <iostream>
#include <algorithm>
#include <vector>

void sort_boxtypes(std::vector<std::vector<int>> &box_types)
{
    std::sort(
        box_types.begin(), box_types.end(), 
        ()(const std::vector<int>& a, const std::vector<int> &b)
        {return a(1) > b(1); }
    );
}
int maximum_units(std::vector<std::vector<int>> box_types, int truck_size)
{
    sort_boxtypes(box_types);
    int max_unit = 0;
    for(const auto& box_type : box_types)
    {
        truck_size -= box_type(0);
        if(truck_size >= 0)
            max_unit += box_type(0) * box_type(1);
        else
        {
            max_unit += (box_type(0) + truck_size) * box_type(1);
            return max_unit;
        } 
    }
    return max_unit;
}

int main()
{
    std::vector<std::vector<int>> box_types = {{5, 10}, {2, 5}, {4, 7}, {3, 9}};
    int max = maximum_units(box_types, 10);
    std::cout << max << 'n';
    
}


coding style – Standarized prefixes for naming REST POJO (Correct or not correct)?

We are building a software application for a client with a particular naming convention for REST services.

For example if you use a POJO for your request or response in a REST service something like that:

public class Document {
    private String codeDocument;
    private String codeParentDocument;
    private Double amountPayed;
    private String nameOwner;
    private String descriptionDocument;
}

Your REST contract should be so:

{
  "codDocument": "123",
  "codParentDocument": "123",
  "amtPayed": 25.5,
  "desDocument": "owner"
}

This is an example because there a list of many prefixes. This prefixes are used by the organization as convention for its database fields.

I think They want to have some type of homologation between its REST contract and its tables. Another reason could be the fact REST contract in some occasions has many fields and it could cause confusion. Therefore prefix would help to people to distinguish the meaning of a particular field among of many other fields. They could know if a field is a description, amount, code, etc…

But…I recognize that in some occasions this prefix are redundant. For example codeDocument could be simply code. Another example is with DNI (Identity National Document). It should be defined as dni but people from client prefer to use numberDni. DNI is a number, is redundant put the word “number” before…

Another minor problem is many applications from the client use this standard. We would be the only one with get out from the their standards.

I consider that use prefix is not correct but I would like have other opinions and if possible more arguments to convince to my client of my project. Thanks a lot (Y)

object oriented – I want java coding OOP mean I want code using Classes, Encapsulation, Constructors, Inheritance and Array list

The second level of training contains practical work on programming using Java, and ‎focuses on implementing basic algorithms in code using IDE, your training should go ‎as follows:‎
‎1.‎ To start the technical part, you should start by showing a suitable IDE for your ‎trainees
‎2.‎ Then, create a discussion with the attendees to criticize development using IDEs ‎in comparison with not using one.‎

Now, you’ll give them practical training by giving them a small programming project, ‎the following is the project description: ‎
Create a library system with the following specifications: the library has a name, number ‎of employees, manager name, and location. Also, the library consists of five sections: ‎human studies, science, mathematics, information technology, and history. Every ‎section contains books, every book has a serial number (number), title, number of ‎pages, author name, and publisher name. Identify and Implement all the needed ‎classes according to the mentioned requirements.‎
After you make sure all the project details are clear, you need to help your attendees to ‎implement a sorting algorithm to sort books (Ascending) in every section, implement the ‎algorithm in two ways, sort by serial number, and sort by book title. ‎

public static library(){
NumOfEmployee;
ManagerName;
location;
}

**package library;

public static ‎human studies {

}**