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.

Until recently I didnt properly understand the power of interfaces. Now that I do and have used them properly I noticed the quality of my code has increased significantly.

What other language features (correctly implemented) are essential for writing great code?

share|improve this question
    
Hi Tom, while open-ended lists might make a great Reddit or Hacker News topic, they're not a fit for the Stack Exchange style of Q&A. If there's a specific problem you're working that has you thinking about this, feel free to ask about that instead. –  user8 Jan 6 '12 at 19:15
    
I'm not sure pointing at features will get you the answer you seek; at least not at first. Any language feature can be used to create great code and/or code that’s downright evil. Start with understanding the patterns that make great software. They've remained largely unchanged for decades, and are a much better guide to start with. Take Interfaces for example. It's Object composition, and coupled with patterns like Dependency Injection and IoC code can become flexible, testable, etc. Once the patterns are understood, combine language features to help realize your patterns –  JoeGeeky Jan 6 '12 at 19:24
add comment

closed as not constructive by Oded, Mark Trapp Jan 6 '12 at 19:14

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.

3 Answers

Your question as stated can receive a rather broad answer:

  • Inheritance
  • Abstract classes
  • Access modifiers (private, protected, public)
  • The readonly keyword (immutability)
  • Exceptions: throw, try...catch and try...finally
  • Generics
  • Events (even though you can also roll your own without the need of the language)
  • The using keyword for IDisposable
  • The ref and out keywords

The above are essential.

The following are useful:

  • structs vs classes
  • The yield return keyword for IEnumerable
  • Properties
  • Linq
  • Attributes
  • async
  • Extension methods
  • Delegates
share|improve this answer
    
@JeffO !LOL OK, I will change it. –  Mike Nakis Jan 6 '12 at 18:21
2  
+1 - This would make a solid list of things to learn. –  JeffO Jan 6 '12 at 18:27
    
+1 for actually answering a question, unlike me. –  MainMa Jan 6 '12 at 18:44
1  
@MainMa no, I think you have given an essential answer, and the OP needs to take both of our answers into consideration. –  Mike Nakis Jan 6 '12 at 18:53
add comment

Not all code needs interfaces, although they're common. Not all code needs lambdas, although they've got their moments. Not all code needs delegates, or inheritance, or arrays or... oh, you get the idea.

The important thing is to use each language feature when it is appropriate. That requires knowing all of the features of the language. Nobody's going to look at a piece of code and say, "Oh, this is using ABSTRACT CLASSES, it must be good," unless the abstract class is the right thing to do in that situation.

share|improve this answer
1  
I didn't get the impression the OP considers Interfaces or anything else as infallable and always leads to great code. –  JeffO Jan 6 '12 at 18:32
add comment

Every language feature you learn will increase the quality of your code. This applies to LINQ, to lambda expressions, to interfaces, to delegates, to optional parameters, to code contracts, etc.

None of the language feature you learn will transform by itself a good code into a great code. Years of experience and learning will.

share|improve this answer
3  
+1 "None of the language feature you learn will transform by itself a good code into a great code. Years of experience and learning will" Good code isn't something you just plug in. –  System Down Jan 6 '12 at 18:16
    
+1, Even good code because bad code if used in the wrong place and time or way. –  Malfist Jan 6 '12 at 18:18
    
And some features you need to learn enough about so they are avoided. –  JeffO Jan 6 '12 at 18:33
    
optional parameters turn good code to bad code way more than they improve code. –  Ryathal Jan 6 '12 at 18:57
add comment

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