Today I Learned

06/08/2022

There is a list of The All-Time Top 150 i-Technology Heroes.

According to Steve McConnell, rapid development consists of balancing between four pillars:

  • Classic mistake avoidance
  • Development fundamentals
  • Risk management
  • Schedule-oriented practices

05/08/2022

Magento’s way of handling logical expressions through search criteria and its internal filter/filter group builders is poor.

Conditions like (A and B) or (C and D) are not directly supported, and you have to do distributed laws magic to handle them.

04/08/2022

Magento supports batch resolvers that can help you to fetch additional data for entities without querying each item separately.

class RelatedProducts implements BatchResolverInterface
{
    ...

    public function resolve(ContextInterface $context, Field $field, array $requests): BatchResponse
    {
        //Get the list of products we need to load related products for
        $rootProductIds = array_map(function ($request) { return $request->getValue()['model']->getId(); }, $requests);

        //Load the links
        $productLinks = $this->service->getRelatedProductLinks($rootProductIds);

        //Sort the links
+        $response = new BatchResponse();
+        foreach ($requests as $request) {
+            $response->addResponse($request, $productLinks[$request->getValue()['model']->getId()]);
+        }

        return $response;
    }
}

02/08/2022

A perfect solution to a problem does not exist. There are always tradeoffs along the way and snappy specification or API changes might shred even the brightest ideas.

28/07/2022

There are only a few possible ways approach to testing can go:

  • Test First (TDD)
  • Test During
  • Test Never (often derives from “Test Later”)

27/07/2022

As a developer, you’ve been trying things and seeing which worked and which didn’t. You’ve been accumulating experience and wisdom. When you feel a nagging doubt, or experience some reluctance when faced with a task, it might be that experience trying to speak to you. Heed it. You may not be able to put your finger on exactly what’s wrong, but give it time and your doubts will probably crystallize into something more solid, something you can address. Let your instincts contribute to your performance.

D. Thomas, A. Hunt – The Pragmatic Programmer

26/07/2022

There is an Agile Manifesto that boils down to:

Individuals and interactions over processes and tools
Working software over comprehensive documentation
Customer collaboration over contract negotiation
Responding to change over following a plan

25/07/2022

You might sometimes end with superficial requirements that need further clarification. Don’t assume anything. Just ask the right people to get a better understanding.

24/07/2022

You can change the default vendor directory path that is used for autoloading classes through app/etc/vendor_path.php

You can pass the custom object manager factory as the third argument of Bootstrap::create that is called in pub/index.php

23/07/2022

Magento is wrapping it’s caching around Zend_Cache.

All cache type instances must implement Magento\Framework\Cache\FrontendInterface either directly or through inheritance of one of the decorators:

  • Magento\Framework\Cache\Frontend\Decorator\Bare – a decorator that attaches no additional responsibility to a decorated instance
  • Magento\Framework\Cache\Frontend\Decorator\Logger – a decorator that logs cache invalidation actions
  • Magento\Framework\Cache\Frontend\Decorator\Profiler – a decorator that performs profiling of cache operations
  • and… preferably Magento\Framework\Cache\Frontend\Decorator\TagScope – a decorator that limits the cleaning scope within a tag

22/07/2022

Andy Sloane wrote the donut animation in c, and the source code is also a donut.

Source code

             k;double sin()
         ,cos();main(){float A=
       0,B=0,i,j,z[1760];char b[
     1760];printf("\x1b[2J");for(;;
  ){memset(b,32,1760);memset(z,0,7040)
  ;for(j=0;6.28>j;j+=0.07)for(i=0;6.28
 >i;i+=0.02){float c=sin(i),d=cos(j),e=
 sin(A),f=sin(j),g=cos(A),h=d+2,D=1/(c*
 h*e+f*g+5),l=cos      (i),m=cos(B),n=s\
in(B),t=c*h*g-f*        e;int x=40+30*D*
(l*h*m-t*n),y=            12+15*D*(l*h*n
+t*m),o=x+80*y,          N=8*((f*e-c*d*g
 )*m-c*d*e-f*g-l        *d*n);if(22>y&&
 y>0&&x>0&&80>x&&D>z[o]){z[o]=D;;;b[o]=
 ".,-~:;=!*#$@"[N>0?N:0];}}/*#****!!-*/
  printf("\x1b[H");for(k=0;1761>k;k++)
   putchar(k%80?b[k]:10);A+=0.04;B+=
     0.02;}}/*****####*******!!=;:~
       ~::==!!!**********!!!==::-
         .,~~;;;========;;;:~-.
             ..,--------,*/

Output

image source: Quora

21/07/2022

You can use Magento\Framework\GraphQl\Query\Resolver\ArgumentsProcessorInterface to process GraphQL arguments.

You can use Magento\Framework\GraphQl\Query\Resolver\Argument\ValidatorInterface to validate GraphQL arguments.

You can set up an SSH tunnel connection in DBeaver to connect to remote databases that are not exposed.

20/07/2022

mview.xml is only adding MySQL triggers when the indexer is updated On Schedule

19/07/2022

You can adjust Elastic Search queries and filters through search_request.xml but if you want to add them dynamically, there is no easy way besides plugging into the core codebase.