views:

675

answers:

10

I don't know LINQ, but from reading a lot around this site and others, it's a MUST HAVE skill for C# developers.

The problem is I am so booked on projects at work I have no time to pick up LINQ, I need to convince my boss to let me (and fellow coders) set aside some time so that we can become a LINQ house.

So.. my question is, what are the productivity gains? (percentages or some kind of solid numbers, maybe even estimates) What are the security, maintenance, etc, advantages?

I'm looking for something a little more solid than anecdotal evidence, he's not a tech guy, so I have to speak it in numbers, numbers that translate to dollars and cents.

+1  A: 

Tell him that everywhere you loop through objects and data you can use Linq and this will increase your productivity and quality.

After that you can search your code and tell how many times you could use it.

Gerrie Schenck
Maybe you missed the part where I said hes not a tech guy? "everywhere you loop through objects and data you can use Linq" translates to gobledey gook to non coders.
Neil N
+22  A: 

Well I'm perhaps the wrong guy to answer this but then again I'm opiniated so what the hey.

I don't really believe in training courses. They're expensive and hte idea that you can turn someone into a C# or Java developer in a week is, well, patently ridiculous, a waste of $4000 and a loss of a week of developer time.

No time at work? Let me put this in perspective for you. Imagine you were at an interview. I, as the interviewer ask you this question:

Q: Have you learnt any LINQ?

And you gave this answer:

A: I'm on so many projects at work I have had no time to learn.

Do you know what I would do? I would politely thank you for coming in, tell you we'd let you know and then toss your CV in the bin as soon as you were out the door.

Why? Because developers--good developers at any rate--take their own time to learn new stuff. It's an ever-changing industry and the rate of change is substantial. Good developers learn something not because there's some commercial advantage in it or not because it fills some perceived CV gap and definitely not because they've seen a lot of jobs advertised that mention it.

Good developers learn new things because they're interested in them.

If you're relying on work to give you the time and motivation to learn something then sorry, you are just lacking in motivation.

