Giter Club home page Giter Club logo

Comments (4)

force-net avatar force-net commented on July 19, 2024 2

A first, library copies fields, not properties. It conception of library. E.g. we have such pseudo code

public int A 
{
 get 
 {
    return Database.Read("A");
 }
 set 
 {
    Database.Write("A", value);
 }

In this code we do not have real properties, but have complex logic which can cause strange behavior on copying.

Also, there are can be next situation with virtual methods which have different implementations in derived types.

pubic abstract void ValidateStructure();

public int A 
{
 get 
 {
    return _a;
 }
 set 
 {
   ValidateStructure(value);
   value = _a;
 }

As result we can receive object in acceptable state.

I understand, that for simple situations dumb decision can work without problem, but many people uses this library to copy complex objects and situation when after copying in rare cases code can fail - seem really bad. It hard to debug and understand situation.

from deepcloner.

force-net avatar force-net commented on July 19, 2024

Currently, it forbidden in code due possible unstable behavior. I'll think about ability to enable this functionality, if I found, that it won't cause strange runtime errors due inconsistent object state.

from deepcloner.

macias avatar macias commented on July 19, 2024

Upvoted.

Why it would cause strange runtime errors? Do I sense correctly some old/bad memories from C++ days? ;-)

Background info: my scenario is like this, I try to keep my code as KISS as possible, so for data transfer types and DB types I keep common core type. To copy data from one to other such method would do this in one call.

from deepcloner.

macias avatar macias commented on July 19, 2024

Thank you for detailed explanation, those are valid points for sure.

But also partial copy for POCO types is valid need. So just thinking aloud, until something better appear (or idea will be burried) -- when the exception is thrown for inheritance reason, this part of code does not affect current valid uses. So there could be additional step just before exception to check if the types have any custom method. If no -- it is a POCO type and it could be copied (new feature), if it has custom methods -- exception as today.

from deepcloner.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.