[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]
Subject: [OASIS Issue Tracker] Commented: (ODATA-364) Remove restriction that a property MUST NOT have the same name as its containing type
[ http://tools.oasis-open.org/issues/browse/ODATA-364?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=33327#action_33327 ] Stefan Drees commented on ODATA-364: ------------------------------------ Maybe I did not understand the possible translation of Evan's requested canonical naming scenario to a programming lanuage right. So, please excuse any style or otherwise - deficits and follow me on my journey of adhoc mapping the scenario : The following test-code in python: #! env python """Don't tell anyone Stefan wrote this. ;-) """ class Employee(object): """ Anyone being employed. """ def __init__(self, key, man = None): self.key = key self.manager = man def join(self, man): """Join a managed relationship. """ self.manager = man def leave(self): """Leave a managed relationship. """ self.manager = None def Manager(self): """Here we have the same name as the derived type. And PEP8 states the name should match [a-z_][a-z0-9_]{2,30}$ ...""" return str(self.manager) class Manager(Employee): """ A manager is expected to be employed. """ def __init__(self, key): super(Manager, self).__init__(key, key) self.subordinates = [] def take(self, key): """Take responsibility for another employee as identified by key. """ if key not in self.subordinates: self.subordinates.append(key) def release(self, key): """Release responsibility for employye as identified by key. """ if key in self.subordinates: self.subordinates.remove(key) if __name__ == "__main__": manager = Manager(1) employee = Employee(42, manager.key) manager.take(employee.key) print "Manager(1) has key = " + str(manager.key) print "Manager(1) has subordinates = ", print repr(manager.subordinates) print "Employee(42) has member property manager = ", print str(employee.manager) print "Employee(42)'s member function Manager() yields: ", print employee.Manager() employee.leave() manager.release(employee.key) print "Manager(1) released Employee(42), thus subordinates = ", print repr(manager.subordinates) print "Employee(42)'s member function Manager() now yields: ", print employee.Manager() Yields when executed: Manager(1) has key = 1 Manager(1) has subordinates = [42] Employee(42) has member property manager = 1 Employee(42)'s member function Manager() yields: 1 Manager(1) released Employee(42), thus subordinates = [] Employee(42)'s member function Manager() now yields: None So this works and the method Employee.Manager() would map to the navigational property as noted by Evan. Right? Is it really impossible in C# to define a class Employee where a method has the same name (Manager) as a class Manager derived from that class? > Remove restriction that a property MUST NOT have the same name as its containing type > ------------------------------------------------------------------------------------- > > Key: ODATA-364 > URL: http://tools.oasis-open.org/issues/browse/ODATA-364 > Project: OASIS Open Data Protocol (OData) TC > Issue Type: Improvement > Components: OData CSDL > Affects Versions: V4.0_CSD01 > Environment: [Proposed] > Reporter: Ralf Handl > Fix For: V4.0_CSD02 > > > Chapters 8 and 9 state that > - Properties MUST NOT have the same name as the declaring entity type. > - Properties MUST NOT have the same name as the declaring complex type. > This sometimes prevents using natural names for properties, e.g. > - EntityType Employee > - EntityType Manager inherits from Employee > - EntityType Employee has NavigationProperty that leads to the manager > The natural name for the navigation property is Manager, but prevented by the above rule. So the navigation property has to be named "TheManager" or "manager" (using different case) -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://tools.oasis-open.org/issues/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira
[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]