L * = {0,1} * ∈ P class?

I have the following question about complexity time classes. Since a language, L = {0,1} * is inside or not of class P ?.

L* = {0,1}∗ ∈ P?

C ++ log class – Code Review Stack Exchange

I have created a simple class C ++ logging. It generates different levels of log and adjusts the output color accordingly. I am interested in tips to improve my coding style.

I am particularly concerned about my use of #defineis in the bottom of Logger.hpp. I was unable to find another way to pass __FILE__ and __LINE__ to function (apart from doing it manually of course), but I would not be surprised if this approach is a bad practice.

ConsoleColer.hpp

#include 

namespace AGE
{
    enum class BackgroundColor : int
    {
        Black   = 0,
        Blue    = 16,
        Green   = 32,
        Cyan    = 48,
        Red     = 64,
        Magenta = 80,
        Brown   = 96,
        White   = 112,
    };

    enum class ForegroundColor : int
    {
        Black = 0,
        Blue,
        Green,
        Cyan,
        Red,
        Magenta,
        Brown,
        White,
        Gray,
        Intense_blue,
        Intense_green,
        Intense_Cyan,
        Intense_red,
        Intense_magenta,
        Yellow,
        Intense_white,
    };

    // Used to combine background and foreground colors
    WORD operator &(const BackgroundColor& left, const ForegroundColor& right)
    {
        return static_cast(static_cast(left) + static_cast(right));
    }
}

LoggerSettings.hpp

#pragma once

namespace AGE
{
    struct LoggerSettings
    {
        explicit LoggerSettings(bool should_print_level = true, bool should_print_file_and_line = true,
                                bool should_print_color = true, bool should_print_time = true) :
        print_level(should_print_color),
        print_file_and_line(should_print_file_and_line),
        print_color(should_print_color),
        print_time(should_print_time)
        {}

        // TODO add ability to display time in Logger.hpp/cpp
        bool print_level;
        bool print_file_and_line;
        bool print_color;
        bool print_time;
    };
}

Logger.hpp

#pragma once

#include "LoggerSettings.hpp"

#include 
#include 

namespace AGE
{
    enum class LogLevel
    {
        Trace,
        Info,
        Warn,
        Error,
        Fatal
    };



    class Logger
    {
    public:
        Logger();

        void set_log_level(const LogLevel level);

        LoggerSettings& get_settings();

        void explicit_trace(const std::string_view message, const char* file, int line);
        void explicit_info (const std::string_view message, const char* file, int line);
        void explicit_warn (const std::string_view message, const char* file, int line);
        void explicit_error(const std::string_view message, const char* file, int line);
        void explicit_fatal(const std::string_view message, const char* file, int line);

    private:
        void log(const LogLevel level, const std::string_view message, const char* file, int line);

        WORD get_color(const LogLevel level);
        std::string get_error_string(const LogLevel level);
        std::string get_file_name(const char* filepath);

        const HANDLE m_console_handle;
        LogLevel     m_current_log_level;
        LoggerSettings m_settings;
    };
}

#define trace(message)  AGE::Logger::explicit_trace(message, __FILE__, __LINE__)
#define info(message)   AGE::Logger::explicit_info(message, __FILE__, __LINE__)
#define warn(message)   AGE::Logger::explicit_warn(message, __FILE__, __LINE__)
#define error(message)  AGE::Logger::explicit_error(message, __FILE__, __LINE__)
#define fatal(message)  AGE::Logger::explicit_fatal(message, __FILE__, __LINE__)

Logger.cpp

#include "Logger.hpp"

#include "ConsoleColor.hpp"

#include 

#include 

namespace AGE
{
    Logger::Logger() :
    m_console_handle   (GetStdHandle(STD_OUTPUT_HANDLE)),
    m_current_log_level(LogLevel::Trace)
    {
        m_settings = LoggerSettings();
    }



    void Logger::set_log_level(LogLevel level)
    {
        m_current_log_level = level;
    }



    LoggerSettings& Logger::get_settings()
    {
        return m_settings;
    }



    void Logger::explicit_trace(const std::string_view message, const char* file, int line)
    {
        if (m_current_log_level > LogLevel::Trace)
        {
            return;
        }

        log(LogLevel::Trace, message, file, line);
    }



    void Logger::explicit_info(const std::string_view message, const char* file, int line)
    {
        if (m_current_log_level > LogLevel::Info)
        {
            return;
        }

        log(LogLevel::Info, message, file, line);
    }



    void Logger::explicit_warn(const std::string_view message, const char* file, int line)
    {
        if (m_current_log_level > LogLevel::Warn)
        {
            return;
        }

        log(LogLevel::Warn, message, file, line);
    }



    void Logger::explicit_error(const std::string_view message, const char* file, int line)
    {
        if (m_current_log_level > LogLevel::Error)
        {
            return;
        }

        log(LogLevel::Error, message, file, line);
    }



    void Logger::explicit_fatal(const std::string_view message, const char* file, int line)
    {
        if (m_current_log_level > LogLevel::Fatal)
        {
            return;
        }

        log(LogLevel::Fatal, message, file, line);
    }



    void Logger::log(const LogLevel level, const std::string_view message, const char* file, int line)
    {

        if (m_settings.print_color)
        {
            WORD color = get_color(level);
            SetConsoleTextAttribute(m_console_handle, color);
        }
        if (m_settings.print_level)
        {
            std::cout << "(" << get_error_string(level) << ")";
        }
        if (m_settings.print_file_and_line)
        {
            std::cout << "(" << "In " << get_file_name(file) << " at line " << line << ") ";
        }

        std::cout << message << std::endl;
        SetConsoleTextAttribute(m_console_handle, BackgroundColor::Black & ForegroundColor::White);
    }



    WORD Logger::get_color(const LogLevel level)
    {
        switch (level)
        {
        default:
            return BackgroundColor::Black & ForegroundColor::White;
            break;

        case LogLevel::Trace:
            return BackgroundColor::Black & ForegroundColor::Intense_white;
            break;

        case LogLevel::Info:
            return BackgroundColor::Black & ForegroundColor::Intense_green;
            break;

        case LogLevel::Warn:
            return BackgroundColor::Black & ForegroundColor::Intense_red;
            break;

        case LogLevel::Error:
            return BackgroundColor::Black & ForegroundColor::Intense_Cyan;
            break;

        case LogLevel::Fatal:
            return BackgroundColor::Black & ForegroundColor::Intense_magenta;
            break;
        }
    }



    std::string Logger::get_error_string(const LogLevel level)
    {
        switch (level)
        {
        default:
            return std::string();
            break;

        case LogLevel::Trace:
            return std::string("Trace");
            break;

        case LogLevel::Info:
            return std::string("Info");
            break;

        case LogLevel::Warn:
            return std::string("Warning");
            break;

        case LogLevel::Error:
            return std::string("Error");
            break;

        case LogLevel::Fatal:
            return std::string("Fatal");
            break;
        }
    }



