Thoughts On Techies
_cdecl vs _stdcall conventions:
.NET Bits
Its just there to re-claim your unmanaged resources. Basically Garbage Collector does not know how to collect the unmanaged, so we pump code to do ourselves. But we cannot leave the work to Garbage Collector since it is non-deterministic. So we empower(?!) programmers to use Dispose pattern to deterministically and programmatically recollect the memory. But support a Finalizer only if there are unmanaged resources.
System Sub-System Unit Component
Notes on the Design
System contains many sub-systems. System is an independent entity. It is everything put together.
Sub-System can consists of many units or modules.
Software Architecture is the bigger picture. It is the highest level of view or abstraction. MVC or Layered Architecture are some examples.
Software design is the smaller picture. It is the design of individual modules. Often represented in UML. They adhere to design patterns.
Consequences of the design on the architecture:
Detailed design vs Continuous design
Detailed design fits in the classic waterfall model. Its also a top down approach. Sub-system, units, interfaces between them and deployment are well identified and documented.
Continuous design is a bottom up approach. Evolving software is refactored. This is an outcome of extreme programming and Agile methodologies.
Functional vs Non-Functional
Functional is the What (FR)
Non-Functional is the How (NFR)
The behavior is the What
The metrics is the How
Functional deals with features
Non-functional deal with the constraints
UML
Functional depicted in Use Cases
Non-Functional no specific UML diagram
Some of non-functional requirements are:
Safety
Security
Privacy
Reliability
Response times
My codeproject article
http://www.codeproject.com/Tips/403418/Lifetime-events-of-a-WPF-application
CS1619 error on using command prompt compilation of .net file
error CS1619: Cannot create temporary file 'c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\CSCDC60.tmp' -- Access is denied.
Resolution: Launch your command prompt as Administrator.
Goto Start->All Programs->Accessories-->Command Prompt
Right click to get context menu.In the menu click "run as administrator" menu item.
You are done:
TidBit: Beginners guide to .NET command prompt compilation:
1. Open cmd prompt
2. type cd\
3. type cd "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727>"
4. type csc "filepath" example: csc "c:\myprograms\test.cs"
5. you see output of program (if any) or errors/warnings if your program has problems
6. step 4 command puts your exe in same path where csc.exe resides. If you want your exe to be created in different path use an out:"file path" after "csc" command. example: csc out\:"c:\myprograms\test.exe" "c:\myprograms\test.cs"
Design Patterns
Outputs: Below. This is how I understood design patterns... I try to put them in a abstract way... concisely...
Processor: Error prone... my brain!
A Design pattern is general solution to commonly occurring problem in software design. In fact solutions to commonly occuring OOPS issues. One level down the Object Oriented Programming cannot support itself hence needs a design paradigm. Most of us will be using patterns even without knowing that we are using a pattern in many scenarios.
Structural patterns:
Decorator pattern: What it is: It can be simply said runtime subclassing. subclassing is extending the functionality of class at compile time itself. Whereas decorator pattern involves extending the functionality at runtime. It can be also said that adding functionality dynamically to an object is possible by decorator pattern. When to use: This pattern is fit if subclassing will lead to too many.
Proxy pattern: What it is: Proxy pattern implements call forwarding mechanism. It helps to create objects on demand wherever object creation is expensive. Good example is the world of DCOM and Remoting. Where proxies will be middle man and clients query them as local objects. The actual call will be executed in remote machine.When to use: If objects needs to be created on demand. If some misc activities needs to be performed when a call is made. Example for misc activities include authentication, authorization, licensing etc.,
Proxy vs Decorator: Do you think they can be compared?! May be in one aspect... that is the call forwarding aspect. They both forward calls. But proxies always forward call to the same object it creates. It is fixed at design time. But in case of decorator it is dynamic.Decorator objects can hold instance of any type of components or even to another decorator itself!
_cdecl vs _stdcall conventions:
_cdecl & _stdcall are two different calling conventions seen in pre .NET world. Here _cdecl is mostly used with C & C++ Environment. Here Calling function (caller) will be clearing the stack under the hood. This is default for CRT (C Runtime Library) environment.
Example:
void foo(int i) à _foo;
void foo(int i, int j) à _foo@8
Most of the Win32 (32 bit Windows OS) API’s will be of_stdcall type. Here called function (callee) will be doing the stack cleanup. Name decoration will be containing param count. Code foot print is small because clean-up code will be in only one place even there are multiple calls.
Example:
void foo(int i) à _foo@4 ; (An int param is 4 bytes in size!)
void foo(int i, int j) à _foo@8
Note: See the decorations that’s why they did not support optional params
Thoughts on FxCop (.NET)
Common crashes & compile errors (C++)
1. Error C2243: 'type cast' : conversion from 'DerivedClassXXX *' to 'BaseClassXXX *' exists, but is inaccessible.
class DerivedClass : public BaseClass
Include Guard in C++
Include guards prevent multiple includes of the same file in C++, MFC.
They are preprocessor directives. Pre-processor directives will be also called as compiler directives. These are instructions that will not be part of the executable/object file instead commands to the compiler when it generates the executable!
When you require include guards?
When you get “redefinition; different storage class” errors in your visual studio it means that same header file is included twice somewhere directly or indirectly. This will be difficult to find in complex code. So easy option is to provide include guard for your most used header files. Syntax given below…
#ifndef YOURFILENAME_H
#DEFINE YOURFILENAME_H
//YOUR HEADER FILE CODE GOES HERE
#endif
A view on C# Generics
An object based collection has boxing/unboxing overhead for value types, casting overhead for reference type this means type safety can be compromised & may be runtime exceptions will happen. Writing a collection class for every type will lead to lesser productivity. In Non-generic list value types needs to be boxed & reference types needs to be casted hitting performance. Also accidentallly unwarranted type can enter in to list throwing runtime exception because weekly typed it is. A generic class can defer specification of one more types until it is instantiated. (For example a generic type T may be an int or string)
Generics after compiling in CIL it will contain only type value parameters. But during compilation by CLR to create instance of generic class, the handling is different for value type and reference type. For value type for every distinct type T a generic specialized class will be created with proper substitutions. For example for int & long, separately substituted two generic specialized class will be created. For reference types things are different. On encountering usage of first reference type a single specialized generic type will be created substituting object pointers. For example customer, order classes will be instances of same substituted specialized generic type. This reduces code bloating instead of a class for every Type, same generalized substituted Type class is re-used.
Default keyword will be used like default
Good book on COM
The author argues on the definition of object orientedness.
C++ => OO => (some) Encapsulation + (some)Polymorphism + (some)Late Binding + Implementation Inheritance
COM => OO => (Real)Encapsulation + (Real) Polymorphism + (Really)Late Binding + Interface Inheritance