tags:

views:

588

answers:

9

.Net is a huge framework with some functionality that appears to target beginners or becomes problematic if much customization is involved. So what functionality available in the .Net framework do you feel professional developers should avoid and why?

For example, .Net has a wizard for common user management functions. Is using this functionality considered appropriate for professional use or a beginner only?

One component/feature/class, etc per answer please so votes are specific to a single item.

Thanks in advance for your input!

+13  A: 

Typed DataSets
ASP.NET *View Controls
ASP.NET *DataSource Controls

John Sheehan
What's wrong with DataSource controls?
Slace
DataSource controls generally makes separation of concerns very hard, and you usually end up having SQL commands sprinkled all over your presentation layer. It works for someone who has never built a website before, but is (and should be) considered bad practice for proffessional programmers.
Tomas Lycken
While that's true for SqlDataSource, I don't think it applies to ObjectDataSource, which allows good separation.
Scott Ferguson
I don't see the point of the ObjectDataSource control frankly, when you can bind your controls on page load. As a web developer it irks me to see "markup" like the ObjectDataSource in my html that clearly isn't markup.
Bayard Randel
Why typed datasets? Not disagreeing, I just don't know enough about them to know what is bad. More explanation would be great.
Simucal
I think typed DataSets are a freaking godsend, but there's certainly a point on the learning curve where they just don't seem to do anything right.
Robert Rossney
I'm way past the learning curve. They are just verbosity in most cases created by a non-person but once it exists developers are stuck with responsiblity for it anyway.
le dorfier
What if you add the datasource control to the page from code? It is not in the markup, and yet you get all its functionality?
Slavo
datasets and views makes the developer a dull boy
zzzuperfly
+1  A: 

Thread.Abort

Here is an excellent article by Ian Griffiths about Why Thread.Abort is Evil and some better alternatives.

JayMcClellan
Thread.Abort isn't evil if you're using it during process shutdown.
Will Dean
Yeah it's lovely when you check if thread aborted in 100 different places(!)
dr. evil
+3  A: 

I think generally most controls/features that do a lot of work "behind the scenes" can cause a lot of trouble. No problem using a GridView if that layout is exactly what you want - but it very rarely is, and a Repeater is probably a better choice. UpdatePanels can save you lots of work if you want an ajaxy feel to your site, but compared with a jQuery AJAX call they - sorry to say so - suck. The user wizard you mention can be really useful during development, but if membership functionality is required in the project it should be built as an integrated part of it.

So in summary: Proffessional programmers should do the job themselves and write code that specifically satisfies their clients needs, and only take in ready made parts of the .Net Framework when that is in fact exactly what they need.

Tomas Lycken
Be careful with "Proffessional programmers should do the job themselves and write code that specifically satisfies their clients needs, and only take in ready made parts of the .Net Framework when that is in fact exactly what they need."That's true to a certain degree, and then it becomes NIH. There is a benefit to using a ready-built component, even if it isn't exactly what you would have designed.
Matthew Flaschen
the "black box" nature of webform controls is a constant source of frustration for me.
Bayard Randel
Bear in mind that this question extends beyond just ASP.NET.
Adam Robinson
I hate being resposible for the quaiity of code written by the IDE that I'll never use and wouldn't want anyone else to use either.
le dorfier
Matthew, what I'm trying to say is not necessarily that we should reinvent the wheel every time we need it, just because we need a different size of wheel. If the customer requests a wheel with a radius of 2.51 inches, maybe they can make do with a 2.5 one - especially if there is one ready to be used and production costs will decrease. But as le dorfier pointed out, a proffessional programmer is responsible for his or her code quality and should make sure that the code actually meets the needs.
Tomas Lycken
+7  A: 

MS Ajax

jquery, and other js frameworks like prototype etc., are a more lightweight and flexible alternative. The MS Ajax controls may seem great initially, until you really need a custom behaviour out of the scope of the controls.

Microsoft themselves have recognised this to some extent in that jquery will be bundled with upcoming versions of visual studio, with intellisense support.

Bayard Randel
+1  A: 

Linq To XML

XmlDocument/Xpath is easier to use, if you want strong typing to parse your document use xsd.exe or Xsd2Code.

