3

There are businesses and people. People could be liked and businesses could be commented on:

class Like
class Comment

class Person implements iLikeTarget
class Business implements iCommentTarget

Likes and comments are performed by a user(person) so they are authored:

class Like implements iAuthored
class Comment implements iAuthored

People's like could also be used in their history:

class history
class Like implements iAuthored, iHistoryTarget

Now, a smart developer comes and says each history is attached to a user so history should be authored:

interface iHistoryTarget extends iAuthored

so it could be removed from class Like:

class Person implements iLikeTarget
class Business implements iCommentTarget

class Like implements iHistoryTarget
class Comment implements iAuthored

class history

interface iHistoryTarget extends iAuthored

Here, another smart guy comes with a question: How could I capture the Authored fact in Like and Comment classes? He may knows nothing about history concept in the project.

By scalling these kind of functionallities, interfaces may goes to their encapsulated types which cause more type strength, on the other hand explicitness suffered and also code end users will face much pain to process. So here is the question: Should I encapsulate those dependant types to their parent types (interface hierarchies) or not or explicitly repeat each type for every single level of my type system or ...?

  • Do you know traits, refinements, subject-oriented programming, context oriented programming, data-context-interaction? Maybe they can help here. – User Nov 3 '14 at 17:06
  • yeah. How could they help me? – Hossein Jazayeri Nov 5 '14 at 8:10
1

I would say being an authored object is independent of being a history item so the way to reflect the domain more closely would be:

class Like implements iHistoryItem, iAuthored

This says that even if Like was not a history item, it would still be an authored action.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.