    std::string Logger::get_file_name(const char* filepath)
    {
        std::string path = std::string(filepath);

        int index = 0;
        for (int i = static_cast(path.size()) - 1; i > 0; i--)
        {
            if (path.at(i) == '\')
            {
                index = i;
                break;
            }
        }

        // For some reason the compiler complains if i dont cast to 64bit int
        return std::string(path, static_cast(index) + 1, path.size() - 1);
    }
}

group theory – What irreducible representations of the symmetric group are proper spaces of class sums?

In the context of complex representations of finite groups, a sum of class $ 1_C = sum_ {g in C} g $ acts on an irreducible representation $ V $ as $ lambda (C, V) operatorname {Id} $, or $ lambda (C, V) = | C | chi_V (C) / dim (V) $ with $ chi_V $ the character of $ V $.

My question is which irreducible representations $ V $ symmetric group are clean spaces of a class sum $ 1_C $. That is, when is there a class of conjugation? $ C $ such as $ lambda (C, W) neq lambda (C, V) $ for everyone $ W neq V $?

If this is true, then the isotype component corresponding to $ V $ in any representation is a clean space of $ 1_C $. A simple example is when $ V $ is the $ 2 $three-dimensional irreducible $ mathrm S_3 $ and $ C $ the class of $ 3 $-cycles. then $ V $ is the clean space of $ 1_C $ with eigenvalue -1 $, or equivalently the nucleus of $ operatorname {id} + (123) + (132) $. If we leave $ mathrm S_3 $ on trilinear forms, this means that the corresponding isotype subspace consists of satisfying forms
$$ f (u, v, w) + f (v, w, u) + f (w, u, v) = 0. $$
Similarly, if we can do it for an irreducible representation $ V $we can then describe the corresponding Schur functor on multilinear forms as the solution space of a single equation (rather than a system of equations).

I have checked with Maple that all irreducible representations of $ mathrm S_n $ for $ n leq $ 8 are clean spaces in the sense explained. When $ n leq $ 5 and $ n = $ 7 there is even a class of conjugation $ C $ it works for everyone $ V $, but for $ n = $ 6 and $ n = $ 8 This is not the case.

Add a CSS class to a WordPress menu item that depends on the page visited by the user

I'm trying to make sure that menu items display an underline under the associated navigation item when the user is on a specific page (attached image).

In the static version of the site I was doing, I had a php variable at the top of every page, such as:

Then, in the header menu item, I added the following by adding a class "active_page" when someone is on the page concerned, which I could then style accordingly with CSS:

  • ">HOME
  • Now I have moved it to a custom WordPress theme, it does not work. I place the variable above the get_header() function on each page:

    
    
    

    Because this site has two big submenus in the nav, using the is_page() function to detect the URL of the page does not go to work. For example, I have 11 submenu items under one of the main menu items.

    Any help would be great for it to work.

    enter the description of the image here

    php – Class of sessions with assoc-array – practice

    I'm trying to deal with sessions .. including tables before moving to "database".

    Class.file sessions

    index.php file

    ';
    
    $er = ();
    $data = array((
        'id'=> '1',
        'username'=> 'user1',
        'password'=>'123456'
      ),
      (
        'id'=> '2',
        'username'=> 'user2',
        'password'=>'654321'
      )
    );
    
    //submit
    if(isset($_POST('submit'))){
      // Error Msgs
    $er() = "Not found in array";
    // Forms Inputs
    $username = $_POST('username');
    $password = $_POST('password');
    
    //fetch users in array
    foreach ($data as $key => $value) {
      if(in_array($username, $value)){
        if( $username == $value('username') && $password == $value('password') ){
          $uid = $value('id');
          $unm = $value('username');
          //Sessions class
          Sessions::set('id', $uid);
          Sessions::set('username', $unm );
          // Error Msgs
         unset($er(0));
        }
    }
      }
    }
    
    
    ?>
    
    
    
    
    
    
    Out

    logout.php file

    
    

    Is it good for beginner ..! is anything wrong..! Is there a better solution for this complicated code?

    magento2 – In Magento 2, how can I add a custom class to a SPECIFIC customer navigation item, that is, "Company Structure"

    In Magento 2.3, I try to add a custom INSTEAD class of "navigation item" to a SPECIFIC menu item. In my case, it is "Company Structure". A perfect solution would be for each element with a separate class such as "navigation element structure", but if I could make one, I would take it.

    I know how to edit ALL items in customer_account.xml, but I do not see how to change the

  • class for a specific article.
  • .net – Matrix class in C #

    I have learned C # during my free time in the last few months; Before that, I mostly wrote Java, so the transition was not too difficult, but I have never seen my code read or read by anyone else.

