|
Prev: How does one model behavior?
Next: Toy or tool
From: alexcpn on 11 Apr 2008 01:19 On Feb 28, 9:23 pm, topmind <topm...(a)technologist.com> wrote: > Robert Martin wrote: > > On 2008-02-25 23:38:19 -0600, topmind <topm...(a)technologist.com> said: > > > >> Classes operate best at the task level. > > > > But one does not need OO at the task level. > > > That's silly. Tasks are written in source code. Source code > > dependencies need to be managed. OO helps you manage those > > dependencies. It's really as simple as that. > > > Given two modules [A] and [B] such that the source code of A depends on > > the source code of B, so that A can call B. > > > [A]----->[B] > > > I can use OO to invert the direction of the dependency by inserting a > > polymorphic interface. So that the source code of A does not depend on > > the source code of B, either directly or transitively. > > > [A]----->[I]<-----[B] > > > Note that the flow of control has not changed. A still calls B. > > > This is the kind of dependency management that OO gives you. We apply > > this kind of management at the level of small modules. 500 lines of > > code or less. > > How about some task-oriented examples? The devil's in the details. > > > > > -- > > Robert C. Martin (Uncle Bob)��| email: uncle...(a)objectmentor.com > > Object Mentor Inc.� � � � � ��| blog:��www.butunclebob.com > > -T- Well so many views are here regarding the subject; and I have been thinking - distancing myself from the keywords and paradigms that I have embraced knowingly or unknowingly. I feel like I have fallen into the trap an average mind falls when he knows a little.He will try to relate his experience with what he knows. Open Closed Principle is a beautiful ideal , ideals seem like the truth,anyway it is as worthy as the truth. This is what I would have embraced and preached about a year ago, I would also have embraced and raged about dynamic dispatch at that time. I read about Rober Martin's example of changing a mess of pointers by the String abstraction and it strikes a chord; most of the work that I have done is redesign or design, and in this process most of the source is also modified as well as extended. This could have been because it was not designed in the ideal object oriented way so that it could have been easily extended by me without modification.And tomorrow there might arise another use case whereby my beautifully designed code needs again to be modified to be extended. As long as complex design patterns are not built into the programming language this cycle will continue, by at least 99% of the average programmers. Taking myself as an average programmer let me try to answer a part of the question which I have asked- why is object oriented looking so good to me . For me now the answer seems too simple to be relevant - I like it because it is fun, powerful - It has given concept tools like inheritance and polymorphism which aids the programmer to create more and more complex and elegant designs. Ultimately I believe it will be these tools that will help us to go to the next level in programming.For instance pointers give more flexibility, templates more versatility.These are all tools,and the expert who wields it creates a masterpiece while a novice will make mistakes and learn. When new languages evolve they try to reduce the complexity while trying to give the same productivity, java , ruby.. so that the novice will make fewer mistakes. I am no expert in languages or compliers but I felt like expressing my views based on the knowledge that I have now and I have done it for what it is worth.
|
Pages: 1 Prev: How does one model behavior? Next: Toy or tool |