Skip to main content
added 1 character in body
Source Link
Robert Bräutigam
  • 12.4k
  • 1
  • 20
  • 39

Using "properties" in an "object" goes fundamentally against object-oriented practicesprinciples. It makes the object a data structure, which is something that doesn't (shouldn't) exist in an object-oriented design.

So in short, none of those options is object-oriented, nor a good practice to do. Separating the data from its behavior just results in less maintainability, since stuff that often changes together is separated.

To be object-oriented you have to hide the data and offer behavior. Behavior that is specific to your application and your domain. Be it something that changes it (promoting an employee, canceling a credit card), or just presenting on a UI.

Loading data without knowing what the use-case is will only introduce problems like under-, or over-fetching, unoptimized queries etc. All that is unnecessary, just offer behavior, and have the behavior do database queries/update/etc as needed.

Using "properties" in an "object" goes fundamentally against object-oriented practices. It makes the object a data structure, which is something that doesn't (shouldn't) exist in an object-oriented design.

So in short, none of those options is object-oriented, nor a good practice to do. Separating the data from its behavior just results in less maintainability, since stuff that often changes together is separated.

To be object-oriented you have to hide the data and offer behavior. Behavior that is specific to your application and your domain. Be it something that changes it (promoting an employee, canceling a credit card), or just presenting on a UI.

Loading data without knowing what the use-case is will only introduce problems like under-, or over-fetching, unoptimized queries etc. All that is unnecessary, just offer behavior, and have the behavior do database queries/update/etc as needed.

Using "properties" in an "object" goes fundamentally against object-oriented principles. It makes the object a data structure, which is something that doesn't (shouldn't) exist in an object-oriented design.

So in short, none of those options is object-oriented, nor a good practice to do. Separating the data from its behavior just results in less maintainability, since stuff that often changes together is separated.

To be object-oriented you have to hide the data and offer behavior. Behavior that is specific to your application and your domain. Be it something that changes it (promoting an employee, canceling a credit card), or just presenting on a UI.

Loading data without knowing what the use-case is will only introduce problems like under-, or over-fetching, unoptimized queries etc. All that is unnecessary, just offer behavior, and have the behavior do database queries/update/etc as needed.

Source Link
Robert Bräutigam
  • 12.4k
  • 1
  • 20
  • 39

Using "properties" in an "object" goes fundamentally against object-oriented practices. It makes the object a data structure, which is something that doesn't (shouldn't) exist in an object-oriented design.

So in short, none of those options is object-oriented, nor a good practice to do. Separating the data from its behavior just results in less maintainability, since stuff that often changes together is separated.

To be object-oriented you have to hide the data and offer behavior. Behavior that is specific to your application and your domain. Be it something that changes it (promoting an employee, canceling a credit card), or just presenting on a UI.

Loading data without knowing what the use-case is will only introduce problems like under-, or over-fetching, unoptimized queries etc. All that is unnecessary, just offer behavior, and have the behavior do database queries/update/etc as needed.