Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I am very eager to learn in depth OOP concepts and most importantly how they can be applied in "real life". So far, I have read many references and many tutorials online but they all lack something: They do not provide a way to fully understand how object oriented programming can be truly used. In fact, it seems that most tutorial focus on OOP "syntax" as opposed to "the art of OOP design". Since OOP is a set of concept/idea/best practice in thinking about a problem and tackling that problem in a way to allow a better productivity I really want more. I want something to help me think as an "OOP designer" and not an "OOP programmer". Can someone provide with me a resource (preferably an online resource) that actually provides a non trivial example on how to apply OOP? Although I am aware that OOP is language agnostic, I would prefer examples in C#.
IMHO the best resources are not available online. This former SO post contains pointers to some very good books:
https://stackoverflow.com/questions/3315633/which-is-the-best-book-to-learn-and-implement-design-patterns-using-c
Check the following books;
Object-Oriented Analysis and Design with Applications
Code Complete
Design Patterns Explained
Not sure online versions avialable
http://www.amazon.com/Object-Oriented-Programming-Peter-Coad/dp/013032616X
Code Complete
http://www.exforsys.com/tutorials/oops.html
http://www.clear.rice.edu/mech517/Books/
Head First Design Patterns ( its in java but really good)
http://shop.oreilly.com/product/9780596527730.do
http://www.amazon.com/gp/reader/0201633612/ref=sib_dp_pt#reader-link
http://www.amazon.com/Design-Patterns-Explained-Perspective-Object-Oriented/dp/0321247140/ref=pd_bbs_sr_1?ie=UTF8&s=books&qid=1211844244&sr=1-1
Good question. I've read many of the books that are suggested here, but I still struggle sometimes with good object design. In fact I've become somewhat disillusioned with Object Design. I think two books that are worth reading are
Robert C. Martin - Clean Code
Robert C. Martin - Agile Principles, Patterns, and Practices in C# (but be aware that the C# code is a bit outdated)
see this question and answers: What is the single most influential book every programmer should read? there really great books mentioned there(not just OOP).
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
Sorry for the noob question but I've always had a hard time distinguishing situations when it's good to create a function or a class. For some of the smaller programs I write at work, I write a whole bunch of functions to carry out specific tasks. The programs all work as intended. However, when I have some of my more senior developers take a look to give me their critique, they rewrite a lot of my functions completely over as a class. These are my coworkers so I don't want to look completely incompetent (I just started this job as a junior developer) by asking them why they did that. What do you guys think?
That is too broad question and you really have to understand the concept of the Object Oriented Programming and when you should use it.
Note: Bellow you will find my personal opinions (some of them borrowed from great books' authors and experienced programmers), and for sure the things highlighted bellow, does not reflect the entire power of the Object Oriented thinking and design. These will be gained throughout experience and feedback.
0. A use case of a class
There are many applications, on where to use an internal class to your C# code.
Data Transfer Object (DTO)
One application (of really many) and is used many times in software, is when you are transmitting data from database to your application for processing.
What better than writing an internal class that will store your data, implement useful and re-usable methods that can be used later in your application logic (e.g isAdministrator) and so on.
1. Object-Oriented Design Patterns
I will recommend you reading a book about Object-Oriented Design Patterns.
Books like that, describe some problems scenarios that can be implemented with a class using a pattern. Once you have read about these patterns and possible scenarios on where can be used, you will be able to get the book, find the pattern and solve your problem.
A co-worker of mine, state something really useful. When you are facing a problem, you should ask yourself:
"Does this problem solved again using a design pattern?"
If the answer is yes, then you go back to your reference book to find your design pattern, that will solve your problem, without re-inventing the wheel.
This approach, will teach you how and when you should use a separate class; but will also help you to maintain a communication language between you and your co-workers, that is, if you are talking about your code to a co-worker, you will be able to state the design-pattern and you will be immediately understood (given that, your co-worker know about the specific design-pattern).
2. Don't be afraid creating more than one internal classes
Another note, don't afraid to create multiple internal classes. Implement as much as possible, don't try to implement one internal class and mix responsibilities. Your class should be for a specific purpose, and should not do more than one thing (i.e responsibilities, if you are writing a class that is about transmitting data from your database to your application logic, should not - ideally - doing something else, like adding data to your database).
Consider learn more about Polymorphism, Inheritance, Encapsulation and Abstraction.
These four fundamental principles of Object Oriented Programming can also help you to learn how to structure your code object-oriented.
3. General Notes
As a Junior-Developer and not only as a Junior but as a Developer in general, you should always willing to learn from the more experience guys, by asking for feedback. Is not a shame is the law of learning and improve your code.
Another powerful source of learning, is books, consider buy some for the area you are interested in. (e.g Object Oriented Programming, Design Patterns etc).
As others noted in comments, this is really too broad and slightly opinionated, but big picture, use a class when:
You maintain state over time, and apply functions to this state.
You have a set of functions that share a common goal or deal with a common usage, data type or otherwise "obvious shared idea". That's particularly relevant when these functions can be reused in other places.
But really, to get a deeper understanding, get a book :-)
BTW, in C#, you can't put any functionality outside of a class, so the question should really be "how to divide my monolith class to smaller classes"
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
Ok here is my situation. I've studied Java in my college for 2 semesters. But you know they teach you jack in there, just the basics. We skipped half of our textbook and even then our professors don't teach from section to section of each chapter. I don't blame them. It's hard as it is for new students to understand even the basic concepts of programming. Now this is a community college we are talking about and not Stanford, MIT or Berkeley.
So like I said I've done 2 semester of Java. I really like our textbook because it has some challenging projects to do at the end of each chapter. This textbook is pretty clear and i have no problem understanding it (although 2-D and 3-D Arrays have given me some trouble). I have tried reading a few C# books such as Pro C# 2008 and .NET 3.5 and C# 4.0 in a Nutshell. I found these books to be dry and overloaded with information that put me to sleep (No offense to the authors of those 2 wonderful, according to amazon ratings, books).
Would you suggest I finish my Java textbook, brush up my knowledge of Arrays, Polymorphism, and etc that are universal to most programming languages. And then switch to C#, plus the syntax is very similar so it should be easy to switch. Or should I just start learning C# right now from the very beginning? If it's the latter then could you recommend some free online resources that will keep me engaged and at the same time teach me everything I need to know about C#.
Someone has recommended me to learn .NET first, but I found it to be not the brightest idea. .NET is just a big monster full of libraries. How am I going to apply it if I don't even know the C# or VB!? Anyway back to my question: Master Java and switch to C# or just go with C#?
DISCLAIMER: I don't want to start .NET vs J2EE or C# vs Java flame war. I am going with C#. I've decided that I want to work in a Microsoft shop in the future. .NET is what I want to learn.
Thanks! Will be waiting for the answers.
I found myself in pretty much the same situation as yourself whilst studying Java at community college - I am smiling right now :). That was 10 years ago and D flat, as some wags were calling it, was starting to make some noises.
What I did, was do all of my assignments in both C# and Java, so that I could get to grips with both. I then begged to do my final year project in C#, which they eventually relented on. Getting practice in a couple of languages and doing a major project will stand you in good stead.
I have never looked back. Good luck! :)
Both Java and C# concepts and syntax are very similar.
I would concentrate on the one you expect to use after completing your studies. Look at which is asked for more often in the area you are intending to work.
As a side note, C# 4.0 in a Nutshell is an excellent book both for learning and reference. Suggest you give it another go.
I think I found the answer to your question...in your question.
For now, go ahead and finish your Java book as a way of continuing to learn the fundamentals of OOP.
Next (or while finishing the Java book), shift your focus to C# and the .NET framework (in most business situations, you'll be hard-pressed to find one without the other).
If you want to focus more on language elements of C# rather than a specific framework (such as ASP.NET, Silverlight, Windows Forms, or WPF, to name a few things), you might consider a book on LINQ, such as LINQ in Action from Manning Press. Combine your knowledge of LINQ with trying to solve some problems at http://projecteuler.net and you should start picking up the language pretty quickly.
Personally, I read Illustrated C# 2008 by Daniel Solis. Granted, it's not a textbook filled with lots of fun and challenging examples, but it is a good exposition of the language.
Don't worry so much about any particular language, and "Teach yourself programming in 10 years": http://norvig.com/21-days.html
Since it sounds to me like you don't really know a lot about programming, and this is largely your first major exposure to it, I think it's absolutely in your best interest to stick with something until you have learned enough of it that you are satisfied with your skill level. Jumping now may hurt you later, because you will be covering a lot of concepts you probably already know.. but hidden inside will be something you don't, and thus you will skim right over it.
Keeping yourself "engaged" is only something you can do, not the text. Certainly some texts are more interesting than others, but you have to be committed to reading the material whether or not you find it boring. That's how you learn.
Both Java and C# are syntactically similar at the basic level, but they both diverge from there in different directions and do similar things in different ways. Further, the languages are largely useless without the base class library, and those are often very different between languages.
What you didn't mention was how you are doing in school. Does your school require you to do more java work? If so, then you will have to stick with it. If not, and you are "done" with it, then perhaps starting over with C# from the beginning would not be a bad idea. Just think of C# as a new language you have to learn from the ground up, even if much of it seems familiar.
I found the Wrox book series to be particularly good to learn from, along with the Head First book series. As for which one to continue I would say it depends on what you are tested on. If you have to do written exams and write out sample code. You don't particularly want to start banging out C# by accident.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
Are there any books for C# developers that will help me to improve my performance answering programming questions during an interview? I need practice, and need to work on algorithm types of questions.
Introduction to Algorithms, second ed.
I'd highly recommend the O'Reilly book "C# Cookbook" since it will give you specific algorithm implementations. Another good one is "Algorithms in a Nutshell", for more language agnostic algorithms.
O'Reilly - C# Cookbook
Algorithms in a Nutshell
As someone that interviews potential developer for my team, I really would rather you didn't try and "game" the interview. If you study for interview type questions you might get really good at it, but then would you be a good developer?
Other than for graduates, who I expect to be learning on the job, any other level of developer will get task to perform in Visual Studio. The candidate will be asked to write a small program in the space of about 4 hours. It will contain all the elements necessary to determine if they are any good or not and we can see examples of their real programming style, thought processes and abilities.
The worst person I ever interviewed was someone who had learned the "standard set" of questions by rote. When we asked a question he knew we got a beautifully crafted answer back. But, when he was asked something he didn't know we got back an instant "I don't know". Some of the questions were logical questions, we didn't expect anyone to know the answer off the top of their head, they were expected to work it out.
So, just learn how to write software. Learn how to communicate that to other people and you'll do just fine in the interview.
"Programming Pearls" by Jon Bentley, nothing to do with C# per se, (it was first published 14 years ago), but is great book on programming problem solving in general
I like Algorithms in a Nutshell.
Edit: and The Algorithm Design Manual is fun, but don't start there.
I highly recommend "C# in Depth" by our fellow Jon Skeet. :)
You asked about books, but I will advise trying one of the following:
Project Euler
Top Coder (they support C# solutions)
UVA Online Judge
SPOJ
The more You solve, the better You will be at algorithms.
PS: Don't get addicted:)
This might be what you're looking for.
It's what I used in my algorithm class.
I would decide first if you need work on C#, or on algorithms, or on both. It sounds like you're worried about "algorithms in C#", which you shouldn't be. Algorithms are essentially the same across all the common imperative programming languages. If you're really worried about algorithms, you can pick up pretty much any algorithms book and work through it. Same thing with C#.
A lot of "programming type questions" on interviews, unfortunately, tend to be either "do you know this minor tidbit of this language?" Sadly, there's not much you can to do study for those types of questions, other than use the language a lot and become increasingly familiar with its details.
Data structures and the framework they're within, however, are a bit different. In a (relatively) short time you can become familiar with some aspects of the .NET framework that can help considerably. Learning things like how to use generics and how to get a hashtable or a list is good to know. Of course, then you should also know the more general answer of when you should use a hashtable vs. a list.
For general programming questions related to .NET technologies, I wrote an eBook called "Shove It, FizzBuzz: How to Find and Land a .NET Development Job."
http://shoveitfizzbuzz.com
It's more than just interview questions, but it's still chock full of them, and comes with a .NET Interview Simulator.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
as the question says, i wish to learn OOP in c#. I am aware of the basics of OOP such as what does class means, what is object, and all 6-7 features of OOP. What i dont understand that how to make use this in real application? I get stuck when it comes to using all these features during development (coding).
I have code in VB.NET and now would be doing in C#. I have use VS 2005 and now using VS 2008.
Please suggest me some very good resource to learn (& especially i could implement it also) OOP in C#
thanks
Although not the book's only focus, I found Agile Principles, Patterns, and Practices in C# really useful for OOD/OOP. It covers SOLID design principles in an accessible and very readable way. Similar content is also available at the author's (Robert C. Martin) web site, Object Mentor.
Agile Principles, Patterns, and Practices in C# cover http://www.objectmentor.com/Images/book_agileprinciplesandpractices.jpg
Applying Domain-Driven Design and Patterns: With Examples in C# and .NET
Applying Domain-Driven Design and Patterns is the first complete, practical guide to leveraging patterns, domain-driven design, and test-driven development in .NET environments. Drawing on seminal work by Martin Fowler and Eric Evans, Jimmy Nilsson shows how to customize real-world architectures for any .NET application. You'll learn how to prepare domain models for application infrastructure; support business rules; provide persistence support; plan for the presentation layer and UI testing; and design for service orientation or aspect orientation.
(source: amazon.com)
Maybe design patterns are the second thing to learn in OO, after you sort of master the basic principles. But in each case you should know them to recognize them and to avoid inventing them again.
And this one is especially nice, be it in Java. Even though, there exists many C# variants now, I still think it's important to know the classics, and these are in this book, sort of a popular translation of the GoF-pattern book.
alt text http://ecx.images-amazon.com/images/I/51LSqrgoT1L._BO2,204,203,200_PIsitb-sticker-arrow-click,TopRight,35,-76_AA240_SH20_OU01_.jpg
If you are an e-book fan then I would definitely read S.O.L.I.D principles from Pablo of Los Techies.
Personally, I found the classic Design Patterns book quite an eye-opener when it comes to object-oriented design. From that, all else follows :)
It predates C# with about 5 years, so you will have to look at C++ and SmallTalk code instead, but learning OO is really not about the language, but rather the mindset.
Many people find that Head First Design Patterns is a more digestible alternative, but I have only flipped through it myself (it looks pretty good, though).
Do you want to learn the core concepts of OOP or get your hands dirty and write an application? The principles of OOP are fairly well covered on the Wikipedia article and concepts like inheritence, encapsulation, polymorphism, composition will be the same as those in VB.NET as the two languages have to adhere to the CLS.
Name a feature in VB.NET that you already know and in C# the difference will be a keyword or three, curlies instead of begin/end.
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.
Closed 10 years ago.
Recently I came about this concept of Design Patterns, and felt really enthusiastic about it. Can you guys suggest some resources that help me dive into Design Patterns?
You know, for me, one of the best books out there is Head First Design Patterns. I personally like the style that they use to communicate the material.
Wikipedia, the Gang of Four book, and if you're specifically interested in C# implementations there's a decent site here.
One of the best books is (as mentioned above) the Head First series because it gives great analogies and real-world examples.
There are also other decent Java Design Pattern books available. Also, web sites that are specialized on the subject (see posts above for some)
Although the Gang of Four book was my first read on this subject, it is my opinion that you should avoid it especially if your starting out. At the time this was the reference, but today many books exist giving you many to choose from.
BUT, and I clearly emphasize this point... practice is the ultimate learning tool. After having read several books on the subject, I was 100% certain of knowing and understanding these patterns. When I attempted to actually implement some of them I soon realized that my knowledge was mostly 'theory' and my comprehension wasn't even close. A huge blow to my ego!
I set out to test and challenge my peers and quickly learned that they were in the same boat as I was. I find that 99% of programmers proclaim to know patterns but when really put to the test, only about 1/3 actual know the subject well.
I set out to implement as many patterns as I could in one or more complex systems. I put theory to practiced and what I learned was a gold mine.
One of the most challenging aspects of my experience was that each pattern alone look simple. But sometimes linking a bunch of patterns together can be even more challenging.
I encourage you to put theory to practice!
Jeach!
Here is a very nice screencast series on Design Patterns on DnrTV
Part 1
Part 2
Part 3
Part 4
Part 5
Hope this is more inviting ;)
The gang of four design patterns book is the standard. I recommend it if you're comfortable with C++.
Head first design patterns is good too, especially if you like visual aids and want to feel like you're learning design patterns in a '50s diner. Examples are in Java.
There are sometimes multiple ways to implement patterns in a given programming language (for example see this discussion of options for implementing the Singleton pattern in C#), so it might be worth getting one book to succinctly describe the common patterns, and another to suggest the best way to implement them in your favorite language.
I frequently reference this site: Design Patterns . It has a nice write up including examples for all the popular design patterns for free.
Here're the two I found a while back
http://www.dofactory.com/Patterns/Patterns.aspx
http://amazedsaint.blogspot.com/2008/01/design-patterns-part-i-and-ii.html
ASP.NET has good reference to DPs.
http://wiki.asp.net/page.aspx/276/design-patterns
Head first design patterns book is a good read.
If you want to test your knowledge of design patterns , here is the design patterns quiz
Microsoft Pattern and Practices Developer Center
Really, I think the best way to learn them is to deeply understand your language (C# based on your tags), and then to really commit yourself to the goals of having good separation of concerns, low coupling and high cohesion. I'd read and study Robert Martin's writings about SOLID principles.
And then (and this is the most important part), try to follow those principles as you develop software. You'll find that you start to do certain things, and later it will hit you, "Oh! That was the strategy pattern." This is truly what the "pattern movement" demonstrates ... people working in a certain kind of language, trying to achieve good software design, will find themselves arriving at solutions that follow certain common patterns.
I like these 2...
http://www.amazon.com/Design-Patterns-Object-Oriented-Addison-Wesley-Professional/dp/0201633612
http://www.amazon.com/Refactoring-Patterns-Addison-Wesley-Signature-Kerievsky/dp/0321213351
this one really helps with taking existing code and implementing a design pattern.
I find Design Patterns Explained to be a good introductory text. The Gang of Four book is a reference for those who already understand patterns.
Martin Fowler's website has plenty of information: http://martinfowler.com/articles.html.
Much of this is covered also in his book, Patterns of Enterprise Application Architecture.
For those using C#, I found Design Patterns in C# a bit easier read than GoF's book. The examples of course are in C# and the connection is made to the Microsoft naming of the patterns.
Last year I bought and read C# 3.0 Design Patterns, by Judith Bishop and I've been very pleased with it, having previously tried to get through Go4 and Design Patterns in C#.
This covers the standard set of patterns, grouped by similarity, in order of increasing complexity, but also ties them in to the language features of C# 3.0, so you start with simple cases with interfaces and abstract classes, and move up through extension methods, generics, anonymous types, functions, etc - a very good way to learn both.
All presented in an easy to read format, with quite a few real world examples and handy source code.