Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 151057
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T09:23:21+00:00 2026-05-11T09:23:21+00:00

I use Delphi, but this is a question that I think is valid for

  • 0

I use Delphi, but this is a question that I think is valid for any object-oriented programming language.

When should I use records over objects. I used to think that you used records when you had some simple definition of a set of related data that you wanted to store together that didn’t need to be able to manipulate itself. However every time I decided that a piece of data should be placed along with other data into a record, I came up with reasons for why it should be a fully blown object.

  1. There is almost always a reason that a piece of data needs some properties or methods.
  2. Memory management (creation and destruction) is much, much simpler with Objects (at least in Delphi).
  3. Using objects is probably no more expensive in terms of speed and memory but much much more flexible.

In fact I have recently come to the conclusion that possibly the only time you should use records over objects in modern applications is if you are reading a binary file from disk that can be read directly into an array of records.

I inherited a 10 year old project that uses records extensively over objects for small pieces of data, and I wonder is it just me or should these concepts be consigned to the recycle bin of experience.

Discuss.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T09:23:22+00:00Added an answer on May 11, 2026 at 9:23 am
    1. When there are no methods to act upon your data, it is useless most of the time. So you are right here.

    2. One of the biggest differences between objects and records is the fact that records are default on the stack and objects on the heap. To get a record on the heap, you get all the hassle you were referring to, but when you can leave them on the stack it’s a whole lot easier then managing objects lifetime. But lets face reality, there is little use for short lived records.

    3. When objects are instantiated, something more than merely reserving memory happens, there is a VMT to be managed, something a record hasn’t. So it a little more expensive to allocate objects than records, but I suppose it is neglectable when your not talking about thousends of items.

    To make your choice you need to consider how you will be using these objects or records. If you are going to read large binary files, records are the way to go (reading an entire buffer into an array of records maybe converting them to objects to work with). If you are handling structured data our runtime generated data objects seems to be a lot easier to work with.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use a routine that can start and stop services via Delphi but I
Is there any equivalent of DocTest for Delphi. I use DUnit but I like
Background This question relates to the new Cirrus infrastructure for Aspect Oriented Programming in
I am using the TADOConnection object in Delphi XE but this appears to be
Delphi strings use single quotes, for example ' a valid string '. How does
We want to use Unicode with Delphi 2009 and Interbase, and found that to
After this question , I need to know what principles should be followed in
This is a continuation of my last question . In that question I showed
This question is similar to this one , but not a duplicate because I'm
Background: This question relates to versions of Delphi below 2009 (ie without Unicode support

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.