Mostly based on a veteran’s input…
Most GUI clients I have seen use some sort of messaging and you want that to be as asynchronous as possible. There is no reason to keep the user waiting. User clicks on something, the client sends a message to the server and the client is now waiting for a response. When a response comes in (on a separate thread), the GUI takes it and displays whatever it needs. Some people stick a unique request id in the message so when the response comes they can figure out to which request it belongs.
You also have subscription cases where you subscribe to prices for a security and the server will tell you listen to this channel for all updates. That should be encapsulated in some sort of handshake.
RV, 29West and JMS are good choices.
Q: how do u speed up a stored proc?
%A: join order; index selection; avoid table scan; update stats
Now I think we should first establish performance target, by estimating minimum I/O required. (U can’t make a huge query run faster than a tiny query.) Then measure actual logical i/o. See the gap? Usually u can find clues in the execution plan. Improve the plan.
Q: How could a string object’s content be modified?
A (right): reflection to access the char array.
Q: how does a singleton become a 2-ton?
A: 2 class loaders, but i thought class loaders form a delegating hierarchy so no 2 loaders compete to load a class?
A (from interviewer): you can create a class loader outside the hierarchy. Indeed singletons are per-classloader.
Q:diff between clustered and non-clustered index
The answer I forgot to give: a column with lots of updates is no good as clustered index
Q: Users complain about a delay/slowness. we know it’s due to a Unix process. How do you investigate.
A: top; thrashing.
Q: What’s garbage collection?
Q: I have an object in a cache. it’s not referenced from anywhere outside the cache. After using it once, i don’t need it anymore. How do i get it garbage collected?
A: just delete the entry from the cache
Q: lots of insert/delete/updates to a table. how do u keep track of all changes and by who? How do u ensure changes are always tracked?
A: %_hist table and milestoning
Code below is not fully tested, but it shows one feature of Data::Dumper — cross reference. Basically, $b content won't get dumped.
Dumper will show $b is an alias of (another pointer) @a.
If you don't want cross reference, then call Dumper() multiple times, each with a single argument.
$b = @a;
print Dumper @a, $b
PRECISE meaning of Type differs between java and C++.
– any (even marker) interface,
– any class,
– any primitive….
is a type. We say “the declared type of the variable”.
* any class, paramtrized or not
* primitive data type … is a type.
* typedef can declare new type names like aliases, but can’t create new types. Consider const_reverse_iterator.
For an architect and a student, it’s good know ..
when a method or field or argument is named like …register…, it often means “add a CALLBACK to an OBSERVABLE”. The observable (subject, dispatcher..) often holds a list of listeners. When some life cycle event occurs, it /notifies/ them. See other posts on callback, listener, async…
Registration is used in DI, Hollywood principal and many “frameworks”
* singletonList() …
* swap() to swap 2 items in a list
* shuffle — a deck of cards
* checkedList() …
converting between list, set and Collection –> don’t use Collections.java but use constructors.
A footnote on the post about FCD. Here’s another aha moment — *.h file is #include’d into the the host class (I call it the “umbrella class”).
If the component class changes any part of its field listing including field types, umbrella “detects” it through the #include, tantamount to a text change in the umbrella file. Umbrella is marked dirty and needs a recompile.
Q: If you don’t #include the *.h but use FCD instead, can we avoid the recompile?
A: not sure. How about sizeof(Umbrella)? can compiler calc it if you use FCD? See Item 34 eff c++. I believe the trick borrowed from java is a pointer field, so sizeof(Umbrella) is independent of sizeof(Component)
In OO literature, an Interface in the strict sense specifies a contract or expected-services by a family of _objects_ (i’m not saying “classes”)
It follows that an interface specification should never specify field listing.
defining feature: MY Header file is #included by OTHER code, using macro expansion
feature: header file usually contains MY field listing so compiler can do sizeof()
Q: Does the object file include field listing?
A: not important
Q: is header file NOT compiled into the object file? In that case, the field listing is not physically saved in the object file?
A: At runtime, the assembly instructions in the object file has enough details to instantiate objects of my class.
Q: header file creates compile-time dependency, but how about run-time dependency?
http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml – is a real-world coding standard in a real software company.
1. array — contiguous memory => random access.
2. linked graph
—–which are the basis of ..
3. hash table — uses array and linked list. A LinkedHashTable uses linked list at 2 levels.
4. tree — the dominant sorted structure, an important subtype of linked graph
#) skip list
#) binary heap — priority queues
Everything in STL/collections is based on these 4.
Q: When i declare a “Serializable” array, how does VM decide how many contiguous bytes to reserve for 22 array elements of type Serializable? The actual object can have 900 fields in it, so the object can occupy any amount of memory.
A: 22 pointers, roughly 22*32bits. Thanks to Chad Parry.