Good and bad practice

mandelbrot

Centurion
Joined
Jul 1, 2005
Messages
194
Location
UK North East
Dear All,


I've just started using .NET to develop web apps, as previously I've only ever written code for Windows.

I don't want to fall into bad practice here, so I feel I must ask a few basic questions...

Firstly, is it good practice to embed HTML code in the (in this case VB) code that I'm writing?

Secondly, the distinctions between some of the controls used in .NET obviously differ from standard HTML tags; for instance, the panel control appears to replace both DIV and SPAN tags. Is there anywhere that actually clearly explains all of the differences so that I don't have to re-write chunks of code at a later date?

Thirdly, is there any advice you could give me that would save me a shed load of time later?

I've always found web programming to be a disorganised mess to be honest, so if anyone can convert my way of thinking, I'd appreciate it! ;)


Many thanks in advance,
Paul.
 
As a rule I would tend to avoid embedding any HTML in the code itself (too be honest I try to apply this rule to all languages - no SQL, HTML, CSS etc. in the VB / C#), it simply makes maintenance far more difficult.

The various controls such as Panel tend to render different tags based on the situation (browser being used being a major factor), under most situations I can't see why you would need to recode these later - as long as the appearance of the page is correct it shouldn't matter overly.

In terms of web programming being a mess - it still can be if you aren't careful ;) I would tend to utilise the server controls wherever possible, make good use of CSS rather than relying on .Net attributes for fonts, colours etc. I would avoid writing code within the .aspx pages and always take advantage of either code-behind or classes. For code being shared over multiple projects class libraries are a must.

If you are using .Net 2 then MasterPages are a great addition to your set of tools - along with SiteMaps and Themes; used sensibly these can be big time savers for any project bigger than a single page or two.
 
Thanks for your quick reply, once again, PlausiblyDamp!

I have to agree with you on the embedding of strings - it does actually go against my grain, also, and I try to avoid embedding SQL wherever possible.
Again, I do modularise my code by incorporating classes and structures - it saves so much time...

Unfortunately I don't yet have 2005, but am expecting a licence soon...


Thanks again,
Paul.
 
Just to expand on string theory...

I've just been looking at a few solutions on the internet to the training project I'm working on (a simple css web menu system), and have noticed that quite a lot (if not all, in one way or another) of the systems rely on JavaScript being embedded in the code.

It does appear that at some point I'm going to have to have some form of literal values embedded within my code. Am I able, therefore, to have static functions within a js file that I can link to my control or page? (Obviously this gives me the facility to then simply change the js in the file as opposed to recoding the whole app).


Thanks,
Paul.
 
Re: Just to expand on string theory...

A practice I got used to and that I find fun is to dynamically create labels and add html code to their text, instead of using .net user controls :)
 
Re: Just to expand on string theory...

Actually that methodology is used by various members of the team that I presently work in. Personally, though, I think this is a little shaky in the practice stakes! ;) As I said before, though, web-page design is a messy business!

Thanks for your input, Proka.
(PS: ElvenSoft - nice sites! Are they all constructed using .NET and Flash?)

Paul.
 
Back
Top