    • Is there anything that could be improved, or perhaps simplified?
    • Am I doing something that would be considered bad practice or a "bad smell"? If so, what should I do instead?
    • I very rarely write comments; should I use them more, and specifically here, are there any methods or sections that could use comments?

    Thank you!

    using System;
    using Mathlib.Misc;
    
    namespace Mathlib.Matrix {
        public class DMatrix {
            private double(,) data;
    
            public int NbRows {
                get;
                private set;
            }
    
            public int NbCols {
                get;
                private set;
            }
    
            public double this(int i, int j) {
                get {
                    return data(i, j);
                }
                private set {
                    data(i, j) = value;
                }
            }
    
            public static int Precision {
                get;
                set;
            }
    
            static DMatrix() {
                Precision = 2;
            }
    
            public DMatrix(int n) {
                if (n < 1) {
                    throw new Exception($"Cannot create matrix," +
                                        $" N should be greater or equal to 1.ntN = {n}");
                }
    
                NbRows = NbCols = n;
                Fill(0);
            }
    
            public DMatrix(int m, int n) {
                if (m < 1) {
                    throw new Exception($"Cannot create matrix," +
                                        $" M should be greater or equal to 1.ntM = {m}");
                }
                if (n < 1) {
                    throw new Exception($"Cannot create matrix," +
                                        $" N should be greater or equal to 1.ntN = {n}");
                }
    
                NbRows = m;
                NbCols = n;
    
                data = new double(m, n);
                Fill(0);
            }
    
            public DMatrix(int m, int n, double x) {
                if (m < 1) {
                    throw new Exception($"Cannot create matrix," +
                                        $" M should be greater or equal to 1.ntM = {m}");
                }
                if (n < 1) {
                    throw new Exception($"Cannot create matrix," +
                                        $" N should be greater or equal to 1.ntN = {n}");
                }
    
                NbRows = m;
                NbCols = n;
    
                data = new double(m, n);
                Fill(x);
            }
    
            public DMatrix(double(,) data) {
                NbRows = data.GetLength(0);
                NbCols = data.GetLength(1);
    
                this.data = new double(NbRows, NbCols);
    
                for (int i = 0; i < NbRows; i++) {
                    for (int j = 0; j < NbCols; j++) {
                        this.data(i, j) = data(i, j);
                    }
                }
            }
    
            public DMatrix(DMatrix A) : this(A.data) { }
    
            public void Fill(double x) {
                for (int i = 0; i < NbRows; i++) {
                    for (int j = 0; j < NbCols; j++) {
                        data(i, j) = x;
                    }
                }
            }
    
            public void Rand() {
                for (int i = 0; i < NbRows; i++) {
                    for (int j = 0; j < NbCols; j++) {
                        data(i, j) = Utils.Rand();
                    }
                }
            }
    
            public void Rand(double max) {
                for (int i = 0; i < NbRows; i++) {
                    for (int j = 0; j < NbCols; j++) {
                        data(i, j) = Utils.Rand(max);
                    }
                }
            }
    
            public void Rand(double min, double max) {
                for (int i = 0; i < NbRows; i++) {
                    for (int j = 0; j < NbCols; j++) {
                        data(i, j) = Utils.Rand(min, max);
                    }
                }
            }
    
            public void SwapRows(int row1, int row2) {
                for (int i = 0; i < NbCols; i++) {
                    double temp = data(row1, i);
                    data(row1, i) = data(row2, i);
                    data(row2, i) = temp;
                }
            }
    
            public static DMatrix operator -(DMatrix A) {
                DMatrix res = new DMatrix(A.NbRows, A.NbCols);
    
                for (int i = 0; i < A.NbRows; i++) {
                    for (int j = 0; j < A.NbCols; j++) {
                        res.data(i, j) = -A.data(i, j);
                    }
                }
    
                return res;
            }
    
            public static DMatrix operator ~(DMatrix A) {
                return A.Transpose();
            }
    
