Posted in ASP .Net, C#, Core Java, Design Pattern, Framework, Inversion of Control, Java EE, Library

Library vs Framework

The key difference between Library and Framework is in IoC (Inversion of Control)

  • by using a feature from a Library you are in control.
  • The Framework include some abstract design with built-in behaviors. Control is inverted and the framework calls you; framework code will call the code at those various points that behavior has inserted. The Hollywood principle: Don’t call Us, we’ll call You.

Library

Framework

A certain set of reusable functions of an application (mostly organized into classes) As a skeleton of an application
A collection of class definitions A collection of patterns
You call the library APIs in your code A framework calls your code
The control is always with you The control in with the framework if you’re using it
Libraries meant to do some specific tasks only Framework is a predefined design
You need to scaffold your project manually Super easy to scaffold
   

 

 

 

Posted in C#, Object Oriented Programming, Static

Static keyword in C#

Static class cannot be instantiated using the “new” keyword

 

Static items only access other static items. Share resources between multiple users

 

Static constructor in non-static class: runs only once when class instantiated first time

 

In static class: runs only once when any of its static members accessed for the first time
Static members are allocated in high frequency heap area of the memory

 

 

Posted in Abstract Class, C#, Interface, Object Oriented Programming

C# – Abstract Class vs Interface

Abstract Class Interface
Multiple inheritance Doesn’t support support
Data Member contains Doesn’t contain
Constructor declaration contains Doesn’t contain
Definition May contain definition with no implementation Just a pattern, an empty shell
Methods Can have both abstract & non-abstract methods Can only have abstract methods
Implementation Can contain both definition and its implementation

Incomplete class, cannot be instantiated

Can only have the signature of the functionality without any code
Access Modifier Can have all access modifiers for member declaration of functions, subs and properties. Not allowed (all methods must be implicitly defined as public).

All the members assumed as implicitly public.

Homogeneity is used for implementations of the same type, behavior and status Is used for implementations that share only method signatures
Declaration Acts as a base class for all other classes, can declare/ use any variable Not allowed to declare any variables
Core vs Peripheral Core identity of a class & for objects of the same data type Used to define Peripheral ability of a class
Rigid vs Supple More supple More rigid
Fields definition Predefined fields & constants Fields cannot be defined in interfaces
Posted in Abstract Class, C#, Concrete Class, Object Oriented Programming

Abstract classes vs Concrete Classes

 

Abstract Class Concrete Class
Type Base class Default class
Methods May contain partially implemented methods All methods are completely implemented
Functions Some or all declared functions are purely virtual No purely virtual functions
Instantiation Cannot be instantiated Can be instantiated

Image Courtesy: tutorials.jenkov.com, stackoverflow.com

Posted in ASP .Net, C#, MVC, SQL Server Report Services, SSRS

SSRS (SQL Server Reporting Services)

SSRS is a server side report by Microsoft. I used that to create interactive and printed  reports in my C#, ASP .Net MVC project when I need to have export the report from the view page to a file (PDF or Excel).

I design the reports by using MS Visual Studio 2012 and be able to test the preview of the reports.

rdll

It can connect to the MS SQL Server database as a data source

rdl--

 

and have the specific data set that can use queries or stored procedures,

dataset-

calculated fields and parameter values (entries for queries/ stored procedures).

rdl---

Then the report will be created and we can add table, text box and etc. from the toolbox and design the report like this:

ssrs

There is an option to edit the page layout and design the report or even have an expression for a specific textbox of the report; for instance if the calculated number is greater than zero make the field green and if it is less than zero make the field background red.

exp

=IIF(VAL(ReportItems!MeetExp.Value) = 0,”No Color”,IIF(VAL(ReportItems!MeetExp.Value) >0,”GREEN”,”RED”))

After all these, we can test the report by preview tab and verify it is working correctly.

There was an issue that in the PDf I had some blank pages; the solution is: modifying the Margins of the report.

In the Design tab of the rdl report, right click on the grey part (outside of the report’s body) then select “Report Properties” and then change the width and Height to a bigger number.

margins

This can fix the problem.