object oriented design – Flat or nested classes

Im new to object design and Im trying to figure out which design is better.
I have a Material entity which can have multiple versions. I have two designs, one is with nested classes, and the other is flat, more like a database table.

Nested example (pseudo code):

class Material
    path = "some/path/" + name
    List MaterialVersion

class MaterialVersion
    path = "some/path/materialName/" + versionNumber

MaterialVersion is nested inside Material and this way its easier for me to display it in the UI.
But I’ve tought of another design like this:

class Material
    path = "some/path/" + name + version

class MaterialCollection
    List Material


I have lost the MaterialVersion class but I need some methods that I can query all of the materials so I can display them in a tree like this

-- Material 1
---- V1
---- V2
-- Material 2
---- V1

I think the first one is better for my use but I would like to hear some opinions or even some other solution.

unity – Angle object only in the X axis

I’m trying to code a turret to angle towards a target, where I have one part of the turret only rotating on the left/right, and I want to animate another part to only angle up/down. I’ve got the left/right (RotateTowardsTarget) working, but I can’t get the up/down (AngleTowardsTarget) to work, it seems to also rotate the object as well as angle it.

turretXRotation is a child of turretYRotation. These objects form the top of a gun turret, so the base will rotate, and the gun barrel will angle towards the target

/// <summary>
/// Orient the turret weapon towards the target.
/// </summary>
/// <param name="lookPosition"></param>
private void OrientWeaponsTowards(Vector3 lookPosition)

