Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

A page built so that is has server side scripts implemented on the page.

Should indentation of the code be according to the server side logic (making it easier to read while coding) or according to the HTML/ASP.NET markup (making it easier to read while debugging etc.)?

share|improve this question
add comment

1 Answer

For "pure" ASP.NET, there isn't really much of an issue because by design, the aspx page and the code-behind document are separated: the code-behind document follows the indentation rules of the language used (C#, VB.NET, ...), the aspx page follows HTML markup.

If your ASP.NET pages contain e.g. JavaScript-like scripts, then I try to minimize their occurrence on the aspx page itself and try to isolate as much of it as possible in external files (that would then follow their own indentation).

Apart from this, I always let every language have and keep its own "default" indentation. But let's be honest: this is about more than ASP.NET. It's about making consistent choices in your programming habits. It's not about writing code you can print out and frame. It's about consistency. Choose a set of rules within the range of established possibilities and stick with them.

Check out articles like Top 15+ Best Practices for Writing Super Readable Code. It's packed with good advice. Undoubtedly, there are many others, that can offer valuable insight as well.

(If you're in a work environment, team habits or team rules may apply: dear employee, please do as we do. That makes sense.)

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.