Categories
Article Blog: My thoughts

Next step to development team

In my last post I try to define what motivate me to learn new things. Also, I try to show that I really believe in learning new things. In this blog, I will try to define the basic things a team need for developer productivity. This list may not be what most agree, some might see it incomplete, some might found it over burden. But this works well for me till now, and if I found something better I will change this. But from my experience in sub-standard teams and project this will be a good start.

First, there needs to be a team. Yes, that is first requirement because often there is no team to work, there are individual who just do their work. The team consist of at least two entity, at least two human. Now, you might question that I work alone so how I am referring a team to be of two entity. So to answer it, the first person in team is the Client, and you are the second person, the developer. Client is always the first person in team. He/she must be ready to accept you as his team. This is where team builds. If, he just think he hire you for the job, then he will only get a contracted human resource. He will never get a person who even try to understand his business needs. And if that happens the game is over before it starts. This doesn’t mean the role of developer team is reduced, or all the burden is on client to make team. Developer should be truthful. He should be the one, a client can trust on. It doesn’t matter if you fail to achieve deadline, if doesn’t matter if you fail to deliver the expected product. What matter is at end client doesn’t think he is been cheated. He doesn’t feel you are not skilful enough for job. He should not regret his decision about choosing you.

Second, part of ideal setup comes, with tools you use. How you protect what is been done? How you ensure reliability of software/code you are writing? How you ensure that it works on load? What will happen, in case you are not available to maintain the software? Are you using out date technology? Are you using immature technology? And most importantly, how does it affect client and his requirement? I often see these question are neglected at small scale. Developer mainly think, it is small project and not worth taking all extra in account. If we reduce those Version control, documentation it cost less to client and we gain project over competitor as we offer same solution at low price. If you are looking for developer, ask him to explain his stand on above question. And if you like answer then only choose him. I am not saying everything must always be included, but if you understand the risk/profit of not include all these it is win situation.

Third thing is communication medium. This is another important setup. Often, developers are not available to receive phone calls or chat. They reply email after 2-3 days, while client wonders if you are still alive. Same happen when developer ask for feedback and they get a reply after a week saying, “yes”. Whereas developer was asking to choose between two possible scenario or asking to define a problem. You must set a communication channel between all members of team. And there must be a definite time frame between replies. Even if there is nothing to reply, just acknowledge that message is been received.

Once you master these three things, a first step in ideal setup is been done. If you are developer, please always be truthful to client. I am tired of doing Editing job of some other developer’s failure. I want to work on new project more. I am not your debugger.

Categories
Article ASP.NET HTML/CSS PHP Programming

PDF Creation: wkhtmltopdf

In past I post about how good wkhtmltopdf is. I have used it for few of my projects. Really it is the cheapest [as it is open source and free] and powerful solution. But it is not the reason I love it. I love this because it is the Easiest solution available. Most of PDF library range few hundred dollars to start with. Then we learn through their call of function to draw Tables and add media content and text. But with wkhtmltopdf, all you need to do is simple create a HTML page, add CSS and Javascript (yup, it support jQuery’s document load function and other other load method of your favourite javascript library.)

I recently test jQuery load function as I need to write text as Arc, however I don’t want to use Image as image manipulation will generate a rectangle image and then placing it going to be problem. But with wkhtmltopdf, and it’s support for JavaScript it make my life easier. I use a cool ArcText js following a nice article/tutorial http://tympanus.net/codrops/2012/01/24/arctext-js-curving-text-with-css3-and-jquery/ .

And yes, I recently saw that develpoment of wkhtmltopdf has started again. So this is going to be very good for those who want easy and best solution for their application.

Categories
Article ASP.NET Bookmarked C#.NET PHP Programming VB.NET/VB

WKHTMLTOPDF: A Free PDF solution

As any other developer we often find it difficult to get a Website to print something accurately, specially when printing labels for mailing as they are outside the default print area for most browser and no client want to adjust or memorize the print setting to adjust them manually. Also it doesn’t make sense to relay on client to do adjustments.

So the only universal solution I found is.. of course PDF files. But how do I create PDF. Well easy enough use some library. I did that I use iTextPDF very good Library that works for my C# project well for couple of years. But then what is the problem now? Well iTextPDF is now have commercial license at ridiculous pricing in fact it is now most expensive to any other paid software. Yet another Open Source project going paid on success. 

Also, there is a problem with library like iTextPDF that they need you to draw each and every element programmatically more often or not. And you find yourself caught in a web of long written code. I remember one of my report’s PDF generation code goes 1000 lines. I hate it. So, the best solution is to Generate PDF from a HTML source. We can handle HTML much better way and rather easily with our skills as web programmer. And even a designer in team can change PDF design giving time for programmer for other work. 

