Tid bits with C++

one common interview question is difference between overloading & overriding. The correct answer is overloading is compile time polymorphism. While overriding is runtime poly morphism.

Tid bits Windows with VC++

SendMessage & Postmessage API are essentially same, but big difference is SendMessage blocks, while PostMessage returns immediately

In C# to draw Control.CreateGraphics() is called to get a Graphics obj. Finally Dispose() needs to be called on this Graphics object. In MFC you can call GetDC() or CClientDC dc(this) to get DC... In former case ReleaseDC(CDC *p) needs to be called. Other DC's are CWindowDC, CPaintDC...

UpdateData(false) updates data in variable to control while param true does in reverse.

GetDlgItem(ID) returns a CWnd ptr. GetDlgCtrlID(CWnd*) returns ID of control

Diamond Problem

Diamond problem occurs with multiple inheritance where a derived class derives from two intermediate base classes whereas those base classes have a common base class. When compiled a common method in super base class call will resolve to ambiguity and throw an compiler error. This can be solved by adding virtual keyword in both of the base classes which creates separate vtables. By using these vtables runtime binding is resolved. (In other words both vtables of intermediate base classes will be referencing to the address of function in super base class)

In C# this problem is solved my completely blocking multiple inheritance. Only multi-level implementation is permitted in C#. Also note that multiple interface implementation is supported in C#. The reason is multiple inheritance leads to more complexity. (only one of which is diamon problem) So the .NET architects kept away from it.

Agile Vs Scrum

Agile:
Iterative & Incremental
Delivery of working software in short intervals
Continuous customer involvement
Cross-functional team

Waterfall:
Requirements, detailed schedule upfront
Linear phase by phase
Every phase done by specialist programmers
Feedback only at end.

Agile Merits:
Customer involvement
Early testing

Waterfall Merits:
Detailed plan including cost & estimation
Every phase proceeds to next with proper sign off & checklist

Agile Demerits:
Feature creep.
Compromise quality to meet sprint delivery.


Waterfall Demerits:
Oversights in requirements/design only visible at end.
Testing done at end so quality might end bad

Tit Bits .NET General concepts

Startup:

What is .NET framework:
.NET framework comprises CLR and Class libraries. Code that targets CLR is managed code. CLR aka Common Language runtime is the execution environment for managed code. It provides Garbage collection, JIT Compilation, Code Execution, code access security, interop, diagnostics, type safety & many services. Base class library is the set of class libraries that expose many .net services for all clr compliant languages.

Cold Startup: This happens when .NET runtime as well as application code were not in memory.
Warm Startup: This is faster. This happens when application is re-launched.

Thread.Suspend vs Thread.Sleep
Sleep() immediately puts the thread to sleep. While suspend() clr takes care to suspend after finding a safepoint to do so. Suspend() is not safe deadlocks can happen if the thread suspends with access to a resource that another thread is waiting for. Suspend()/Resume() deprecated functions from 2.0

Lock is a language construct that wraps Monitor.Enter & Monitor.Exit Both of them are basic synchronization objects. But Monitor class offers Wait & Pulse methods. But these are unsafe because if an thread enters wait after a pulse was issued it will result in deadlock. So for synchronization & communication between threads AutoResetEvent is the good construct.
Locks, Monitors & Mutexes are mutually exclusive. Semaphore is not mutually exclusive. Both semaphores & Mutexes derive from WaitHandle OS construct. Mutexes & semaphores can work across processes.

Software Patterns

Software patterns fall in to Architectural patterns, Design patterns and Idiomatic patterns. Architectural patterns: It defines the fundamental structure of the whole software system.
(Layered systems, MVC)
Design patterns: It organizes functionality between subsystems in a domain independent way.
(Abstract factory, template methods, singleton)
Idiomatic patterns: Low level patterns to solve particular implementation problems.
(singleton pattern implementation specific for .net)

Design Principles

Many people don't follow any principles in living... Many don't know about them and many laugh about such thing... Same applies to software design principles also... Let us join the few who cares about design principles...
Open close principle (OCP)
This is known as open for extension and closed for modifications. A class can be better implemented as abstract & derived forms so that if any changes needs to be made it can be made to the derived functionality instead of changing core base class. A bad implementation example is Shape class that draws rectangles, ellipses, circles. If it needs to draw a square then a new drawSquare() function needs to be added. This is bad design because as the class is changed all of it needs to be unit tested again, if this is imagined as big class there are problems with multiple developers working simultaneously needs to integrate it and a change might break the code somewhere. A good design is splitting the shape in to one Shape base class with abstract drawShpe() and multiple derived classes like Ellipse, Circle, Rectangles overriding implementation which fits in to OCP...

Dependency Inversion Principle

Content in development..............................



WARNING: ALL CONTENTS HERE ARE MY PERSONAL INTERPRETATIONS. THERE IS NO WARRANTY GUARANTY ABOUT RELIABILITY OF CONCERNED MATTER