Posts

Smart Class in PHP using getter & setter

Hello readers, This article is about smart class in PHP so it will only contain business logic. In another article  Clean Code In PHP , I wrote about clean coding in PHP for beginners. But if you want to go for next level then this article is for you. Every developers must try to be smart in coding. If you have mastered some architecture, then don’t stop there thinking that you have learned smart way of coding. Frankly speaking I’m not smart coder, but yes I always try to apply new techniques to make my code simple and smart. Yes, your code must be simple, there is myth in most of the beginners mind that the developer who writes complex code, which is not easy to understand is smart programmer. But it’s not true. I’ll write more about it in another article. Let’s focus on this article. This article is one step to make class simple and more focused towards its business logic. Let’s take example of class file from article  Clean Code In PHP . <?php class Student {

RGraph Class Library Nuget Package (2.0.0): 3D Pie Chart

Image
This article gives steps for  RGraph Class Library  to create 3D Pie Chart in ASP .NET from dataset. RGraph is free JavaScript Library for creating dynamic charts using HTML5 Canvas tag. For more information about features and examples go to  RGraph Official Web-Site . In this article I’m going to introduce you to RGraph Class Library, which you can download from Nuget Package Manger. I’m going to use RGraph JavaScript library can be downloaded from  here . In many Web Applications there is need of presenting data summary in Pie Chart. Pie Chart allows us to analyse data using proportional sectors. In case of Simple Shop System Application, user can analyse per day sales of products in pie chart to determine the product in demand. Let’s see simple example to create 3D Pie Chart using RGraph. I have referenced some JavaScript files required for 3D pie graph as follows. <script src= "Scripts/jquery-1.10.2.min.js" ></script> <script src= "S

Memoization: Speed up expensive functions in ASP .NET

Image
This article is about Optimizing ASP .NET server side execution using Memoization technique. Before understanding Memoization, let’s discuss the simple but time consuming scenario first. Consider the simple example in ASP .NET Web-form, I want to create Table control populated with list of students and bind that control to asp:panel. The reason to consider this example is it’s really simple but time consuming when data to be populated is increased. Obviously we can populate gridview which in-turn will be rendered as table, but to demonstrate the memoization I’m going to populate data manually. Normally we will create Table WebControl and add TableRow WebControl for each student. First we want simple student entity class,which is as follows. public class Student { public string name { get ; set ; } public string description { get ; set ;} } Then added some method to get TableRow let’s say dataToRow, which is wrapped in HTMLtable class as

Data binding in ASP .NET using AJAX & SQL Database

Image
This post is illustrate the process of data sharing from server to client using AJAX. There are lots of advantages of using AJAX. The Main advantage of using AJAX is we just need to transfer data which is required. For example when HTML page loaded then for each subsequent operation (Excluding the redirect) we don't need to reload page again and again. Let's see how this can be implemented in ASP .NET Webform as well as ASP .NET MVC. Created simple product table, we will be retrieving data from this table only. I am using ADO.NET for database connection. We will use JQuery library to make an ajax call to the server. WebForm In case of WebForm, we will create WebMethod which will be called using AJAX. On Client side above webmethod is called using JQuery AJAX. The result is MVC In case on MVC, we will create Method in controller which will return JsonResult. On Client side in Razor it will be called using JQuery AJAX. The result is

Creating Hierarchical Structure in C#

Image
There are many instances encountered by developer to create hierarchical data structure. For example, Category Hierarchy in E-Commerce. Electronics Mobiles Android Mobiles Samsung Motorola One Plus Windows Mobiles Lumia Laptops Gaming Laptops Dell 4GB RAM 6GB RAM 8GB RAM HP 4GB RAM 6GB RAM 8GB RAM Appliances AC Inverter AC Window AC Almost in all instances this data will come from single table (Assuming data is stored in database). Table structure would be. Category Column Name DataType Description CategoryId bigint PK Name nvarchar(100) Not Null ParentCategoryId bigint default(0) All Category have ParentCategoryId value, which refers to CategoryId of column allowing us to perform self join.  ParentCategoryId=0 informs that the category don't have any parent.i.e topmost category. Now above hierarchy will be stored as follows: