tags:

views:

249

answers:

10

I am looking for a book which explains how to program object-oriented.

I am not looking for a book which explains OO concepts: what classes and objects are, what private, protected and public do, what static and final means. I already know this.

I would like for the book to explain how to program OO in practice, answering questions like:

  • Should I make all methods protected, so that they can always be overloaded?
  • Should I have utility classes, with only static methods?
  • Should I extend or decorate a certain class to add functionality?
  • Should I use singletons for things like database objects?
  • When should I make a class final?
  • When do I use a static factory method instead of a constructor?
+7  A: 

it seems you are looking for a book about software development best practices
have a look at code complete

Alon
+4  A: 

Effective Java

It's pretty much leaning to Java programming but most of good OO practice can be learn language agnostically.

nanda
+5  A: 

I'd go for Martin Fowler's books, and more specifically:

Bozho
@downvoter - if you don't like Fowler's ideas and practices, explain why
Bozho
+1, Fowler is excellent in explaining complex things in simple and easy to follow language. The first book takes you step by step through your wrong decisions and shows how and why to improve them. Your second book is not for the faint of heart and should only be read by people that already have some years experience in the field.
Abel
+3  A: 

I found Clean Code by Robert C Martin to be a very interesting read.

Brian Rasmussen
A: 

Hi...

these are the book list from a course in my university about OOP

[1] Bertrand Meyer. Object Oriented Software Construction. Prentice Hall. 1997. Second Edition.

[2] Ivar Jacobson, Grady Booch, James Rumbaugh. The unified software development process. Addison Wesley, 2000.

[3] A Eliëns. Principles of object oriented software development. Addison Wesley, 1995.

[4] Setrag Khoshafian, RazmikAbnous. Object orientation: concepts, languages, databases and user interfaces. John Wiley&Sons Inc. 1990.

[5] Erich Gamma, Richard Helm, Ralph Johnson, John vlissides. Design Patterns: Elements of reusable object oriented software. Addison Wesley. 1995.

[6] Cay Horstmann.Object-Oriented Design & Patterns John Wiley & Sons, Inc., 2004.

[7] Timothy C. Lethbridge, Robert Laganiere. Object oriented software engineering. McGraw-hill Education. 2001 [8] Bjarne Stroustrup. What is object oriented programming?

IEEE Software. 1988. [9] Bertrand Meyer. Applying design by contract. Computer. 1990

[10] Daniel Halbert y Patrick O'Brien. Using types and inheritance
in object oriented languages. European conference on object-oriented programming on ECOOP '87. 1987.

[11] Developing software for the user interface. The SEI series in software Engineering. Adisson Wesley. 1991.

[12] Bjarne Stroustrup. The {C}++ Programming Language}. Addison-Wesley, 2002. Edicion especial.

[13] Java http://sunsite.dcc.uchile.cl/SunSITE/java/docs/tut-java122-sun/index.html

forellana
+2  A: 

Fowler's

Patterns of Enterprise Application Architecture

is pretty good.

Jride
A: 

Robert Martin's Agile Software Development, Principles, Patterns, and Practices, mainly the first 5 chapters, most of which are also online, known as the SOLID principles.

This is high-level strategic advice on class design. For more tactical applications of those principles see the two books mentioned earlier, Josh Bloch's Effective Java and Martin's Clean Code.

Dave Sims
+3  A: 

Thank you for your answers. I had a look at most of the suggested books.

Effective Java, by Joshua Bloch

This book consists of 78 guidelines, which explain how you should use OO concepts and what the advantages are for doing so. It is a useful book with a lot of practical advice. It answers my questions with the following chapters:

  • Item 13: Minimize the accessibility of classes and members
  • Item 4: Enforce noninstantiability with a private constructor
  • Item 16: Favor composition over inheritance
  • Item 3: Enforce the singleton property with a private constructor or an enum type
  • Item 15: Minimize mutability
  • Item 1: Consider static factory methods instead of constructors

Patterns of Enterprise Application Architecture, by Martin Fowler

This book covers various separate topics about the structure and architecture of programs. It is in interesting read for anybody who is working on a "Enterprise Application", a program specific to a certain domain. As it covers the architectural part of certain topics, it gives a broad insight to architecture. Interesting book, but it answers only a part of my questions.

  • Mapping to relational databases
  • Web presentation
  • Concurrency
  • Session state

Clean Code, by Robert C. Martin

This book is about keeping code clean and maintainable. It explains how to structure the code and gives guidelines how to keep your code clean. I dislike the writing style and many things covered in this book are already clear to me. It does cover OO somewhat and explains some programming principles, such as:

  • The law of Demeter
  • The single-responsibility principle
  • Class cohesion
  • Encapsulation
  • Dependency injection

Code Complete, by Steve McConnell

A useful, thick book with a lot of concrete tips and guidelines for programmers. Assumes that the reader knows how to program and wants to get good at it. Covers writing code, working in a team and the software process. It misses specific information on how to use OO concepts. This book, although very practical and useful, is not what I was looking for.

Refactoring, by Martin Fowler

This book describes some very practical ways to refactor something in code. It offers an example, a motivation and step-by-step plan to do the refactoring. It explains how to move between various OO structures, but it omits information on what the best OO structure is and why. Some section names:

  • Replace Parameter with Method
  • Encapsulate Field
  • Extract Superclass
  • Replace Method with Method Object

Agile Software Development, Principles, Patterns, and Practices, by Robert C. Martin

I had not the chance to look at this book. The SOLID principles, although very true, are quite abstract and do not answer many of my questions.

Sjoerd
+1  A: 

I really don't think that any book can answer for all of your questions. All of this depends on your own experience, knowledge, and even taste.

I think, that first must-have book for every object-oriented developer is "Object-Oriented Software Construction" by Bertran Meyer. It is most fundamental book about object-oriented world ever published.

Second importand thing (if you want to become a great architect or designer) - is challenging project.

Sergey Teplyakov
+1  A: 

I suggest the Head First Object oriented analysis and design (http://www.amazon.com/Head-First-Object-Oriented-Analysis-Design/dp/0596008678 ) Book

It walks you through the process of analyzing the requirements in OO way and then design the object and during the process handles the questions you are asking.

Emad