2 minute read

LESS is effective way to use Stylesheet for web-designing. The more technical you goes inside a technology then more rules and care you need in your code. How better your code is depend on how better you can refactor it or modify it in future. The more better your code are the better you can edit them. The trouble is CSS code are very easy to written but hard to write better and usable code.

Here is somethings I would like to share with you for better coding.

1 Never try to inherit every object with parent object.

Suppose you put .x . y .z .a .b .c this element that have class c is inside the element have class b. When you do this same more and more code are going hard to refactor in future. Thing for 2 second what object can be move in future.

Suppose header logo can be move from left to right. The widget on left can be move to right. This way you can easily modify the code in future.

2 Formatting LESS file.

LESS CSS have native support in Visual Studio Express (and above). I have checked it in update2 for VWD. in Visual studio 2012 there is a feature called Hierarchical Indentation. Use it. it’s well design to make your code easy to read.

3 tools to compile

it’s your choice to use Nuget Package or a tool that will compile the less file on your machine. I personally prefer to use standalone tool which compile my file so I can easily modified them after what they compiled.

4 Be creative, don’t make your habit to follow every rule from books you read

In Every CSS related book you find a lot of Rules, programmer’s habit and idea to follow to solve the puzzle. Every programmer have their habit and idea to solve the same puzzle. Maybe your trick are somehow different. Don’t try to follow every rules. First understand the way why we need such thing then apply it. CSS language have less rule then other language. Try to do thing differently then you already have tried. Sometime you will found some better thing you got when you tried something different.

If you found any mistake or update on this article please comment. I would like to make it more better for all my readers.

Thanks for read my post Smile

Updated: