basic question on reference counting + virtual^redefining

Given

class C : public B

Q: i have a variable holding a C object , how do i get a variable of type B, connected to the same object?
A: simple assignment will do, but sliced!

Here’s the call to C constructor

C obj;

Using pointers — B* ptr = &obj;
Using references — B& ref = obj;

Q: Can 2 non-ref variables refer to the same object in memory?
A: I don’t think so. You need the address. nonrefs don’t know how to use addresses.
A: I guess it’s similar to java primitives. No way to create 2 int variables connected to the same int object
A: I feel the slicing problem occurs when you copy objects, but what about when you have just one object but multiple pointers?

Now we are ready to differentiate virtual vs redefining. Building on our example, say B has a public method m(), redefined in C. What is ptr->m() or ref.m()?

* difference — virtual is C::m() ^ redefinition is B::m(),
* difference — virtual is runtime binding ^ redefinition is compile time binding

Now a note on java. Java has only overloading (compile time binding) vs overriding ie virtual. C++ offers virtual ^ overloading ^ redefining. Last 2 are compile time binding.

ptr + virtual -} C // B ptr to a C object, to call a virtual method m()
ref + virtual -} C
nonref + virtual -} B
ptr + redefine -} B
ref + redefine -} B

In summary, only ptr/ref + virtual is really virtual. Not virtual if you use a nonref OR if you drop “virtual” keyword.

Destructors behave just like methods —
ptr + virtual -} C
ptr + non-virtual -> B. See P104 [[NittyGritty]]

%%tech strengths for fin IT jobs

— ranked
java + c# + c++
perl, unix — still widely used in financial but not many people know in-depth
SQL — outer join, self-join, sub-query and other complex joins, case expressions, group-by. See the t-sql book.

# eor
index design and utilization — banks heavy usage
milestoning pitfalls, limitations — banks heavy usage
refactor
complex data analysis using SQL — banks use it all the time.
query plan

make an autosys job start/stop@fixed days

Sometimes you might need to have a job start RUNNING at a fixed time (per Caldendar Cal1), and become success at a fixed time (per Calendar Cal2).

For now, let’s not dispute the requirement. (You might have a job that should not start in the window.)

Here’s a solution:
* Box b1 starts RUNNING per Cal1
* child file watcher w1 starts RUNNING right away
* a top-level job creates the file as per Cal2 => w1 becomes success.

Hibernate basic 2-table join — nested scan implemented in java

Zhu Rong,

To my dismay, hibernate (a popular,stable,fast java ORM framework) implements a 2 table join with individual SELECT’s on the inner table. As you explained, it’s more efficient to join inside the database?

Here’s my experiment. Hibernate supports a basic many-to-one mapping. Student object/table joining Course object/table. if i load 22 Student objects, hibernate uses lazy loading to delay querying the Course table until necessary. When it does query Course, it uses CourseId (join column, but not necessarily a PK or FK) to select just one Course. If 22 students are in 11 courses, hibernates runs 11 queries!

sleep() ^ yield() ^ wait()

Feature 1: does the thread let go of CPU@@
Feature 2: does the thread release lock@@
Feature 3: which real-world thread is affected? current call stack or another thread in an argument?
Feature 3a: is any Thread object explicitly mentioned? as arg or host object?
Feature 4: What objects are involved?

myObj.wait() is most complex:
1) yes
2) exactly 1 and only 1 lock (myObj), even if the thread holds multiple locks
3) current thread only
3a) none.
4) an object to serve as the waiting room

sleep() is simple:
1) yes
2) no, even if holding n locks
3) current thread only
3a) none. this is a static method.
4) No object involved. Thread.sleep() is a static method

yield() is similar to sleep()
4) No object involved. Thread.yield() is a static method
3) current thread only
2) no, even if holding n locks
1) yes