Tag Info

New answers tagged

4

In my purview, Object is undefinitive, and belongs in a binary format, not in a human-readable text. I don't see the relationship between these two things; there are plenty of good reasons to choose text versus binary: this is not one of them. How it appears is an implementation detail only. any derived type of Object The biggest challenge, then, ...


1

If you add a method Lead.list() where it returns a list of leads it's violation of SRP, as the fetching a list of Leads is not the responsibility of Lead object. So the best option is to use a data service or a repository. For example LeadRepository could have methods GetAll(), GetById(id)


1

But what if it isn't so simple and we really don't know what kind of thing we want to store, only that it is one of a finite set of well-defined things? This is precisely what a tagged union is for. You can emulate them in Java using an abstract base class with a private constructor, and final inner subclasses. The inner subclasses can use the private ...


1

This feels like a "service" class or an implementation of the "unit of work" pattern would be beneficial. I'm leaning towards Unit of Work here. You can define multiple "unit of work" classes in a hierarchy to break up the updates. Plus you can define additional classes for updating the $db_object with values from the $api_object. While this adds ...


1

Along with Robert Harvey's advice, rather than 'setting' an existing API object's properties from an instance of a DB Object directly where you need it to happen, why not just 'create' a brand new API object using a factory that uses your DB object as a template? class ApiObjectFactory { public static function createFromDbObject($dbObject, ...



Top 50 recent answers are included