Board index » delphi » Re: Noun Oriented Thinking Considered Harmful
I.P. Nichols
Delphi Developer |
I.P. Nichols
Delphi Developer |
Re: Noun Oriented Thinking Considered Harmful2006-08-09 07:06:17 PM delphi136 "Jim Cooper" writes: Quote
|
Oliver Townshend
Delphi Developer |
2006-08-09 07:15:35 PM
Re: Noun Oriented Thinking Considered HarmfulQuote>It is true that many programmers are not good at design. They write poor |
Jim Cooper
Delphi Developer |
2006-08-10 07:07:15 PM
Re: Noun Oriented Thinking Considered Harmful
I.P. Nichols writes:
Quote"Jim Cooper" writes: If you are interviewing someone for a job (like I have had to do in my current position), judging how they good they are at their job is what you are doing by interviewing them. Your quote is not a useful piece of advice Cheers, Jim Cooper _____________________________________________ Jim Cooper XXXX@XXXXX.COM Skype : jim.cooper Tabdee Ltd www.tabdee.ltd.uk TurboSync - Connecting Delphi to your Palm _____________________________________________ |
Jon Robertson
Delphi Developer |
2006-08-10 09:55:41 PM
Re: Noun Oriented Thinking Considered Harmful
Jim Cooper writes:
QuoteYour quote is not a useful piece of advice |
I.P. Nichols
Delphi Developer |
2006-08-10 10:58:21 PM
Re: Noun Oriented Thinking Considered Harmful
"Jim Cooper"
Quote> |
Brad White
Delphi Developer |
2006-08-10 11:16:24 PM
Re: Noun Oriented Thinking Considered Harmful
"I.P. Nichols" <XXXX@XXXXX.COM>writes
Quote"Jim Cooper" writes: I do it all the time. Let's get it on. -- Thanks, Brad. |
Jim Cooper
Delphi Developer |
2006-08-10 11:46:43 PM
Re: Noun Oriented Thinking Considered HarmfulQuoteIn taking it literally one can miss the point Jim Cooper _____________________________________________ Jim Cooper XXXX@XXXXX.COM Skype : jim.cooper Tabdee Ltd www.tabdee.ltd.uk TurboSync - Connecting Delphi to your Palm _____________________________________________ |
Michael C.
Delphi Developer |
2006-08-11 10:45:05 PM
Re: Noun Oriented Thinking Considered Harmful
Barry Kelly writes:
Quote"Michael C." <XXXX@XXXXX.COM>writes: <snip> Quoteuse a QuoteIn languages like C and it's not a good tool for that person. I think you're are smarter if you try to stay away from tools that make you unproductive. |
Michael C.
Delphi Developer |
2006-08-11 10:59:46 PM
Re: Noun Oriented Thinking Considered Harmful
Jim Cooper writes:
<snip> Quote>There are plenty of people out there who can write maintainable code QuoteIt is QuoteYour quote in reply Honestly, I find testing in procedural or OO can be easy depending on how you've set it up. Quote>Moreover, one can write unmaintainable code in OO too. I think you believe that anything non-OO is unmaintainable based on your comments so far. <snip> QuoteThey may indeed lack the skills to do OO, but that means they are not Believe it or not, there are great programs out there that weren't written using OO. |
Barry Kelly
Delphi Developer |
2006-08-12 12:11:38 AM
Re: Noun Oriented Thinking Considered Harmful
"Michael C." <XXXX@XXXXX.COM>writes:
Quote<snip> 'object' in the name :) With just a record with function pointers, one can construct polymorphism, dynamic dispatch and encapsulation. With careful overlaying of records or the use of a union, inheritance and abstraction aren't far away. A record with function pointers is the skeleton around which most object oriented implementations (at the binary level) are built. They're the same shape, basically. The essence of object orientation is a set of accepted patterns for fleshing out the skeleton. The two things are not unrelated; one was created as a formalism and widespread acceptance of the other. The Delphi language provides native support for object orientation, a formalism for supporting these records of function pointers (+ extras). The compiler builds these records automatically at compile time so you don't have to do it at runtime, it typechecks pointers to them taking into account polymorphism, it provides a uniform syntax for invoking statically and dynamically bound member functions, and it provides support for automatically chained inheritance. So, if you're writing code for which (in a procedural language) records with function pointers are a good tool for solving the problem, I would strongly suggest that classes in a language which provides them are an even better tool - if only for the benefits described above. Can we agree on this much? And if so, can we then look at what kinds of problems are suited to the 'record of function pointers' approach? Quote>In languages like C and some: imagine the concept of a Control (or Window if you prefer), which needs to be drawn, and needs to support nested Controls. In other words, a Control is a node in a visual tree (or render tree if you prefer), a well-known structure in computer graphics, where each node is recursively drawn with a context (i.e. location, rotation, clipping etc.) inherited from its parent. One control won't do: we need an extensible solution that allows arbitrary controls (for 3rd party market reasons). Keeping it all extra simple, we just need to Draw different kinds of Controls, and perhaps accepts Clicks from the user. Within those constraints, what kind of approach would you take to implementing the Control concept, so that it is flexible enough to meet the open-ended constraints (i.e. arbitrary kinds of controls, with arbitrary Drawing and arbitrary responses to Clicks)? I would suggest that, in order to achieve the desired flexibility, the functionality of both Draw and Click must be indirected - which implies a function pointer of some form. To encapsulate the two operations into one 'thing', it would seem reasonable to stick a couple of function pointers into a record. Do you agree? Disagree? If you agree, would a procedural approach be simpler than: ---8<--- public abstract class Control { public Collection<Control>Children = new Collection<Control>(); public abstract void Draw(Surface surface); public abstract void Click(); } --->8--- ... or the slightly more verbose Delphi, where the tree structure follows the Lisp style for brevity: ---8<--- type TControl = class public procedure Draw(Surface: TSurface); virtual; abstract; procedure Click; virtual; abstract; NextSibling: TControl; FirstChild: TControl; end; --->8--- ... bearing in mind the tools provided by Delphi: type checking, version-safe extensibility via new virtual but not abstract methods, compact implementation syntax, low memory usage (function pointers only stored once, in the TClass metaclass instance), etc. Or would you use a different tool to solve the problem? -- Barry -- barrkel.blogspot.com/ |
Jim Cooper
Delphi Developer |
2006-08-12 11:54:30 PM
Re: Noun Oriented Thinking Considered HarmfulQuoteI think that depends on your point of view. QuoteI think in this case "done it wrong" means not doing it your way. QuotePersonally, I find procedural code easier for me to read especially if I write good QuoteHonestly, I find testing in procedural or OO can be easy depending on QuoteThat's pretty much a blanket statement that is totally incorrect. say again, that in my experience it *is* true. As I said in an earlier post, comments like that trigger alarm bells, and the reason for that is because of the experience I have had with those sorts of developers. QuoteAgain, I think you are talking from your point of view. QuoteI think you believe that anything non-OO is unmaintainable based on your QuoteI disagree. spends 90% of its lifetime in maintenance. Too many developers forget that. You may well bring out v1 that your customer is happy with, but that is them happy for only 10% of the product lifetime. You now have to keep them happy the other 90% of the time. You have too narrow an idea of the job, I think. QuoteBelieve it or not, there are great programs out there that weren't the job done" brigade. There is more to your job than writing code that works right now. Failure to comprehend that leads to tears later (and more work for people like me). Cheers, Jim Cooper _____________________________________________ Jim Cooper XXXX@XXXXX.COM Skype : jim.cooper Tabdee Ltd www.tabdee.ltd.uk TurboSync - Connecting Delphi to your Palm _____________________________________________ |
Michael C.
Delphi Developer |
2006-08-15 03:28:11 AM
Re: Noun Oriented Thinking Considered Harmful
Barry Kelly writes:
Quote>Actually using a record with function pointers is a valid procedural programming technique. Quote
First of all, the concept of using records with functions is more flexible to me. The purpose of writing a function is to preform a singular specific task. The purpose of writing a class is to group data with functions for common task. Writing a function is easier for me to do than writing a class. QuoteWhat procedural QuoteLet's cut it down - so I think you are setting up a straw man argument here. But if you are really interested in how you would do it without using OOP. One would probably using a similar data structure for all common controls that would probably contain function pointers. QuoteOne control won't do: we need an extensible solution that allows Or you could have a "draw" table so that call the parents draw style before other drawing operations. Quote
QuoteIf you agree, would a procedural approach be simpler than: I find that using a library of classes aren't as flexible as functions because they REQUIRE you to create a class to extend an objects functionality. I actually find that extending classes difficult and time consuming. |
Michael C.
Delphi Developer |
2006-08-15 03:56:40 AM
Re: Noun Oriented Thinking Considered Harmful
Jim Cooper writes:
Quote
Quote
I think your point of view is very wrong. QuoteWhile you can do unit testing with non-OO code, it is easier and a more <snip> QuoteWhat I have said is that good OO code Moreover, I believe OOP can be less productive for some people. <snip> QuoteMost QuoteThere is more to your job than writing code that works right now. |
Barry Kelly
Delphi Developer |
2006-08-15 04:49:09 AM
Re: Noun Oriented Thinking Considered Harmful
"Michael C." <XXXX@XXXXX.COM>writes:
QuoteBarry Kelly writes: were used before OOP became popular - as you say. In fact, OO is a proper subset of the record of function pointers approach, one that limits the operations available to those known to be safe, where "known to be safe" is interpreted with varying degrees of rigour in languages like C++, Delphi, Java, etc. (in ascending order there). Quote>So, if you're writing code for which (in a procedural language) records Quote>What procedural developer.gnome.org/arch/gtk/object.html G>Although GTK+ is written in C, a language without explicit support G>for object-oriented program, the design of GTK+ is heavily object G>oriented. The basis of this is a layer known as the GTK+ Object G>System. In addition to such traditional features as inheritance, G>polymorphism and reference counting, the GTK+ Object System also adds G>a number of features particularly adapted for a widget toolkit, G>including a signal system for notification and an object attribute G>system. Look at that - inheritance, polymorphism, signal system (basically events)! Quote>Let's cut it down or subtyping, only parent and child relationships. What are the coordinates for a button inside a dialog box? Where is 0,0 inside the dialog box? it is not screen top-left (Windows) or screen bottom-left (DOS). I can tell you that people don't design dialog boxes using the screen coordinate system! If they did that, when you moved the dialog, all the controls inside it would stay put! Clearly something (i.e. the offset of the origin) is *literally* inherited (i.e. passed down) from the parent. QuoteBut if you are really interested in how you would do it without using OOP. QuoteYes, you would probably put function pointers in a record - just like QuoteI actually find that extending classes difficult and time consuming. pointers in a record, wouldn't you have to do the same kind of thinking in order to extend it? For example, when people want to add a size grip control to their forms in Win32 API (which is a C API, as you know), they write a message loop that intercepts the WM_NCHITTEST, checks the location, and conditionally returns HTBOTTOMRIGHT (or whatever). How is that thinking different from overriding some "WMNCHitTest" method which is taking in two arguments (i.e. x and y mouse position), and returning the hit-test value? (Apart from the fact that the compiler gets to check it for you - even better!) -- Barry -- barrkel.blogspot.com/ |
Jon Robertson
Delphi Developer |
2006-08-15 06:11:32 AM
Re: Noun Oriented Thinking Considered Harmful
FWIW, you don't have to use a OOP language or create classes to use OOP
methodology. On of my favorite GUI frameworks, C-Scape, was written in pure C /years/ before C++ became available. But it is /very/ OOP. You have base types and other types that extend on the base types and have all the functionality of the base types and can be passed as parameters to functions expecting a "ancestor" type, etc. All using pointers to structures and type-casting. In fact, VCL's design looks so much like C-Scape's design that I wondered if someone on the VCL team hadn't used C-Scape. Then I realized that most well-designed frameworks should look very similar to each other. The more I read posts from Michael C, the more I think he's using OOP, whether he likes it or not. ;) |