cletus
you missed just about everything in my q. that or I wasnt detailed enough.Good developers learn on thier own time? Guess how I learned everything I know now? I guess I'm a bad developer because I spend basically every waking minute that I am not in the shower is devoted to my projects.
Neil N
It IS possible to run out of time. Perhaps a developer who always has free time is the one who I wouldnt want to hire.
Neil N
"And, like we all eventually learn, the best advice you’ll get in life hurts like hell at the time. Because it has to." - Merlin Mann (http://www.43folders.com/2008/12/03/real-advice-hurts). It's harsh advice, but it's true to my own experience as well.
Andrew
Granted, but I've just not been as terribly interested in learning Linq, what if I told you instead "My topic for the last few months has been SharePoint?"...now what do you say? Presumably if the job is Linq, I'm probably shown the door anyways but hey...
tekiegreg
I take great offense to this answer. So basically after putting in counless hours on a project any "good" developer will also take time away from health and family to learn more technology that may or may not relate to what they're working on? -1
Steve Brouillard
Having rereard the question... I don't think I missed anything at all. You get as much out of a job as you put in. If you already know/use C# then the leap to LINQ is not large.
cletus
@Steve: if you want a 9-5 job might I suggest McDonalds, Walmart, the Gap or many other fine retail opportunities. "Time away from health and family"? Cry me a river.
cletus
Steve Brouillard
Doctors, Lawyers, Teachers, Engineers and many others are expected to maintain a current understanding of their profession and in any of these cases if they work for a company (as opposed to for themselves) such time and training is routinely accounted for and provided to some degree...
Steve Brouillard
I'm hardly suggesting that you shouldn't take any time to learn a new technology, what I take offense at are the notions that A. If I don't spend every spare waking moment becoming intimately fmiliar with every new thing that comes along, I am not a "good" developer...
Steve Brouillard
B. That is is ALWAYS incumbent on me to go out and leanr those things that will be useful to my company. As an employee that sees plenty of folks in other disciplines within the same company receive on average several weeks of training per year...
Steve Brouillard
I find it disingenuous on the part of many companies to simple expect it as a matter of course and dismiss those that don't have 6 months of experience with the latest killer skill that's only been out of beta for 3 months, want you to stay completely up-to-date at all times..
Steve Brouillard
and simultaneous tell you that "taking a week of the company's time and $4000 of the company's money" to be a waste of resources, while the same company would be happy to spend 10s of thousands of dollar to get similar productivity gains in other aspects of their business. It's hipicritical at best.
Steve Brouillard
Of course, they'll all tell you, "of course you should balance life and ypur profession", but then you do the math 8hrs work (assuming no OT), 7hrs to sleep (you don't need that much do you?) 1-2 hours commuting (if you're lucky)...
Steve Brouillard
Steve Brouillard
Oh, but what of the weekends, you say? Let's see, I have children, would like to spend time with them OTHER than getting them ready for bed or to be elsewhere, let's not forget the things that need doing around the house, paying bills, housework, yard work, repairs...
Steve Brouillard
Oh, AND I go to school part time, in part so that I CAN keep up with what's out there because I AM interested. I'm not suggesting for an instant that you shouldn't spend time learning on your own, I just don't think that a company should expect the burden to be entirely yours...
Steve Brouillard
..particularly, when they've shown that they don't hold that attitude when it comes to members of other professions in their ranks. Luckily for me I've found a company that feels their developers deserve training when they can budget for it. I also beleive that...
Steve Brouillard
...it's incumbent on us to NOT perpetuate the stereotype that all developers are geeks and LIVE to do this 24/7. I LOVE my profession and spend a great deal of time trying to stay up to date. Is it too much to ask that my compnay lend a hand? Then the compnay wonders why the good developers...
Steve Brouillard
...never really stick around. Hmm, if I have to drop my dime to invest in myself ALWAYS (and ALWAYS, is the key word here), why should I be concerned about whether a company can afford the cost associated with hiring a new developer when I jump ship for more money?
Steve Brouillard
OK, fine that was a hell of a rant. I simply find it very frustrating when it seems as though you have to always be on your own...sigh.
Steve Brouillard
Sounds to me like you've got deeper issues (with your company, your profession or both) than Linq training. To me it sounds like a combination of being burnt out, frustrated and dissatisfied. Not good. You need to change something. Could be your company, your attitude, your career, etc.
cletus
And yes that is by far the biggest comment-rant I've ever seen on SO.
cletus
I didn't want to put it in an answer as that wasn't appropriate. I am frustrated with my profession, or more to the point with IT in general. I LOVE working in IT, I really enjoy providing solutions to problems using technology...
Steve Brouillard
and though it may not be obvious in this rant I DO love to learn new things all the time. Is it completely unreasonable to ask for a little help with that when that learning will also benefit my company?I don't think I realized what a hotbutton that was for me until I commented on your answer.
Steve Brouillard
+10  A: 

Linq can lead to drastic reductions in line count, when manipulating data.

E.g. use

using System.Linq;
var index = collection
    .Where(i => i.SomeCondition())
    .ToLookup(i => i.Key);

instead of the much more verbose

var index = new Dictionary<Key, List<Value>>();
foreach(var i in collection)
{
    if (i.SomeCondition())
    {
        if (!index.ContainsKey(i.Key))
        {
            index[i.Key] = new List<Value>();
        }
        index[i.Key].Add(i);
    }
}

That's a factor of two in LOCs, even on such a trivial example.

Even if you do not get any time for formal training, you can try to spend a minute every time you have to loop over a collection to look into some Linq reference. It may pay off in reduced typing and improved legibility faster than you'd expect.

David Schmitt
Not really LINQ, but what the heck :)
Jesper Blad Jensen aka. Deldy
Those extension methods are in the LINQ namespace.
spoulson
@Deldy: I'm no fan of the "extended" syntax and prefer calling the interface directly for reduced "magic-ness". @spuolson: thanks, added the namespace for clarity
David Schmitt
+1  A: 