/// <summary>
/// Rotate towards the target.
/// </summary>
/// <param name="lookPosition"></param>
private void RotateTowardsTarget(Vector3 lookPosition)
    // Determine which direction to rotate towards
    Vector3 targetDirection = lookPosition - transform.position;

    // The step size is equal to speed times frame time.
    float singleStep = weaponRotationSpeed * Time.deltaTime;

    // Rotate the forward vector towards the target direction by one step
    Vector3 newDirection = Vector3.RotateTowards(

    // Draw a ray pointing at our target in
    //Debug.DrawRay(turretYRotation.transform.position, newDirection, Color.red, 3);

    newDirection.y = 0;
    // Calculate a rotation a step closer to the target and applies rotation to this object
    turretYRotation.transform.rotation = Quaternion.LookRotation(newDirection);

/// <summary>
/// Angle towards the target.
/// </summary>
/// <param name="lookPosition"></param>
private void AngleTowardsTarget(Vector3 lookPosition)
    // Determine which direction to rotate towards
    Vector3 targetDirection = lookPosition - turretXRotation.transform.position;

    // The step size is equal to speed times frame time.
    float singleStep = weaponRotationSpeed * Time.deltaTime;

    // Rotate the forward vector towards the target direction by one step
    Vector3 newDirection = Vector3.RotateTowards(

    // Draw a ray pointing at our target in
    //Debug.DrawRay(turretXRotation.transform.position, newDirection, Color.red, 3);

    // Calculate a rotation a step closer to the target and applies rotation to this object
    turretXRotation.transform.rotation = Quaternion.LookRotation(newDirection);

Does anyone know how I can just make the `turretXRotation` only change it's X value to aim towards the target? I've tried similar stuff to the rotating, by zeroing out some of the x/y/z coords, but I can't seem to crack it.

python – AttributeError: ‘int’ object has no attribute ‘getKey’

I try to make a simple hashtable in python with linear probing. My hash table is working but I have some problems with my perfomance testing method.

I am just getting an AtrributeError in the follwing code:

This is my performance method:

def performance(lin_prob=True, rand_input=True):
    Prints the average runtime of k insert operations
    for different sizes of key

        lin_prob - whether linear probing or
            double hashing should be used
        rand_input - whether input should be randomized
            or a predefined (worst case) input

    m = 1009  # first prime bigger than 1000

    # repeat for increasing number of keys
    sizes = (math.floor((m * i) / 50) for i in range(1, 50))
    for k in sizes:

        ht = HashTable(m, lin_prob)

        if rand_input:
            inputs = random.sample(range(10 * m + 1), k)
            inputs = (m * i for i in range(k + 1))

        start_time = time.time()
        for key in inputs:

        total_runtime = (time.time() - start_time) * 1000000
        avg_runtime = total_runtime/k  # average time in nano sec

        print("%dt%.2f" % (k, avg_runtime)) 

I am getting the AttributeError: ‘int’ object has no attribute ‘getKey’, which is referencing to this line ht.insert(key)

There is a conflict with my insert method:

 def insert(self, entry):
        Method inserts key into hash table
        according to the hash value of the key.

            key - key to insert


        key = entry.getKey()
        index = self.hash(key)
        count = 0
        if self.table(index) == None or self.table(index).getValue() == "DELETED":
            self.table(index) = entry
            return count + 1
            inserted = False
            step_size = self.hash_method(key)
            while inserted != True:
                index += ste_size
                count += 1
                if index >= self.size:
                    index = index - self.size
                if self.table(index) == None or self.table(index).getValue() == "DELETED":
                    self.table(index) = entry
                    return count

This line key = entry.getKey() is making the error referencing to the line in my performance method.
Is there another way to implement the line in the performance method?
Or how can I avoid this error? I am just a little newbie in programming, please help me.

bitcoind – libbboost cannot open shared object

Background: I compile bitcoind on one system but run it on another. When I compiled bitcoind 0.19.1 some time back using the following method, I was able to run bitcoind and bitcoin-cli on the target system without issue

./configure --disable-wallet --disable-tests --disable-bench --disable-gui --enable-util-tx=no --prefix=$HOME/bitcoind/x64 --exec-prefix=$HOME/bitcoind/x64
make && make install

Today I compiled v0.20.0 using the same method. If I run ./bitcoind -version on the system I compiled the binary it runs fine, but if I take the binary to my target system I get the following error:

./bitcoind: error while loading shared libraries: libboost_filesystem.so.1.67.0: cannot open shared object file: No such file or directory

The binary seemed to be portable last time, and the pre-compiled binary I download from the Bitcoin Core team runs fine.

Note that on the target system libboost-filesystem-dev and libboost-filesystem1.67-dev are not installed, this is likely the source of my error. That said, running the pre-compiled binary from the Core team runs, so why doesn’t mine?

Can someone help me understand if I did something wrong or if I need to add ./configure flags to make the binary more portable? Specifically what I likely did differently than the core developers that made my binary fail where theirs worked?

EDIT 1: Running ./configure --enable-static or ./configure LDFLAGS=-static does not result in a portable binary either.

Also note that installing libboost-filesystem library with apt does fix the error.

dnd 5e – Could True Polymorph turn a creature like a shark into a object like a dead dragon turtle’s head?

I have a bard that has been true polymorphing into a dragon turtle and attacking coastal towns on a large island (think “Big Island” Hawaii) I am doing this so another member of my party can be true polymorphed into a bronze dragon adult and be seen “fighting” with me.

Our plan is for the fight to go into the ocean, then sometime later he as the bronze dragon will drag a part of a dragon turtle’ body out with him and declare himself their savior and new leader and/or guardian. then true polymorph on him will be dropped, he’ll say he used his dragon shapechange ability to look human. Then he will say he has to keep traveling to “right many wrongs” but that one day he will return.

Then at the end of the campaign if we are still alive, I will permanently make him an adult bronze (around 200 years old) and he will get to spend upwards of 5000 years retired and living as the king of an island nation. Also so he is a sailor background fighter so he plans to slowly reshape them into a sea fairing warrior people like the ancient Maori. He also plans to take a bride from the tribe once every generation till the whole island is full of dragon ancestry sorcerers and half-dragon humans.

We may not need the corpse head of a dragon turtle to pull this deception off we could say it died below the waves but it would help give us trick them and then for centuries the skull of a dragon turtle can adore their main village as a constant reminder of why they should follow him.

geometry – How to make computers understand length, breadth and height given a 3d object?

Suppose, I am building an A.I Robot and i want that robot to bring to me that cuboidal shape object whose length is say 10 cm(in 1st case out of (40cm, 19cm, 10cm)), each time it brings the desired object i place the object back there with its bottom(base) resting on its different side so how will it distinguish b/w the length, breadth and height of the object?
For example, the next three images are of the same cuboid having bases on different sides image1 image2 image3.Thinking in pseudo code, my opinion is that for height(side which is ground up or,) comparing it with a virtual vertical unit scale will do the work, but i am unable to come up with how to find the difference b/w lengths and breadths.
How can i figure out the difference b/w the length and breadth of this 3d cuboid?
Also just by simply placing the cuboid with the base having a diffrent side interchanges the values of l,b,h completely most of the time(or atleast two of the values interchange every time)
And now what to do when i need to generalize the situation for many different cuboids with different length, breadth and height?
(skip this part answering if the answer is similar to the previous part).

docker – SNMP: hrSystemUptime.0: Unknown Object Identifier (Sub-id not found: (top) -> hrSystemUptime)

I get the error in the title when I issue the following command.

$  snmpget -v3 -u edgeos-snmpd-user -l authPriv -a SHA -x AES -A authPhrase -X privPhrase 192.168.x.x hrSystemUptime.0
hrSystemUptime.0: Unknown Object Identifier (Sub-id not found: (top) -> hrSystemUptime)

If I enter the same command on the target system (192.168.x.x), I get a valid result.

# snmpget -v3 -u edgeos-snmpd-user -l authPriv -a SHA -x AES -A authPhrase -X privPhrase localhost hrSystemUptime.0
HOST-RESOURCES-MIB::hrSystemUptime.0 = Timeticks: (1362660) 3:47:06.60

The client is an Ubuntu 18.04.1 based Docker container and the target is an Alpine-based Linux device.

I have installed snmp-mibs-downloader in the container and the hrSystemUptime entry exists in "/var/lib/snmp/mibs/ietf/HOST-RESOURCES-MIB.

-- The Host Resources System Group

hrSystemUptime OBJECT-TYPE
    SYNTAX     TimeTicks
    MAX-ACCESS read-only
    STATUS     current
        "The amount of time since this host was last
        initialized.  Note that this is different from
        sysUpTime in the SNMPv2-MIB (RFC1907) because
        sysUpTime is the uptime of the network management
        portion of the system."
    ::= { hrSystem 1 }

However, it doesn’t seem to be searching this directory.

$ net-snmp-config --default-mibdirs

I copied HOST-RESOURCES-MIB to /home/edge/.snmp/mibs but it made no difference.

What do I have to do in the container to get this to work?

How to assign object to variable in Powershell

i am trying to assigned a variable from a search object :

$tes = $ListLookup.Items | where-object {$_.title -eq “TEST”} | sort Title | FT ID

So the above brings back the ID of the item l want but l want to assign that ID number “4” to a variable

So l can use it in $listLookup = $List.GetItemById(4) as l am trying to get information via that code

Hope that make sense

OOP design: how to find one Subclass object in an array of Superclass objects?

Say I have a Group object which maintains a list of its Members:

private $members;

Now the class Member has a range of subclasses such as OrdinaryMember and GroupLeader. Every group has precisely one leader. The GroupLeader can provide a list of pending applicants to this group:


However, the ::getApplicantList() method is unavailable on all of the OrdinaryMember instances.

How can a Group object obtain the list of pending applicants?

unity – Move an object with other objects connected (via joints) the right way

What is the best way to move an object with other objects connected to it via joints?

Let’s assume we have the following setup:

  • A player that can move on the x and the z axis
    • “Normally configured” RigidBody
    • Moving like this:
    void FixedUpdate() {
        Vector3 movement = new Vector3(Input.GetAxisRaw("Horizontal"), 0f, Input.GetAxisRaw("Vertical"));
        movement = movement.normalized * 2f * Time.deltaTime;

        // m_rb is the RigidBody of the player
        m_rb.MovePosition(transform.position + movement);
  • Another object that should be moving with the player as it were its child
    • Connected to the player via a fixed joint
    • “Normally configured” RigidBody

When moving the player without any object connected the movement looks as expected:

enter image description here

Now moving the player with the object connected results in some kind of dragging effect as seen here:
enter image description here

One way to solve this behaviour would be to also move the connected object:

// m_otherRb is the RigidBody of the connected object (m_other)
m_otherRb.MovePosition(m_other.transform.position + movement);

Is there a better way to solve this? Shouldn’t the joint handle the movement of the other object? Moving the connected object like this results in many problems like to high impulse forces when colliding with something as both elements get pushed towards the collider. Also handling the rotation of the connected object isn’t as easy as the position.