Recent

Author Topic: which to use "object vs class"? [SOLVED]  (Read 3621 times)

pascal111

  • Sr. Member
  • ****
  • Posts: 285
  • Un trabajo en equipo para programas serias.
Re: which to use "object vs class"? [SOLVED]
« Reply #15 on: May 08, 2021, 09:32:04 pm »
Jamies's English is sometimes a little obscure :-X.

إن كان الغموض قادراً على أن يُصيب الإنجليزيّة فإنّهُ كان قراراً صائباً أن أكتب بالعربيّة حيث العبارات مُستقيمة المعنى لا عوج فيها قادرةٌ على التوجيه الصحيح للفكر وتضبط عمل العقل.

google translate:

"If the ambiguity was able to afflict the English, then it was a correct decision to write in Arabic, where the expressions are straight in meaning and not crooked, capable of directing the correct thought and controlling the work of the mind."


My guess is that he's referring to event types which are usually declared as "of object", as in:
Code: Pascal  [Select][+][-]
  1. type
  2.   TNotifyEvent = procedure(Sender: TObject) of object;
which basically means that the event handler has to be declared as a method of a class (that is, part of the "type" of methods is being "of object").

This in turn means that to use those "types" you have to use classes rather than "old-style" objects, despite the notation being "of object".

لقد سمعتُ عن الأحداث وهي ميزة حديثة وهذه الأيام يعتبرون من لا يعرف البرمجة غرضيّة التوجّه والبرمجة المسوقة بالأحداث ليس بمبرمج حقيقي ،عليّ أن أُلم بمثل هذه مواضيع.

google translate:

"I have heard about events, which is a recent feature, and these days they consider those who do not know programming for the purpose of orientation (OOP) and programming that are marketed by events (Event driven p.) are not a real programmer, I have to be familiar with such topics."

jamie

  • Hero Member
  • *****
  • Posts: 4749
Re: which to use "object vs class"? [SOLVED]
« Reply #16 on: May 08, 2021, 09:42:58 pm »
obscure ?

 I don't think so..

 Methods are of object type which have a background variable (self) that points to the instance of the body for any fields, etc.

 Using OBJECT or using Classes, they both work the same way. Difference is that Classes are dynamic only and must always be created to access any member fields excluding Class types. OBJECTS are not bound to this, they can live on the heap or stack and the instance body exist for them or they can be dynamically created, its your choice.

 AS for what you were referring to, that is a declared variable (TMethod) if memory serves, and its just a pointer to the a type METHOD. and that can be assigned for events or runtime variations functions to a single method pointer..

 I am sure a 100+ people will come here and twist everything I just said because they can.

That's fine. This is my final comment on this subject anyways..

have a good day and may the bugs be with you.

 
The only true wisdom is knowing you know nothing

pascal111

  • Sr. Member
  • ****
  • Posts: 285
  • Un trabajo en equipo para programas serias.
Re: which to use "object vs class"? [SOLVED]
« Reply #17 on: May 08, 2021, 11:36:43 pm »
obscure ?

 I don't think so..

 Methods are of object type which have a background variable (self) that points to the instance of the body for any fields, etc.

 Using OBJECT or using Classes, they both work the same way. Difference is that Classes are dynamic only and must always be created to access any member fields excluding Class types. OBJECTS are not bound to this, they can live on the heap or stack and the instance body exist for them or they can be dynamically created, its your choice.

 AS for what you were referring to, that is a declared variable (TMethod) if memory serves, and its just a pointer to the a type METHOD. and that can be assigned for events or runtime variations functions to a single method pointer..

 I am sure a 100+ people will come here and twist everything I just said because they can.

That's fine. This is my final comment on this subject anyways..

have a good day and may the bugs be with you.

 

ربّما كان نعت الكلام بالغموض مِزاحاً أو لتهوين الوقت والنقاشات الجادّة ولا أرى سوءاً فيما تفضّلت وقُلت.

التوضيح الذي قدمته الآن يحتوي على معلومات مُفيدة وأعتقد أنّ المقصود بالديناميكيّة في نسخة الـ object هو عن طريق إستخدام المؤشرات للإعلان عن عينات منها بدلاً من مُتغيرات مُعتادة ساكنة تظل تشغل الذاكرة طيلة الـ run-time.

google translate:

"Perhaps the word was called ambiguous as a joke or to belittle the time and serious discussions, and I do not see anything wrong with what I you said and preferred "exerted with".

The illustration I "you" presented now contains useful information and I think what is meant by dynamic in the object version is by using pointers to announce "declare" their samples "instances" instead of regular static variables that keep running the memory throughout the run-time."

dseligo

  • Sr. Member
  • ****
  • Posts: 316
Re: which to use "object vs class"?
« Reply #18 on: May 10, 2021, 04:36:56 pm »
As a beginner, if you are writing code for the Turbo/Free Vision framework, or work on other old TP codebases, use object.

Or if he works with AVR target (and possibly other embedded targets without OS to provide memory allocation) then he has to use (static) object.

Quote from: marcov
In all other cases use (delphi styled) classes.

I agree.

 

TinyPortal © 2005-2018