LINQ is a language construct that can query just about any iterable object, not just databases. This includes lists, dictionaries, xml, sql, etc.

Its this unification that makes it powerful. You no longer need to write annoying helper functions to do simple things like "find every string in this list that starts with the letter A", instead it becomes a single LINQ statement. Likewise, the exact same statement can be used to query a similar SQL structure by simply pointing it at a different data source.

Not only does this make things easier, it makes things significantly more consistent. Each of those helper functions could potentially be poorly coded by a peer, or contain bugs, or need to be organized into some messy "helper library"; all of this is moot with LINQ.

Also, Visual Studio 2008 has native support for LINQ queries, meaning you get intellisense for free. This is not the case with raw SQL statements in strings, or even SQL data adapters beyond the auto-discovery of the adapter's own properties.

So to sum it up: Unification and consistency.

Soviut
+3  A: 

If you can convince your boss to let you learn new programming languages and technologies on company time, more power to you; but I wouldn't expect to, if I were you. Learn it on your own and help your fellow coders do the same.

mquander
+1  A: 

I believe that LINQ increases coder productivity, decreases line count, and decreases bugs. Writing loops can be difficult when the logic is convoluted. LINQ allows you to implement many relatively complex operations in a much smaller number of commands, with the benefit of MS doing all of your testing. Additionally, LINQ is much closer to how the human brain works. Everyone understands Orderby and Select intuitively, while the loops to implement these operations are not necessarily intuitive. Additionally, MS will continue to optimize the LINQ queries and at some point provide an automatic parallelization. While loops are difficult for the compiler to automatically parallelize, expression trees are not. Sometimes you will need to specify the parallelization (i.e. PLINQ), but eventually, many of the LINQ operators will probably be parallelized.

Steve
+2  A: 

Edit: I read the question as "Help me sell linq to my boss" rather than "linq training". Linq is extremely useful and it's use should be encouraged, but I don't think that it requires training. It's all very well documented online, and the concepts should be familiar to anyone who's ever written a SQL query.

We just had one developer (me) do a bunch of reading and give a quick intro to other developers and went from there.

As for my original linq justification:

The biggest selling point for me is that linq lets you perform many list manipulations in a way that does a lot better job of expressing your intent than the non-linq way.

If you look at all of the places in your code where you're looping over a collection (whether with a for loop, or a foreach loop) chances are good you're doing one of (or a combination of) three things:

  • mapping (transforming each element into something else)
  • filtering (finding all elements that match a certain criteria)
  • aggregating (eg. calculating the sum of a collection of integers)

For example, filtering items out of a list is a reasonably common operation (at least for me). The non-linq way requires a foreach loop and an if at minimum:

foreach(Car c in cars)
{
    if (c.Color == "Red")
    {
        newList.Add(c);
    }
 }

There's a lot of accidental complexity there for what should be a simple operation. Compare the linq equivalent:

var filteredItems = from car in cars
                        where car.Color == "Red"
                        select car;

In my mind, that's a lot more readable, and exactly expresses it's intent.

John Price
+1  A: 

A more appropriate approach would be "Help me sell LINQ to my boss".

spoulson
+3  A: 

You coulda spent the time you spent reading these answers and posting the question learning a lil bit of LINQ. If it is "MUST HAVE" then grok it yourself as it is part of your own development.

From the business viewpoint it is just syntactic sugar that doesn't add any direct business benefit as learning another tech might, so to be brutually honest I think you're going to have to rely on some fuzzy logic to justify it, which is going to be hard to prove.

Quibblesome
+5  A: 

You don't. Instead of going on a course, you spend 15-30 minutes reading about the basics, and then you start using LINQ. When you get stuck, you spend another 10 minutes reading, and then you use it some more.

Helen Toomik