            public static DMatrix operator +(DMatrix A, DMatrix B) {
                if (A.NbRows != B.NbRows || A.NbCols != B.NbCols) {
                    throw new Exception($"Cannot compute sum, matrix dimensions do not match:nt" +
                                        $"A : {A.NbRows}x{A.NbCols}ntB : {B.NbRows}x{B.NbCols}");
                }
    
                DMatrix res = new DMatrix(A.NbRows, A.NbCols);
    
                for (int i = 0; i < A.NbRows; i++) {
                    for (int j = 0; j < A.NbCols; j++) {
                        res.data(i, j) = A.data(i, j) + B.data(i, j);
                    }
                }
    
                return res;
            }
    
            public static DMatrix operator -(DMatrix A, DMatrix B) {
                return A + (-B);
            }
    
            public static DMatrix operator *(DMatrix A, DMatrix B) {
                if (A.NbCols != B.NbRows) {
                    throw new Exception($"Cannot compute product, matrix dimensions do not match:nt" +
                                        $"A : {A.NbRows}x{A.NbCols}ntB : {B.NbRows}x{B.NbCols}");
                }
    
                DMatrix res = new DMatrix(A.NbRows, B.NbCols);
    
                for (int i = 0; i < res.NbRows; i++) {
                    for (int j = 0; j < res.NbCols; j++) {
                        for (int k = 0; k < A.NbCols; k++) {
                            res.data(i, j) += A.data(i, k) * B.data(k, j);
                        }
                    }
                }
    
                return res;
            }
    
            public DMatrix HadamardProduct(DMatrix A) {
                if (NbCols != A.NbCols || NbRows != A.NbRows) {
                    throw new Exception($"Cannot compute Hadamard product," +
                                        $" dimensions do not match:ntA : {NbRows}x{NbCols}nt" +
                                        $"B : {A.NbRows}x{A.NbCols}");
                }
    
                DMatrix res = new DMatrix(NbRows, NbCols);
    
                for (int i = 0; i < res.NbRows; i++) {
                    for (int j = 0; j < res.NbCols; j++) {
                        res.data(i, j) = data(i, j) * A.data(i, j);
                    }
                }
    
                return res;
            }
    
            public static DMatrix operator +(DMatrix A, double x) {
                DMatrix res = new DMatrix(A.NbRows, A.NbCols);
    
                for (int i = 0; i < A.NbRows; i++) {
                    for (int j = 0; j < A.NbCols; j++) {
                        res.data(i, j) = A.data(i, j) + x;
                    }
                }
    
                return res;
            }
    
            public static DMatrix operator -(DMatrix A, double x) {
                return A + (-x);
            }
    
            public static DMatrix operator *(DMatrix A, double x) {
                DMatrix res = new DMatrix(A.NbRows, A.NbCols);
    
                for (int i = 0; i < A.NbRows; i++) {
                    for (int j = 0; j < A.NbCols; j++) {
                        res.data(i, j) = A.data(i, j) * x;
                    }
                }
    
                return res;
            }
    
            public double Trace() {
                if (NbCols != NbRows) {
                    throw new Exception($"Cannot compute trace, matrix is not square:nt" +
                                        $"A : {NbRows}x{NbCols}");
                }
    
                double res = 0;
    
                for (int i = 0; i < NbRows; i++) {
                    res += data(i, i);
                }
    
                return res;
            }
    
            public double Det_recursive() {
                if (NbCols != NbRows) {
                    throw new Exception($"Cannot compute determinant, matrix isn't square:nt" +
                                        $"A : {NbRows}x{NbCols}");
                }
    
                double sum = 0;
    
                if (NbRows == 1) {
                    return data(0, 0);
                }
                else if (NbRows == 2) {
                    return data(0, 0) * data(1, 1) - data(0, 1) * data(1, 0);
                }
    
                for (int N = 0; N < NbRows; N++) {
                    DMatrix minor = new DMatrix(NbRows - 1, NbRows - 1);
    
                    for (int i = 0; i < NbRows - 1; i++) {
                        for (int j = 0; j < NbRows; j++) {
                            if (j < N) {
                                minor.data(i, j) = data(i + 1, j);
                            }
                            else if (j > N) {
                                minor.data(i, j - 1) = data(i + 1, j);
                            }
                        }
                    }
    
                    int sgn = (N % 2 == 0) ? 1 : -1;
                    sum += sgn * data(0, N) * minor.Det_recursive();
                }
    
                return sum;
            }
    
