Forum > Beginners

which to use "object vs class"? [SOLVED]

<< < (3/4) > >>

pascal111:

--- Quote from: Zoran on May 08, 2021, 02:35:54 pm ---If I'm not mistaken, you are a beginner in oop concept.

Just take the classes approach and forget about old style objects. You don't need this confusion.

--- End quote ---


لست مُخطأً في كوني مُبتدأً في البرمجة غرضيّة التوجّه وسأعمل بنصيحتكـ بتعلّم إصدارة الـ class بدلاً من إصدارة الـ object.


google translate:

"I am "You are" not at fault for "I'm" being a beginner in object-oriented programming, and I will follow your advice on learning the class version instead of the object version."

pascal111:

--- Quote from: PascalDragon on May 08, 2021, 03:10:50 pm ---
--- Quote from: pascal111 on May 08, 2021, 01:25:39 am ---"I have read that in order to implement the programming for the purpose of orientation (OOP) in Lazarus that I can announce "declare" the classes by one of two registered words, object and class, but I also learned that there are differences between them, and it seemed to me that the official version of the classes applied in the Lazarus structure in which the components were built and organized is the version of the class. Am I obligated, when I apply for purpose-oriented programming (OOP), to use the class version instead of the object, or does each version have its use cases or are almost equivalent, and they are according to the choice and preference of the programmer?"

--- End quote ---

While we don't declare TP-style objects as deprecated like Delphi did, they are essentially in "maintenance mode". So if you want to take advantage of newer language features, it's more likely that the Delphi-style classses will get them than TP-style objects.

Also if you want to interact with Lazarus' LCL you pretty much must use Delphi-style classes.

--- End quote ---

يبدو كما قلت أنّهُ للإستفادة من الجوانب الإضافيّة والمميزات الجديدة المزيدة في اللغة مثل مكتبة LCL فيلزم التعامل مع نسخة الـ class لا نسخة الـ object التقليديّة.

google translate:

"It seems, as I "you" said, that in order to take advantage of the additional aspects and new and more features in the language such as the LCL library, it is necessary to deal with the class version and not the traditional object version."

jamie:
I use a mix of things, Classes, Objects, Records etc..

The reason is that at times I like heap objects, those that do not need to be created at time of need.

Now you can do this with the use of RECORDS however, Records do not inherit unless you are doing helpers which at this time I believe works only in Fpc and not Delphi.

 Also, the Methods of a class are of type OBJECT The difference is the CLASSes are purly dynamic and need to be created always.

 

pascal111:

--- Quote from: jamie on May 08, 2021, 07:48:00 pm ---I use a mix of things, Classes, Objects, Records etc..

The reason is that at times I like heap objects, those that do not need to be created at time of need.


--- End quote ---

من الجيّد أنّكـ وجدت توظيفاً لكل نوع سواءاً كان سجلات أم الأصناف بنسختيها الـ calss والـ object.

google translate:

"It is good that you found a job for each type, whether it is records or classes, in its calss and object versions."


--- Quote from: jamie on May 08, 2021, 07:48:00 pm ---Now you can do this with the use of RECORDS however, Records do not inherit unless you are doing helpers which at this time I believe works only in Fpc and not Delphi.

--- End quote ---

لقد استخدمت السجلات من قبل والسجلات المتقدمة كذلكـ وأظنّ أنّ السجلات مناسبة جدّاً للمبتدئين وحتّى لكي يفهموا الفكرة العامة للأصناف ،ولكنّني لم أستخدم ميزة الـ helpers بعد ولكن سمعت عنها منكـ ومن خلال ذكرها في صفحات ويب أخرى ويبدو أنّي سأقرأ عنها بالتفصيل من خلال بحثي في google إن عثرت على بعض الشروح لهذه الميزة في السجلات.

google translate:

"I have used the records before and the advanced records as well - and I think that the records are very suitable for beginners and even for them to understand the general idea of ​​the classes, but I have not used the helpers feature yet but I heard about it from you and through mentioning it in other web pages and it seems that I will read about it in detail through my search on google if I found some explanations for this feature in the logs"of the records"."


--- Quote from: jamie on May 08, 2021, 07:48:00 pm --- Also, the Methods of a class are of type OBJECT The difference is the CLASSes are purly dynamic and need to be created always.

--- End quote ---

ماذا تعني بكون الـ  methods من نوع الـ object؟ هل تعني الـ methods خاصّة نسخة الـ  object وليس نسخة الـ class؟ عموماً كما أشرتَ أنّ نسخة الـ class تبدو حقّاً ديناميكيّة أكثر من نسخة الـ object.


google translate:

"What do you mean that methods are of type an object? Does "Do you mean" the methods specifically mean the object version and not the class instance "version"? In general, as you indicated, the class version really appears to be more dynamic than the object version."

lucamar:

--- Quote from: pascal111 on May 08, 2021, 08:09:23 pm ---"What do you mean that methods are of type an object? "Do you mean" the methods specifically mean the object version and not the class instance "version"? In general, as you indicated, the class version really appears to be more dynamic than the object version."
--- End quote ---

Jamies's English is sometimes a little obscure :-X. My guess is that he's referring to event types which are usually declared as "of object", as in:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---type  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".

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version