In this regard I look for free alternative of iTEXTPDF, which does have HTML parser to generate PDF from HTML file, and my search for now ends on http://code.google.com/p/wkhtmltopdf/ (wkhtmltopdf ) project. A Simple Executable that I can call from a my code to execute and it does the parsing. 

It is not really a good idea to call it through web page, but we should create a Windows service and use it there, but I have successfully test it to work on web server with quite a load and at least with my limitation to access Windows Service I can live with it running through HTML page, after all my PDF is just 1-2 page and it works fine. Will post code for it some other day. But do try it if you want a good and quick solution to your problem.

Categories
Article Blog: My thoughts Database MS SQL Server MySQL SQL SQlite

Database Optimization

Well, most of program use database for their web application. Eventually all web application does have database. But how many of those web application really works good. Well quite few. I am in web programming for more than 7 years now and during these years I have seen lot of developers building website using PHP or ASP.NET or ASP or PERL using SQL SERVER, MYSQL, Oracle or other database, but I always have a sense of making best application than them. But today I when I look back I realise that I was bad at writing code and making application in my initial years. Not that I don’t want to write a good code, but the fact my approach was not right. Some of the important thing that I learn over the year based on my experience are listed below. However before that I want to tell that not just me but all of us have read them in books but most of us might not have used it thinking we don’t need it as things works otherwise as well. So major stuff are:

1. Fast Database

2. Object oriented Code

3. Serialize flow of application.

In this post I try to mention Only Fast database. Well with Fast database I do not mean to pick the Fastest database on planet through bookmark testing, nor does I mean to use heavy hardware to make database run faster. These two things can really make your database appears to be faster but not really fast. I often ask a question in forum that I have few million records to parse, and can the DB engine handle it. I always get one answer if a database cannot handle few million record why we really need it.

This was very true statement, but do you really facing problem when you have only half million record and your site start taking 20-30 second to access database ? If so, then welcome to my past world. Well don’t worry you don’t need new hardware, you need new approach of programming your software and most importantly you need better database structure.

Starting with most commonly used stuff and I guess most importantly forgotten stuff.. Indexes. Yes, this is most common solution to make your site fast. Okay, so you already have define primary key in your table and it auto create index for it, but still not good enough. Well you need to index columns that you have used in your search and or in Join. Making index of one column does help, but making index of combination of 2 columns make it much better in queries that use the search on those two fields. For example, if you are searching Employee Last Name and their City from Employee table, having index on LastName and City seperately produce result slower than having index on Lastname and city name.

Now moving to next part of it. I have a sql query that has Client Code and User code in seperate column and I have a text box that allow user to enter ClientCode – UserCode in there, and I have to search it in database. I got little lazy and what I did I took the Textbox value as it is and did something like

where ClientCode + "-" + UserCode = @MyClientCode

Now, this looks good and works well for me, but this is not a good approach of writing it. In where clause never do the combination of column like that. Search easy column seperately, i.e.

where clientCode =@ClientCode and UserCode =@UserCode

the difference make your search works 10-15 times faster if you tend to have lot of records.

Third thing that comes to my mind is normalization of database and then creating views with indexes on view to join them if needed. I often see that database is not normalized and lot of Text field are used to store combination of values. For example if you want to have a product in different category then make a table Product_category, which store product ID and CategoryID, instead of storing comma seperate category IDs in product table. This seems awkward at first to change, but advantages are real. You can search product on category much faster as only Integer values are compare against the Regular expression match in comma seperated values. You can index the value in relation table, but not in text field. This approach is very common in developer in sub continent. If I am not wrong 70% of sites I see from other developer has this mistake.

Above are some error in design of database I have seen and some of them I did at my start of career, but I change my approach and today I am handling database with more than 10-20 million entries easily. Infact my site took less than 1 sec to search with a three table join. I remember the old version of this join that took 15 secs. I did great optimization there.

Anyways, making a software is your work, making it great is your choice.

Categories
Article Blog: My thoughts

Are you Marketing or spamming?

Today I delete bulk of comment on blog moderation list. These guys took some effort to put their comment and I delete it. Because they are not commenting on article or entry, they are simply marketing their stuff. There is often such comment you will find on your websites, but is this marketting really useful to post such comments to personnel blog or company websites.

Hello, I am Mr. X and can help you get top rank on Google Search result. Try our SEO service.

I got these message very often, but hey I am already on top 10 results for keywords I want. Did you ever research that ? More over, this is not a business site, so why I want anyone to find my blog. I write it for my pleasure of sharing. If someone need my blog they always find it anyways.

If you are really wanting to market your service, there are certain rules to follow:

Categories
Article Blog: My thoughts Operating System

Why we don’t need VPS?

Late last year, I was pretty happy to have a budget to take a VPS for my company. This was first server that we own. What a great feeling to have it. But soon the great feeling becomes a nightmare. It was not that hosting company is not that good, it was just that the VPS are not good in general. I am talking about it after using atleast 10 VPS server from 3-4 different companies. Fortunately I invest only in one of them.