            public double Norm_frobenius() {
                double res = 0;
    
                if (NbRows == 1 || NbCols == 1) {
                    for (int i = 0; i < NbRows; i++) {
                        for (int j = 0; j < NbCols; j++) {
                            res += data(i, j) * data(i, j);
                        }
                    }
                }
                else {
                    res = (~this * this).Trace();
                }
    
                return Math.Sqrt(res);
            }
    
            public static DMatrix Id(int n) {
                DMatrix res = new DMatrix(n);
    
                for (int i = 0; i < n; i++) {
                    for (int j = 0; j < n; j++) {
                        if (i == j) {
                            res.data(i, j) = 1;
                        }
                        else {
                            res.data(i, j) = 0;
                        }
                    }
                }
    
                return res;
            }
    
            public DMatrix Transpose() {
                DMatrix res = new DMatrix(NbRows, NbCols);
    
                for (int i = 0; i < NbRows; i++) {
                    for (int j = 0; j < NbCols; j++) {
                        data(i, j) = data(j, i);
                    }
                }
    
                return res;
            }
    
            public DMatrix Row(int row) {
                DMatrix A = new DMatrix(1, NbCols);
    
                for (int i = 0; i < NbCols; i++) {
                    A.data(0, i) = data(row, i);
                }
    
                return A;
            }
    
            public DMatrix Col(int col) {
                DMatrix A = new DMatrix(NbRows, 1);
    
                for (int i = 0; i < NbRows; i++) {
                    A.data(i, 0) = data(i, col);
                }
    
                return A;
            }
    
            public DMatrix Diag() {
                if (NbRows != NbCols) {
                    throw new Exception($"Cannot compute diagonal, matrix isn't square:nt" +
                                        $"A : {NbRows}x{NbCols}");
                }
    
                DMatrix res = new DMatrix(NbRows, NbCols);
    
                for (int i = 0; i < NbRows; i++) {
                    res.data(i, i) = data(i, i);
                }
    
                return res;
            }
    
            public DMatrix Map(OneVarFunction func) {
                DMatrix res = new DMatrix(NbRows, NbCols);
    
                for (int i = 0; i < res.NbRows; i++) {
                    for (int j = 0; j < res.NbCols; j++) {
                        res.data(i, j) = func(data(i, j));
                    }
                }
    
                return res;
            }
    
            public double(,) ToArray() {
                double(,) arr = new double(NbRows, NbCols);
    
                for (int i = 0; i < NbRows; i++) {
                    for (int j = 0; j < NbCols; j++) {
                        arr(i, j) = data(i, j);
                    }
                }
    
                return arr;
            }
    
            public string ToCsv() {
                string str = "";
    
                for (int i = 0; i < NbRows; i++) {
                    for (int j = 0; j < NbCols; j++) {
                        if (j != NbCols - 1) {
                            str += $"{data(i, j)},";
                        }
                        else {
                            str += $"{data(i, j)}n";
                        }
                    }
                }
    
                return $"{str}n";
            }
    
            public override string ToString() {
                string str = "";
    
                for (int i = 0; i < NbRows; i++) {
                    str += "( ";
                    for (int j = 0; j < NbCols; j++) {
                        string decimals = new string('0', Precision);
                        string nb = data(i, j).ToString($"+0.{decimals};-0.{decimals};0")
                            .Replace('+', ' ');
    
                        if (j != NbCols - 1) {
                            str += nb + "  ";
                        }
                        else {
                            str += nb + " )n";
                        }
                    }
                }
    
                return str + 'n';
            }
        }
    }
    ```
    

    id = "animatedModal", class = "popup-modal", <! – THIS IS IMPORTANT! to close the modal, the name of the class.

    Hello,
    I'm new to JSquerys and I'm really excited to use them, especially this model that I'm editing.
    Can you give yourself some time to take a look at JSquery, it's been 5 weeks since we've been trying to solve the problem.
    Under the My projects section (index), I'm trying to link the thumbnails to alternative content.
    Currently all thumbnail links to demo01 that generates a pop-up window and text "Geschäfts Eines, Appropriately …

    id = "animatedModal", class = "popup-modal", <! – THIS IS IMPORTANT! to close the modal, the name of the class.

    5th dnd – Do half-elves or half-orcs count as humans or as a feature of the Preferred Enemy class?

    I'm using dndbeyond character builder to create a ranger. If I choose humanoids, it does not list half-elves or half-orcs, but humans and orcs.

    I see three possibilities
    1] I can not choose one or the other
    2] I can have a half-elf if I choose a human or an elf or I can get a half-storm if I choose a man or an orc
    3] they forgot to include them

    I am in the group that is new to the 5th and we only use the player's manual. I did not see anything in this book that covers this

    vb.net – Initialization code for inherited class calls in the base class

    I'm interested in your view of the approach I took for legacy classes to initialize their base class.

    Here is a collection class Machines that maintains a list of Machine objects. Each machine must be able to inform its parent, with the help of a delegate, of something that she does but she has no reference to the parent:

    Public Delegate Sub MachineDelegate(ByRef item As Machine)
    
    Public MustInherit Class Machines
    
        Private _items As New List(Of Machine)
    
        Public Function Create() As Machine
            Dim item As Machine = CreateItem()
            _items.Add(item)
            PostCreationHandler(item)
            Return item
        End Function
    
        ' Create derived object
        Public MustOverride Function CreateItem() As Machine
    
        Public Sub ChildMachineDidSomething(ByRef item As Machine)
            ' Handle child object event
            Debug.Print("Machine did something")
        End Sub
    
        ' Called once object has been created
        Protected Overridable Sub PostCreationHandler(ByRef item As Machine)
            item.MachineDelegate = AddressOf ChildMachineDidSomething
        End Sub
    
    End Class
    
    Public Class Machine
        Public MachineDelegate As MachineDelegate
    
        Public Sub DoMachineThing()
            If Not MachineDelegate Is Nothing Then MachineDelegate(Me)
        End Sub
    
    End Class
    

    The child objects will use a MachineDelegate to inform their parent, going as a reference.

    Inherited Cars and Cars classes look like this and have their own delegate to handle car notifications:

    Public Delegate Sub CarDelegate(ByRef item As Car)
    
    Public Class Cars
        Inherits Machines
    
        ' Create derived object
        Public Overrides Function CreateItem() As Machine
            Dim item As Car = New Car
            CreateItem = item
        End Function
    
        Public Sub ChildCarDidSomething(ByRef item As Car)
            ' Handle child object event
            Debug.Print("Car did something")
        End Sub
    
        ' Called once object has been created
        Protected Overrides Sub PostCreationHandler(ByRef item As Machine)
            Dim car As Car = item
    
            MyBase.PostCreationHandler(item)
    
            car.CarDelegate = AddressOf ChildCarDidSomething
    
        End Sub
    
    End Class
    
    Public Class Car
        Inherits Machine
    
        Public CarDelegate As CarDelegate
    
        Public Sub DoCarThing()
            If Not CarDelegate Is Nothing Then CarDelegate(Me)
        End Sub
    
    End Class
    

    I create an overwhelming PostCreationHandler where object-specific initialization must be handled once an object is created and I use it MyBase.PostCreationHandler to make sure that the object is properly initialized at all levels of the inheritance chain.

    My goal is to avoid giving child objects a reference to their parent.

    My question is: is this correct and is there a better way to do it? Thank you for reading and for your time.