arc strong properties and memory management - automatic-ref-counting

let's say we have a controller A and it has two strong properties B and C.
B and C have one common type of property D.Releationship is as follows:
If I remove the bond betwwen A and C by setting the property C in A to nil, would C be released or it keeps existing until the bond between A and B or B and D is removed?

C will be removed, assuming D has no strong reference to C. Since there are no remaining strong references, it is deallocated.
Your diagram represents these relationships as two-way bonds, but remember that a property is only a one-way relationship; just because C has a D pointer doesn't mean D knows anything about C.

Related

Save the data with a hierarchical key or replicate the data in a DynamoDB table

I have a table in dynamodb with hierarchical information, example agency A -> agency B -> agency C, etc.
In another table I need to keep data related to this hierarchy of agencies, this data has general information of all agencies and other information specific to each agency.
For example, if the item is created by agency C, it should be seen in agency C, agency B and agency A, if it is created by agency B in agency B and agency A and if it is created agency A, only agency A. should see it. have several levels.
I was thinking two ways of doing this:
1. Replicate the same element for each level of agency and use an index with PK id of the agency, in this way I can obtain the respective elements of each agency.
2. Create a single element with a global index PK 'ELEMENT' and SK agencyAId # agencyBId # agencyCId, etc and be able to search the elements of an agency using PK -> 'ELEMENT' and SK -> startWith (agencyAId # agencyBId # agencyCId, etc)
What will be the best way ?, the first creates a large amount of redundant data and when creating or updating an element if a failure occurs it would be difficult to maintain integrity.
and in the second a hot partition would be created.
Thanks in advance.

Google Analytics Roll-up Property Does not Equal the Sum of the Child Properties

Preface
I have three properties, A, B, and C.
A is a property for A.com and there is a filter on that views to only include hostname "A.com". It also sends rollup hits to C.
B is a property for B.com and there is a filter on that views to only include hostname "B.com". It also sends rollup hits to C.
C is the aforementioned rollup property and has a filter for hostname to only equal r"(A|B).com"
Problem
Some metrics in C are equal to A+B, but other metrics are C > A+B.
For example, in A, my pageviews was 2405148, and in B was 1802017, but the rollup reports 4297385 which is a difference of 90220 pageviews.
I have also done a report on pageviews in C and broken down by hostname, and the reported values do not equal the values in the properties.
I'm stumped. Thoughts?
I.- Please look the guides, this question is off topic or not related to the guides stablished by StackOverFlow
II.- Extracted from the Guide
As a result, the number of sessions in a Roll-Up Property does not necessarily equal the sum of all sessions in Source Properties. The following examples illustrate how sessions are merged under different circumstances.
https://support.google.com/analytics/answer/6033415?hl=en
Same Client ID on each Source
Property Different Client ID on each
Source Property The effect of Session timeout settings
Greetings

Google Datastore deletes and multiple parents

I have a data model in which entity A contains references to two other entities, B and C. If either B or C is deleted, I want A to be deleted.
When creating A, it's possible to name either B or C as its parent. Is it also possible to name both B and C as its parents so that if either B or C is deleted, A is also deleted?
In more concrete terms, say search results, a result might have both a category and a region, say a web page about birds in North America. The result is stored with a reference to its category and region. Later, you want to delete the category birds and you want the result also deleted. Likewise, you delete the region North America and want the result deleted.
I hate to go on at such length about such a trivial scenario. But it doesn't seem to be covered in any of the Datastore documentation. What am I missing? Is it a basically flawed data model?
Single-parent limitation:
A child can have only one parent in Datastore. In other words, A can only be a child of B OR C, not both. Of course, a parent can have multiple children, though.
Alternative:
You can use a KeyProperty with repeated=True argument and store many Entity keys on it. In Python, this would be like this:
class A(ndb.Model):
associated_with = ndb.KeyProperty(repeated=True)
some_other_property = ndb.StringProperty()
a_entity = A(
associated_with = [b_key, c_key],
some_other_property = 'any value'
)
a_entity.put()
Automatically triggering deletes:
Datastore doesn't offer this functionality out of the box, but you can mimic it in your application. Just one idea for implementing in Python, for example, you could extend the Model class with your own delete method (haven't tested this code, it's just for illustration):
class A(ndb.Model):
associated_with = ndb.KeyProperty(repeated=True)
some_other_property = ndb.StringProperty()
def delete_ext(entity): # entity object
if entity.associated_with:
for associated in entity.associated_with:
associated.delete()
entity.key.delete()
You may want to wrap all the deletes in a transaction. Beware that a single transaction can operate on up to 25 entity groups.

How to change the PersistenceManager of an attached object?

Assume I have 3 different classes, A, B & C. C is designed to have a list of As and Bs.
If load a list of As and Bs and keep them attached, how can I set them as lists in a transient C object and persisting the transient object ?
The problem is that each of As and Bs lists are managed by different PersistenceManagers. So if I try to persist a transient C object with a list of As (attached, managed by a PersistenceManager) and a list of Bs (attached, managed by a second PersistenceManager), I'll get an exception saying that the As and Bs are being managed by a different PersistenceManager.
Is there an efficient way to resolve this instead of having to reload all the lists again by the one PersistenceManager responsible for persisting the C object ?

is there a design pattern for complex aspnet UI validation?

As an example, say I have a single domain object with 100 properties. In my UI I need complex validation of the style:
If A = 1, show controls B, C, D. B is required, C is not, and D is not required must be less than 30 if it is populated.
If A = 2, show controls B, D, E. B is not required, D is required but has no limits, and E is not required.
If A = 3, show controls B, E, F. B is required and must be more than 10, E is required, F is not required.
If B = 3 and F = 5, then show control G, but only when A = 3.
You can see my problem here. The relationships between the properties are hideously complex, with validation changing dependant on earlier values and in combination with other values.
How have people modelled and handled this in the past? Validation does not need to very often, but a config/xml-based solution would probably be best.
You could project this gigantic domain object into smaller objects containing only the subsets of properties needed and name them according to the scenario they are describing. It's creating some sort of ViewModel if you will.
There has to be a specific use case for each case of A = "X" or B = "Y" etc. If you are splitting things up you can define validation rules per ViewModel. Those ViewModels could also contain the visible/hidden settings for your controls.

Resources