Coming back to topic, here are reasons why I hate VPS now:
1. VPS is said to be cheaper, But for whom? You or hosting companies? Companies with good reputation or resources gives a VPS starting at $60 per month for just a 1GB RAM, with 30GB HDD. IF you compare it with Dedicate server with low end they ends up with 160 GB HDD and 2 GB RAM. for about $100. But to get that configuration you need to spend over $100. So comparatively they are not cheap.

2. When I buy a VPS I read that my VPS will be hosted on Cloud network and hence if a VPS fails for some reason it get up again on next node in network and reduce the downtime. Unfortunately my VPS Hosting GRID failed and it dump my data for 48 hrs, before they can fix the node. I was not alone but all people having their VPS on that grid lost valuble 48hrs waiting for their server. Later it took 15 days to get my hosting to move my VPS to new GRID as even after 48 hrs they said they still need to do few maintenance and my VPS will do roller coaster during that time. If I have Dedicated server and if some hardware fails it took less than 2 hrs to get it up live. But if VPS grid’s hardware fails who grid gets overloaded from other VPS and reduce performance. Plus changinge their hardware wasn’t easy. This is what I had experience on my server and unfortunately on client’s hosting when their Hosting [different my mine] fails for them too.

3. VPS should not be confused with Cloud Hosting. VPS are virtual machine, and even if they are hosted on Cloud Network they are not Cloud hosting for your purpose, they are as good as dedicate machine. IF your VPS fails, or shutdown, your website will be down. You won’t get shifted or reboot, becuase machine is down not a network. It is like notepad crashing on your computer. It do not effect computer otherwise. Cloud hosting are like shared hosting, where multiple computers store data, and a data replication happens on fallback node. then your webserver runs on different hardware on same grid and other application as well. So if say one web server fails there are other webserver available to take load of your application. But this is note the case with VPS machines. IF you take VPS you take a 1990’s computer as server don’t expect too much.

4. VPS is a concept of running more than one Operating system on given hardware. Like running Parallel to run Widows on Mac. Though it is been said that they share resources, but actually if you have a computer with 4 GB RAM running 2 VM with 2 GB RAM. do you think you get full 2GB RAM performance? the answer is NO. because at 4GB RAM there are 3 OS running. and one is using 4GB, while other 2 are using 2GB each, so they need 8GB in total, but it is not possible because we have 4GB. So the host operating system scarifice some of his RAM, maybe 3GB but it still be a 5GB. Same happens with CPU processing, Same with HDD. A HDD writes a 1xX speed if it has to write it for 3 OS will it write faster? no it still write 1xX and each os get only 1/3xX of speed.

In nutshell, if you are trying to save money by using VPS, then you better reconsider using a Shared hosting or a Dedicated server. Hosting 10 site on VPS will cost you $6 per month with no performance, where as shared hosting from decently good host will cost your just about same, but much better performance. And if you have enough money why not a Dedicated server or a Cloud hosting like Microsoft Azure, or Amazon S3 like services ?

Categories
Article Blog: My thoughts Concept/algorithm Programming

MVC : First Encounter

I have been reading about upcoming of MVC from quite few years, but I never feel the need of it. It is surprisingly but yes, I never feel of MVC in web development. I have created my own coding pattern which is good for most programming I have seen in my career. But still MVC always seems to attract me. So finally I decide to give it a try. I remember I try it with CodeIgnitor in PHP previously and was not very impressed with idea of MVC as I see it not quite upto the task as anyother framework it tend to load those load of script that are necessary to run MVC and the framework fine. Sometime you never need that many files. But still I was wondering why people look for something in that line? Well you never learn answer of such question unless you try yourself. So, I try it with .NET 4.0, when I got a chance to make a mobile website. I have to make a really small website and I feel it is best for to learn during this website development. I start it out with video tutorial and thanks to Scott Hanselman’s webcast I get my mind clear on MVC concepts in .NET and what is MVC in general.

Though MVC looks promising but I feel it is not probably not very mature or maybe not a good idea for big projects. I feel it little complex to make architecture of application with MVC as compare to transition event driven programming or procedural programming of old PHP. But yes it is way to dynamic and based on naming convection and assumption/concepts. Which make it cool. At first it looks good to me, but my second thought came in, if dynamic binding is that good then why we need Strong Data Type in applications? Why .NET or Java strats like that and why PHP is going for OOPS programming which again become strong data type somewhere? Isn’t it slow to use dynamic binding then to static binding?

MVC is good for Expertise in either programming, designing or database handling. This make it good choice for enterprise software but definiately for a Geek programmer I feel it is not upto the mark. BTW why a geek programmer care about what is buzz in market, he do his job perfect anyways.

I am confused about MVC , I am not sure if I will adopt it in my future programming yet or will wait for something better to come up. Any advice.