EDIT

which one do you prefer ?

IEnumerable<XElement> partNos =
    from item in purchaseOrder.Descendants("Item")
    where (int) item.Element("Quantity") *
        (decimal) item.Element("USPrice") > 100
    orderby (string)item.Element("PartNumber")
    select item;

or, with XmlDocument and XPath

var nodes = myDocument.SelectNodes("//Item[USPrice * Quantity > 100]");
Nicolas Dorier
I think Linq to XML is very useful if you're writing XML. But if you're reading XML of any complexity, you'll wish you had something better.
Robert Rossney
"Easier to use" is a terrible defense, especially since it's not true :) Also, LINQ to XML is not about strong-typing your XML for parsing. It's a way to query your XML. From my experience LINQ to XML excels with extremely complicated XML and creating documents with it is much faster than the older alternative. You guys should re-evaluate your opinions of it and really dig deep. There's a lot more there than I think you both realize.
John Sheehan
Ok I'll take a look to linq to XML one more time, but I really think that a query with XPath is cleaner and easier (1 line of code).I've not tried to create a document with it. But why not using xsd.exe and Xsd2Code with linq to Object ? you have the benefit of strong typing.
Nicolas Dorier
also you can write this so much easier with XPath, you don't have to use LINQ2XML
dr. evil
Your doing it wrong. The real power of Linq to Xml comes from its type projection capabilities while still allowing you to use xpath.from x in myDocument.XPathSelectElements("//Item[USPrice * Quantity > 100]") select new SomeType() { Property = x.Element };
jfar
@jfar, I didn't know that you could use XPath with a XNode or XDocument, { Property = x.Element }; means that x.Element is casted implicity to the type of Property ?
Nicolas Dorier
A: 

.Net is a huge framework with some functionality that appears to target beginners or becomes problematic if much customization is involved.

It's the "appears to target beginners" that's the real problem.

Typed data sets are a great example. VS provides a nice simple UI to functionality that should be used only by rank beginners building extremely simple demo applications and experienced professionals who understand every nuance of the ADO.NET object model and what typed data sets are actually doing. Nobody in between those two poles should touch it, because there's a good way to learn every nuance of the ADO.NET object model and typed data sets aren't it.

Or take LINQ. It's seductively easy to write LINQ code without having a good understanding of IEnumerable<T>. But it's not so easy to write maintainable LINQ code without that knowledge.

Robert Rossney
Both are cases of functionality that a good developer can write more succinctly with greater simplicity and add yet another abstraction level that usually adds no value. Sometimes it seems to me that some pros use it so they can sell their books.
le dorfier
A: 

You can think of .NET like an onion with many layers. For example the .NET compact framework is a subset of full .NET. Further there are "extra" layers on top on .NET in the form of "Extensions" which are optional installs for new features which have not yet been made part of .NET proper. An example of this would be when Microsoft released ASP.NET 3.5 Extensions which has now been rolled into .NET 3.51.

Another way to think of .NET is as a set of "libraries" you can use. For example there are a set or routines to support RegEx. If you want or need regular expressions, then you use these functions, if not you can simply ignore them. SImilary functions for things like trigonometry or security.

So I guess it really boils down to what do you need for your application? If you are doing scientific programming you may well want the trig functions. A graphical app will require functions that a console application would not. Web apps probably do not need to use the clipboard functions etc.

I really don't think there are any bad APIs in .NET, just programmers who use them in inappropriate ways.

JonnyBoats
+1  A: 

Remoting is generally a good one to avoid, at least if you're targeting 3.0 or above and can therefore easily host messaging endpoints in-process.

itowlson
A: 

There is lots to avoid in the WinForms library.

Avoid DataBinding to most standard WinForms controls. There are many bugs in that area which will lead to lots of head scratching. Or at least that has been my experience. NumericUpDown is a good example of this buggy mess.

Also avoid the standard WinForms controls when dealing with large datasets. They do a lot of data copying and can't deal well with large datasets.

Avoid ListView in "Virtual" mode as it is full of bugs.

In general I just recommend staying away from WinForms. If you have the option go for WPF or at least buy a good, well supported (and hopefully less buggy) 3rd party forms library.

orj